Skip to content

Commit c6f4b47

Browse files
committed
Use generated CodingKeys for Facility entity
1 parent 1c1051a commit c6f4b47

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

‎Tests/CoreModelTests/TestModel.swift‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ struct Person: Equatable, Hashable, Codable, Identifiable {
3232
self.age = age
3333
self.events = events
3434
}
35-
35+
36+
// - Note: Declared manually because `Event.@Relationship(inverse: .events)`
37+
// must type-check against this enum while macros are still expanding;
38+
// the compiler will not expand `@Entity`'s generated `CodingKeys` to
39+
// satisfy another macro's argument. Entities that are not referenced as a
40+
// relationship destination (e.g. `Facility`) can rely on the generated enum.
3641
enum CodingKeys: CodingKey {
3742
case id
3843
case name
@@ -62,7 +67,8 @@ struct Event: Equatable, Hashable, Codable, Identifiable {
6267
self.date = date
6368
self.people = people
6469
}
65-
70+
71+
// - Note: Declared manually; see `Person.CodingKeys`.
6672
enum CodingKeys: CodingKey {
6773
case id
6874
case name
@@ -458,12 +464,4 @@ public struct Facility: Equatable, Hashable, Codable, Identifiable {
458464
self.address = address
459465
self.billingAddress = billingAddress
460466
}
461-
462-
public enum CodingKeys: CodingKey {
463-
464-
case id
465-
case name
466-
case address
467-
case billingAddress
468-
}
469467
}

0 commit comments

Comments
 (0)