mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-31 06:33:06 +02:00
Assert on reserved property names
This commit is contained in:
@@ -288,6 +288,10 @@ public final class CoreStoreSchema: DynamicSchema {
|
|||||||
switch child.value {
|
switch child.value {
|
||||||
|
|
||||||
case let attribute as AttributeProtocol:
|
case let attribute as AttributeProtocol:
|
||||||
|
CoreStore.assert(
|
||||||
|
!NSManagedObject.instancesRespond(to: Selector(attribute.keyPath)),
|
||||||
|
"Attribute Property name \"\(String(reflecting: entity.type)).\(attribute.keyPath)\" is not allowed because it collides with \"\(String(reflecting: NSManagedObject.self)).\(attribute.keyPath)\""
|
||||||
|
)
|
||||||
let description = NSAttributeDescription()
|
let description = NSAttributeDescription()
|
||||||
description.name = attribute.keyPath
|
description.name = attribute.keyPath
|
||||||
description.attributeType = Swift.type(of: attribute).attributeType
|
description.attributeType = Swift.type(of: attribute).attributeType
|
||||||
@@ -302,6 +306,10 @@ public final class CoreStoreSchema: DynamicSchema {
|
|||||||
customGetterSetterByKeyPaths[attribute.keyPath] = (attribute.getter, attribute.setter)
|
customGetterSetterByKeyPaths[attribute.keyPath] = (attribute.getter, attribute.setter)
|
||||||
|
|
||||||
case let relationship as RelationshipProtocol:
|
case let relationship as RelationshipProtocol:
|
||||||
|
CoreStore.assert(
|
||||||
|
!NSManagedObject.instancesRespond(to: Selector(relationship.keyPath)),
|
||||||
|
"Relationship Property name \"\(String(reflecting: entity.type)).\(relationship.keyPath)\" is not allowed because it collides with \"\(String(reflecting: NSManagedObject.self)).\(relationship.keyPath)\""
|
||||||
|
)
|
||||||
let description = NSRelationshipDescription()
|
let description = NSRelationshipDescription()
|
||||||
description.name = relationship.keyPath
|
description.name = relationship.keyPath
|
||||||
description.minCount = relationship.minCount
|
description.minCount = relationship.minCount
|
||||||
|
|||||||
Reference in New Issue
Block a user