Names of NSEntityDescriptions are only checked by the Xcode UI
| Originator: | neocool2 | ||
| Number: | rdar://19714793 | Date Originated: | 04-Feb-2015 04:36 PM |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | 8.1 |
| Classification: | Other Bug | Reproducible: | Always |
Summary:
The character set for an NSEntityDescription’s name is limited, but this is seemingly only enforced when typing in the Core Data model editor inside Xcode.
Consider this code:
#!/usr/bin/xcrun swift
import CoreData
class Foo_Bar : NSManagedObject {
}
let entity = NSEntityDescription()
entity.name = "Foo Bar"
entity.managedObjectClassName = "spacesInEntity.Foo_Bar"
let model = NSManagedObjectModel()
model.entities = [entity]
let coordinator = NSPersistentStoreCoordinator(managedObjectModel: model)
let url = NSURL(fileURLWithPath: "/tmp/store.lol")
coordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil, error: nil)
let context = NSManagedObjectContext()
context.persistentStoreCoordinator = coordinator
let object = NSEntityDescription.insertNewObjectForEntityForName(entity.name!, inManagedObjectContext:context) as Foo_Bar
println(object.description)
Steps to Reproduce:
Run the Swift example code from above.
Expected Results:
Fails at some point with an error message regarding the use of an unsupported entity name.
Actual Results:
A syntax error in the generated SQL:
CoreData: error: (1) I/O error for database at /tmp/store.lol. SQLite error code:1, 'near "BAR": syntax error'
Regression: -
Notes:
Adding insult to injury, this works just fine when using NSInMemoryStoreType
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!