Skip to content
This repository was archived by the owner on Mar 1, 2020. It is now read-only.

Commit 5f3a819

Browse files
committed
Handle entities with superentities
Closes #3
1 parent 79033b0 commit 5f3a819

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

bin/querykit.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ extension NSEntityDescription {
8383

8484
return managedObjectClassName
8585
}
86+
87+
func qk_hasSuperProperty(name:String) -> Bool {
88+
if let superentity = superentity {
89+
if superentity.qk_className != "NSManagedObject" && superentity.propertiesByName[name] != nil {
90+
return true
91+
}
92+
93+
return superentity.qk_hasSuperProperty(name)
94+
}
95+
96+
return false
97+
}
8698
}
8799

88100
class CommandError : ErrorType {
@@ -95,6 +107,10 @@ class CommandError : ErrorType {
95107

96108
func render(entity:NSEntityDescription, destination:Path, template:Template) throws {
97109
let attributes = entity.properties.flatMap { property -> AttributeDescription? in
110+
if entity.qk_hasSuperProperty(property.name) {
111+
return nil
112+
}
113+
98114
if let attribute = property as? NSAttributeDescription {
99115
return attribute.qkAttributeDescription
100116
} else if let relationship = property as? NSRelationshipDescription {

0 commit comments

Comments
 (0)