mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-21 00:49:49 +01:00
unit test for scalar IDs for ImportableUniqueObject
This commit is contained in:
@@ -1083,42 +1083,25 @@ extension TestEntity1: ImportableUniqueObject {
|
||||
|
||||
// MARK: ImportableUniqueObject
|
||||
|
||||
typealias UniqueIDType = NSNumber
|
||||
typealias UniqueIDType = Int64
|
||||
|
||||
static var uniqueIDKeyPath: String {
|
||||
|
||||
return #keyPath(TestEntity1.testEntityID)
|
||||
}
|
||||
|
||||
var uniqueIDValue: NSNumber {
|
||||
|
||||
get {
|
||||
|
||||
guard let ID = self.testEntityID else {
|
||||
|
||||
XCTFail()
|
||||
return 0
|
||||
}
|
||||
return ID
|
||||
}
|
||||
set {
|
||||
|
||||
self.testEntityID = newValue
|
||||
}
|
||||
}
|
||||
|
||||
static func shouldUpdate(from source: ImportSource, in transaction: BaseDataTransaction) -> Bool {
|
||||
|
||||
return source["skip_update"] == nil
|
||||
}
|
||||
|
||||
static func uniqueID(from source: ImportSource, in transaction: BaseDataTransaction) throws -> NSNumber? {
|
||||
static func uniqueID(from source: ImportSource, in transaction: BaseDataTransaction) throws -> Int64? {
|
||||
|
||||
if let _ = source["throw_on_id"] {
|
||||
|
||||
throw TestIDError()
|
||||
}
|
||||
return source[(#keyPath(TestEntity1.testEntityID))] as? NSNumber
|
||||
return source[(#keyPath(TestEntity1.testEntityID))] as? Int64
|
||||
}
|
||||
|
||||
func update(from source: ImportSource, in transaction: BaseDataTransaction) throws {
|
||||
|
||||
Reference in New Issue
Block a user