mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-15 05:33:31 +01:00
extra extra type safety for attributes (fetching and importing)
This commit is contained in:
@@ -80,14 +80,10 @@
|
||||
B50392FA1C47963F009900CA /* NSManagedObject+Transaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = B50392F81C478FF3009900CA /* NSManagedObject+Transaction.swift */; };
|
||||
B50392FB1C479640009900CA /* NSManagedObject+Transaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = B50392F81C478FF3009900CA /* NSManagedObject+Transaction.swift */; };
|
||||
B504D0D61B02362500B2BBB1 /* CoreStore+Setup.swift in Sources */ = {isa = PBXBuildFile; fileRef = B504D0D51B02362500B2BBB1 /* CoreStore+Setup.swift */; };
|
||||
B50956B81E30B810003DF913 /* CoreDataNativeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B50956B71E30B810003DF913 /* CoreDataNativeType.swift */; };
|
||||
B50956B91E30B810003DF913 /* CoreDataNativeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B50956B71E30B810003DF913 /* CoreDataNativeType.swift */; };
|
||||
B50956BA1E30B810003DF913 /* CoreDataNativeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B50956B71E30B810003DF913 /* CoreDataNativeType.swift */; };
|
||||
B50956BB1E30B810003DF913 /* CoreDataNativeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B50956B71E30B810003DF913 /* CoreDataNativeType.swift */; };
|
||||
B509C7F41E54511B0061C547 /* CoreStoreSupportedAttributeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B509C7F31E54511B0061C547 /* CoreStoreSupportedAttributeType.swift */; };
|
||||
B509C7F51E54511B0061C547 /* CoreStoreSupportedAttributeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B509C7F31E54511B0061C547 /* CoreStoreSupportedAttributeType.swift */; };
|
||||
B509C7F61E54511B0061C547 /* CoreStoreSupportedAttributeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B509C7F31E54511B0061C547 /* CoreStoreSupportedAttributeType.swift */; };
|
||||
B509C7F71E54511B0061C547 /* CoreStoreSupportedAttributeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B509C7F31E54511B0061C547 /* CoreStoreSupportedAttributeType.swift */; };
|
||||
B509C7F41E54511B0061C547 /* CoreStoreUniqueIDAttributeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B509C7F31E54511B0061C547 /* CoreStoreUniqueIDAttributeType.swift */; };
|
||||
B509C7F51E54511B0061C547 /* CoreStoreUniqueIDAttributeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B509C7F31E54511B0061C547 /* CoreStoreUniqueIDAttributeType.swift */; };
|
||||
B509C7F61E54511B0061C547 /* CoreStoreUniqueIDAttributeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B509C7F31E54511B0061C547 /* CoreStoreUniqueIDAttributeType.swift */; };
|
||||
B509C7F71E54511B0061C547 /* CoreStoreUniqueIDAttributeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B509C7F31E54511B0061C547 /* CoreStoreUniqueIDAttributeType.swift */; };
|
||||
B51BE06A1B47FC4B0069F532 /* NSManagedObjectModel+Setup.swift in Sources */ = {isa = PBXBuildFile; fileRef = B51BE0691B47FC4B0069F532 /* NSManagedObjectModel+Setup.swift */; };
|
||||
B51FE5AB1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = B51FE5AA1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift */; };
|
||||
B51FE5AD1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = B51FE5AA1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift */; };
|
||||
@@ -267,6 +263,14 @@
|
||||
B5489F501CF603D5008B4978 /* FromTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5489F4F1CF603D5008B4978 /* FromTests.swift */; };
|
||||
B5489F511CF603D5008B4978 /* FromTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5489F4F1CF603D5008B4978 /* FromTests.swift */; };
|
||||
B5489F521CF603D5008B4978 /* FromTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5489F4F1CF603D5008B4978 /* FromTests.swift */; };
|
||||
B549F65E1E569C7400FBAB2D /* CoreStoreQueryingAttributeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B549F65D1E569C7400FBAB2D /* CoreStoreQueryingAttributeType.swift */; };
|
||||
B549F65F1E569C7400FBAB2D /* CoreStoreQueryingAttributeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B549F65D1E569C7400FBAB2D /* CoreStoreQueryingAttributeType.swift */; };
|
||||
B549F6601E569C7400FBAB2D /* CoreStoreQueryingAttributeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B549F65D1E569C7400FBAB2D /* CoreStoreQueryingAttributeType.swift */; };
|
||||
B549F6611E569C7400FBAB2D /* CoreStoreQueryingAttributeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B549F65D1E569C7400FBAB2D /* CoreStoreQueryingAttributeType.swift */; };
|
||||
B549F6731E56A92800FBAB2D /* CoreDataNativeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B549F6721E56A92800FBAB2D /* CoreDataNativeType.swift */; };
|
||||
B549F6741E56A92800FBAB2D /* CoreDataNativeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B549F6721E56A92800FBAB2D /* CoreDataNativeType.swift */; };
|
||||
B549F6751E56A92800FBAB2D /* CoreDataNativeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B549F6721E56A92800FBAB2D /* CoreDataNativeType.swift */; };
|
||||
B549F6761E56A92800FBAB2D /* CoreDataNativeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B549F6721E56A92800FBAB2D /* CoreDataNativeType.swift */; };
|
||||
B54A6A551BA15F2A007870FD /* FetchedResultsControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B54A6A541BA15F2A007870FD /* FetchedResultsControllerDelegate.swift */; };
|
||||
B5519A401CA1B17B002BEF78 /* ErrorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5519A3F1CA1B17B002BEF78 /* ErrorTests.swift */; };
|
||||
B5519A411CA1B17B002BEF78 /* ErrorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5519A3F1CA1B17B002BEF78 /* ErrorTests.swift */; };
|
||||
@@ -608,8 +612,7 @@
|
||||
B501FDE61CA8D20500BE22EF /* CSListObserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CSListObserver.swift; sourceTree = "<group>"; };
|
||||
B50392F81C478FF3009900CA /* NSManagedObject+Transaction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSManagedObject+Transaction.swift"; sourceTree = "<group>"; };
|
||||
B504D0D51B02362500B2BBB1 /* CoreStore+Setup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CoreStore+Setup.swift"; sourceTree = "<group>"; };
|
||||
B50956B71E30B810003DF913 /* CoreDataNativeType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreDataNativeType.swift; sourceTree = "<group>"; };
|
||||
B509C7F31E54511B0061C547 /* CoreStoreSupportedAttributeType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreStoreSupportedAttributeType.swift; sourceTree = "<group>"; };
|
||||
B509C7F31E54511B0061C547 /* CoreStoreUniqueIDAttributeType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreStoreUniqueIDAttributeType.swift; sourceTree = "<group>"; };
|
||||
B51BE0691B47FC4B0069F532 /* NSManagedObjectModel+Setup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSManagedObjectModel+Setup.swift"; sourceTree = "<group>"; };
|
||||
B51FE5AA1CD4D00300E54258 /* CoreStore+CustomDebugStringConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CoreStore+CustomDebugStringConvertible.swift"; sourceTree = "<group>"; };
|
||||
B5202CF91C04688100DED140 /* NSFetchedResultsController+Convenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSFetchedResultsController+Convenience.swift"; sourceTree = "<group>"; };
|
||||
@@ -646,6 +649,8 @@
|
||||
B5489F451CF5F017008B4978 /* TransactionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransactionTests.swift; sourceTree = "<group>"; };
|
||||
B5489F4B1CF5F743008B4978 /* BaseTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseTestCase.swift; sourceTree = "<group>"; };
|
||||
B5489F4F1CF603D5008B4978 /* FromTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FromTests.swift; sourceTree = "<group>"; };
|
||||
B549F65D1E569C7400FBAB2D /* CoreStoreQueryingAttributeType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreStoreQueryingAttributeType.swift; sourceTree = "<group>"; };
|
||||
B549F6721E56A92800FBAB2D /* CoreDataNativeType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreDataNativeType.swift; sourceTree = "<group>"; };
|
||||
B54A6A541BA15F2A007870FD /* FetchedResultsControllerDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchedResultsControllerDelegate.swift; sourceTree = "<group>"; };
|
||||
B5519A3F1CA1B17B002BEF78 /* ErrorTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ErrorTests.swift; sourceTree = "<group>"; };
|
||||
B5519A491CA1F4FB002BEF78 /* CSError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CSError.swift; sourceTree = "<group>"; };
|
||||
@@ -1038,6 +1043,7 @@
|
||||
children = (
|
||||
2F291E2619C6D3CF007AF63F /* CoreStore.swift */,
|
||||
B5D1E22B19FA9FBC003B2874 /* CoreStoreError.swift */,
|
||||
B549F6721E56A92800FBAB2D /* CoreDataNativeType.swift */,
|
||||
B5E84EDA1AFF84500064E85B /* Setup */,
|
||||
B5E84EE21AFF84610064E85B /* Logging */,
|
||||
B5E84EE91AFF846E0064E85B /* Transactions */,
|
||||
@@ -1108,8 +1114,7 @@
|
||||
B5F1DA8C1B9AA97D007C5CBB /* ImportableObject.swift */,
|
||||
B5F1DA8F1B9AA991007C5CBB /* ImportableUniqueObject.swift */,
|
||||
B5E834B81B76311F001D3D50 /* BaseDataTransaction+Importing.swift */,
|
||||
B50956B71E30B810003DF913 /* CoreDataNativeType.swift */,
|
||||
B509C7F31E54511B0061C547 /* CoreStoreSupportedAttributeType.swift */,
|
||||
B509C7F31E54511B0061C547 /* CoreStoreUniqueIDAttributeType.swift */,
|
||||
);
|
||||
path = Importing;
|
||||
sourceTree = "<group>";
|
||||
@@ -1159,6 +1164,7 @@
|
||||
B5E84F071AFF847B0064E85B /* CoreStore+Querying.swift */,
|
||||
B596BBB51DD5BC67001DCDD9 /* FetchableSource.swift */,
|
||||
B596BBBA1DD5C39F001DCDD9 /* QueryableSource.swift */,
|
||||
B549F65D1E569C7400FBAB2D /* CoreStoreQueryingAttributeType.swift */,
|
||||
B5E84F0A1AFF847B0064E85B /* Protocol Clauses */,
|
||||
B5E84EFF1AFF847B0064E85B /* Concrete Clauses */,
|
||||
);
|
||||
@@ -1586,7 +1592,8 @@
|
||||
B56007161B4018AB00A9A8F9 /* MigrationChain.swift in Sources */,
|
||||
B5E1B59D1CAA2568007FD580 /* CSDataStack+Observing.swift in Sources */,
|
||||
B5ECDC231CA81A3900C7F112 /* CSCoreStore+Querying.swift in Sources */,
|
||||
B509C7F41E54511B0061C547 /* CoreStoreSupportedAttributeType.swift in Sources */,
|
||||
B549F6731E56A92800FBAB2D /* CoreDataNativeType.swift in Sources */,
|
||||
B509C7F41E54511B0061C547 /* CoreStoreUniqueIDAttributeType.swift in Sources */,
|
||||
B5E84F0E1AFF847B0064E85B /* Tweak.swift in Sources */,
|
||||
B5E1B5931CAA0C15007FD580 /* CSObjectMonitor.swift in Sources */,
|
||||
B5ECDC291CA81CC700C7F112 /* CSDataStack+Transaction.swift in Sources */,
|
||||
@@ -1613,7 +1620,6 @@
|
||||
B5F1DA8D1B9AA97D007C5CBB /* ImportableObject.swift in Sources */,
|
||||
B56965241B356B820075EE4A /* MigrationResult.swift in Sources */,
|
||||
B5FE4DAC1C85D44E00FA6A91 /* SQLiteStore.swift in Sources */,
|
||||
B50956B81E30B810003DF913 /* CoreDataNativeType.swift in Sources */,
|
||||
B501FDE71CA8D20500BE22EF /* CSListObserver.swift in Sources */,
|
||||
B501FDE21CA8D1F500BE22EF /* CSListMonitor.swift in Sources */,
|
||||
2F291E2719C6D3CF007AF63F /* CoreStore.swift in Sources */,
|
||||
@@ -1659,6 +1665,7 @@
|
||||
B5E84F301AFF849C0064E85B /* NSManagedObjectContext+CoreStore.swift in Sources */,
|
||||
B546F9691C9AF26D00D5AC55 /* CSInMemoryStore.swift in Sources */,
|
||||
B53FBA1E1CAB63FA00F0D40A /* NSFetchedResultsController+ObjectiveC.swift in Sources */,
|
||||
B549F65E1E569C7400FBAB2D /* CoreStoreQueryingAttributeType.swift in Sources */,
|
||||
B5E84F211AFF84860064E85B /* CoreStore+Observing.swift in Sources */,
|
||||
B559CD431CAA8B6300E4D58B /* CSSetupResult.swift in Sources */,
|
||||
B5FE4DA71C84FB4400FA6A91 /* InMemoryStore.swift in Sources */,
|
||||
@@ -1741,7 +1748,8 @@
|
||||
B5D3F6461C887C0A00C7492A /* LegacySQLiteStore.swift in Sources */,
|
||||
B5E1B59F1CAA2568007FD580 /* CSDataStack+Observing.swift in Sources */,
|
||||
B5ECDC251CA81A3900C7F112 /* CSCoreStore+Querying.swift in Sources */,
|
||||
B509C7F51E54511B0061C547 /* CoreStoreSupportedAttributeType.swift in Sources */,
|
||||
B549F6741E56A92800FBAB2D /* CoreDataNativeType.swift in Sources */,
|
||||
B509C7F51E54511B0061C547 /* CoreStoreUniqueIDAttributeType.swift in Sources */,
|
||||
82BA18B31C4BBD3900A0916E /* ImportableUniqueObject.swift in Sources */,
|
||||
B5E1B5951CAA0C15007FD580 /* CSObjectMonitor.swift in Sources */,
|
||||
B5ECDC2B1CA81CC700C7F112 /* CSDataStack+Transaction.swift in Sources */,
|
||||
@@ -1768,7 +1776,6 @@
|
||||
82BA18B01C4BBD3100A0916E /* NSManagedObject+Transaction.swift in Sources */,
|
||||
82BA18D41C4BBD7100A0916E /* NSManagedObjectContext+Querying.swift in Sources */,
|
||||
82BA18D51C4BBD7100A0916E /* NSManagedObjectContext+Setup.swift in Sources */,
|
||||
B50956B91E30B810003DF913 /* CoreDataNativeType.swift in Sources */,
|
||||
B501FDE91CA8D20500BE22EF /* CSListObserver.swift in Sources */,
|
||||
B501FDE41CA8D1F500BE22EF /* CSListMonitor.swift in Sources */,
|
||||
B5FE4DA31C8481E100FA6A91 /* StorageInterface.swift in Sources */,
|
||||
@@ -1814,6 +1821,7 @@
|
||||
B546F96A1C9AF26D00D5AC55 /* CSInMemoryStore.swift in Sources */,
|
||||
B53FBA201CAB63FA00F0D40A /* NSFetchedResultsController+ObjectiveC.swift in Sources */,
|
||||
82BA18A81C4BBD2900A0916E /* CoreStoreLogger.swift in Sources */,
|
||||
B549F65F1E569C7400FBAB2D /* CoreStoreQueryingAttributeType.swift in Sources */,
|
||||
B559CD451CAA8B6300E4D58B /* CSSetupResult.swift in Sources */,
|
||||
82BA18B81C4BBD4200A0916E /* ClauseTypes.swift in Sources */,
|
||||
B5ECDBEE1CA6BF2000C7F112 /* CSFrom.swift in Sources */,
|
||||
@@ -1896,7 +1904,8 @@
|
||||
B5220E241D13085E009BC71E /* NSFetchedResultsController+Convenience.swift in Sources */,
|
||||
B559CD471CAA8B6300E4D58B /* CSSetupResult.swift in Sources */,
|
||||
B5ECDBF01CA6BF2000C7F112 /* CSFrom.swift in Sources */,
|
||||
B509C7F71E54511B0061C547 /* CoreStoreSupportedAttributeType.swift in Sources */,
|
||||
B549F6761E56A92800FBAB2D /* CoreDataNativeType.swift in Sources */,
|
||||
B509C7F71E54511B0061C547 /* CoreStoreUniqueIDAttributeType.swift in Sources */,
|
||||
B5220E1F1D130810009BC71E /* CSListObserver.swift in Sources */,
|
||||
B52DD1941BE1F92500949AFE /* CoreStore.swift in Sources */,
|
||||
B52DD1A61BE1F92F00949AFE /* BaseDataTransaction+Importing.swift in Sources */,
|
||||
@@ -1923,7 +1932,6 @@
|
||||
B5220E231D130826009BC71E /* NSFetchedResultsController+ObjectiveC.swift in Sources */,
|
||||
B52DD19D1BE1F92C00949AFE /* BaseDataTransaction.swift in Sources */,
|
||||
B5220E131D1305ED009BC71E /* SectionBy.swift in Sources */,
|
||||
B50956BB1E30B810003DF913 /* CoreDataNativeType.swift in Sources */,
|
||||
B559CD4D1CAA8C6D00E4D58B /* CSStorageInterface.swift in Sources */,
|
||||
B5ECDBE91CA6BEA300C7F112 /* CSClauseTypes.swift in Sources */,
|
||||
B52DD1B81BE1F94000949AFE /* DataStack+Migration.swift in Sources */,
|
||||
@@ -1969,6 +1977,7 @@
|
||||
B52DD1BB1BE1F94000949AFE /* MigrationType.swift in Sources */,
|
||||
B52DD1C91BE1F94600949AFE /* NSManagedObjectContext+Transaction.swift in Sources */,
|
||||
B5220E151D130663009BC71E /* CoreStore+Observing.swift in Sources */,
|
||||
B549F6611E569C7400FBAB2D /* CoreStoreQueryingAttributeType.swift in Sources */,
|
||||
B52DD19B1BE1F92800949AFE /* CoreStoreLogger.swift in Sources */,
|
||||
B52DD1991BE1F92800949AFE /* DefaultLogger.swift in Sources */,
|
||||
B5220E201D130813009BC71E /* CSObjectMonitor.swift in Sources */,
|
||||
@@ -2051,7 +2060,8 @@
|
||||
B5E1B5A01CAA2568007FD580 /* CSDataStack+Observing.swift in Sources */,
|
||||
B5ECDC261CA81A3900C7F112 /* CSCoreStore+Querying.swift in Sources */,
|
||||
B563217F1BD65216006C9394 /* CoreStore.swift in Sources */,
|
||||
B509C7F61E54511B0061C547 /* CoreStoreSupportedAttributeType.swift in Sources */,
|
||||
B549F6751E56A92800FBAB2D /* CoreDataNativeType.swift in Sources */,
|
||||
B509C7F61E54511B0061C547 /* CoreStoreUniqueIDAttributeType.swift in Sources */,
|
||||
B5E1B5961CAA0C15007FD580 /* CSObjectMonitor.swift in Sources */,
|
||||
B5ECDC2C1CA81CC700C7F112 /* CSDataStack+Transaction.swift in Sources */,
|
||||
B56321911BD65216006C9394 /* BaseDataTransaction+Importing.swift in Sources */,
|
||||
@@ -2078,7 +2088,6 @@
|
||||
B5FE4DA41C8481E100FA6A91 /* StorageInterface.swift in Sources */,
|
||||
B56321B31BD6521C006C9394 /* NSManagedObjectContext+Setup.swift in Sources */,
|
||||
B501FDEA1CA8D20500BE22EF /* CSListObserver.swift in Sources */,
|
||||
B50956BA1E30B810003DF913 /* CoreDataNativeType.swift in Sources */,
|
||||
B501FDE51CA8D1F500BE22EF /* CSListMonitor.swift in Sources */,
|
||||
B5ECDC141CA816E500C7F112 /* CSTweak.swift in Sources */,
|
||||
B56321AE1BD6521C006C9394 /* NotificationObserver.swift in Sources */,
|
||||
@@ -2124,6 +2133,7 @@
|
||||
B546F96B1C9AF26D00D5AC55 /* CSInMemoryStore.swift in Sources */,
|
||||
B53FBA211CAB63FA00F0D40A /* NSFetchedResultsController+ObjectiveC.swift in Sources */,
|
||||
B563218B1BD65216006C9394 /* UnsafeDataTransaction.swift in Sources */,
|
||||
B549F6601E569C7400FBAB2D /* CoreStoreQueryingAttributeType.swift in Sources */,
|
||||
B559CD461CAA8B6300E4D58B /* CSSetupResult.swift in Sources */,
|
||||
B56321A61BD65216006C9394 /* MigrationType.swift in Sources */,
|
||||
B5ECDBEF1CA6BF2000C7F112 /* CSFrom.swift in Sources */,
|
||||
|
||||
@@ -36,40 +36,40 @@ class ImportTests: BaseTestDataTestCase {
|
||||
@objc
|
||||
dynamic func test_ThatAttributeProtocols_BehaveCorrectly() {
|
||||
|
||||
XCTAssertEqual(NSNumber.cs_fromNativeType(NSNumber(value: true))?.boolValue, true)
|
||||
XCTAssertEqual(NSNumber.cs_fromNativeType(NSNumber(value: Int16.max))?.int16Value, Int16.max)
|
||||
XCTAssertEqual(NSNumber.cs_fromNativeType(NSNumber(value: Int32.max))?.int32Value, Int32.max)
|
||||
XCTAssertEqual(NSNumber.cs_fromNativeType(NSNumber(value: Int64.max))?.int64Value, Int64.max)
|
||||
XCTAssertEqual(NSNumber.cs_fromNativeType(NSNumber(value: MAXFLOAT))?.floatValue, MAXFLOAT)
|
||||
XCTAssertEqual(NSNumber.cs_fromNativeType(NSNumber(value: Double(MAXFLOAT)))?.doubleValue, Double(MAXFLOAT))
|
||||
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSNumber(value: true))?.boolValue, true)
|
||||
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSNumber(value: Int16.max))?.int16Value, Int16.max)
|
||||
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSNumber(value: Int32.max))?.int32Value, Int32.max)
|
||||
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSNumber(value: Int64.max))?.int64Value, Int64.max)
|
||||
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSNumber(value: MAXFLOAT))?.floatValue, MAXFLOAT)
|
||||
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSNumber(value: Double(MAXFLOAT)))?.doubleValue, Double(MAXFLOAT))
|
||||
|
||||
XCTAssertEqual(NSDecimalNumber.cs_fromNativeType(NSDecimalNumber(string: "1"))?.boolValue, true)
|
||||
XCTAssertEqual(NSDecimalNumber.cs_fromNativeType(NSDecimalNumber(string: Int16.max.description))?.int16Value, Int16.max)
|
||||
XCTAssertEqual(NSDecimalNumber.cs_fromNativeType(NSDecimalNumber(string: Int32.max.description))?.int32Value, Int32.max)
|
||||
XCTAssertEqual(NSDecimalNumber.cs_fromNativeType(NSDecimalNumber(string: Int64.max.description))?.int64Value, Int64.max)
|
||||
XCTAssertEqual(NSDecimalNumber.cs_fromNativeType(NSDecimalNumber(string: MAXFLOAT.description))?.doubleValue, NSDecimalNumber(string: MAXFLOAT.description).doubleValue)
|
||||
XCTAssertEqual(NSDecimalNumber.cs_fromNativeType(NSDecimalNumber(string: MAXFLOAT.description))?.floatValue, NSDecimalNumber(string: MAXFLOAT.description).floatValue)
|
||||
XCTAssertEqual(NSDecimalNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: "1"))?.boolValue, true)
|
||||
XCTAssertEqual(NSDecimalNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: Int16.max.description))?.int16Value, Int16.max)
|
||||
XCTAssertEqual(NSDecimalNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: Int32.max.description))?.int32Value, Int32.max)
|
||||
XCTAssertEqual(NSDecimalNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: Int64.max.description))?.int64Value, Int64.max)
|
||||
XCTAssertEqual(NSDecimalNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: MAXFLOAT.description))?.doubleValue, NSDecimalNumber(string: MAXFLOAT.description).doubleValue)
|
||||
XCTAssertEqual(NSDecimalNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: MAXFLOAT.description))?.floatValue, NSDecimalNumber(string: MAXFLOAT.description).floatValue)
|
||||
|
||||
XCTAssertEqual(NSNumber.cs_fromNativeType(NSDecimalNumber(string: "1"))?.boolValue, true)
|
||||
XCTAssertEqual(NSNumber.cs_fromNativeType(NSDecimalNumber(string: Int16.max.description))?.int16Value, Int16.max)
|
||||
XCTAssertEqual(NSNumber.cs_fromNativeType(NSDecimalNumber(string: Int32.max.description))?.int32Value, Int32.max)
|
||||
XCTAssertEqual(NSNumber.cs_fromNativeType(NSDecimalNumber(string: Int64.max.description))?.int64Value, Int64.max)
|
||||
XCTAssertEqual(NSNumber.cs_fromNativeType(NSDecimalNumber(string: MAXFLOAT.description))?.doubleValue, NSDecimalNumber(string: MAXFLOAT.description).doubleValue)
|
||||
XCTAssertEqual(NSNumber.cs_fromNativeType(NSDecimalNumber(string: MAXFLOAT.description))?.floatValue, NSDecimalNumber(string: MAXFLOAT.description).floatValue)
|
||||
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: "1"))?.boolValue, true)
|
||||
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: Int16.max.description))?.int16Value, Int16.max)
|
||||
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: Int32.max.description))?.int32Value, Int32.max)
|
||||
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: Int64.max.description))?.int64Value, Int64.max)
|
||||
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: MAXFLOAT.description))?.doubleValue, NSDecimalNumber(string: MAXFLOAT.description).doubleValue)
|
||||
XCTAssertEqual(NSNumber.cs_fromUniqueIDNativeType(NSDecimalNumber(string: MAXFLOAT.description))?.floatValue, NSDecimalNumber(string: MAXFLOAT.description).floatValue)
|
||||
|
||||
XCTAssertNil(NSDecimalNumber.cs_fromNativeType(NSNumber(value: true)))
|
||||
XCTAssertNil(NSDecimalNumber.cs_fromNativeType(NSNumber(value: Int16.max)))
|
||||
XCTAssertNil(NSDecimalNumber.cs_fromNativeType(NSNumber(value: Int32.max)))
|
||||
XCTAssertNil(NSDecimalNumber.cs_fromNativeType(NSNumber(value: Int64.max)))
|
||||
XCTAssertNil(NSDecimalNumber.cs_fromNativeType(NSNumber(value: MAXFLOAT)))
|
||||
XCTAssertNil(NSDecimalNumber.cs_fromNativeType(NSNumber(value: Double(MAXFLOAT))))
|
||||
XCTAssertNil(NSDecimalNumber.cs_fromUniqueIDNativeType(NSNumber(value: true)))
|
||||
XCTAssertNil(NSDecimalNumber.cs_fromUniqueIDNativeType(NSNumber(value: Int16.max)))
|
||||
XCTAssertNil(NSDecimalNumber.cs_fromUniqueIDNativeType(NSNumber(value: Int32.max)))
|
||||
XCTAssertNil(NSDecimalNumber.cs_fromUniqueIDNativeType(NSNumber(value: Int64.max)))
|
||||
XCTAssertNil(NSDecimalNumber.cs_fromUniqueIDNativeType(NSNumber(value: MAXFLOAT)))
|
||||
XCTAssertNil(NSDecimalNumber.cs_fromUniqueIDNativeType(NSNumber(value: Double(MAXFLOAT))))
|
||||
|
||||
XCTAssertEqual(true.cs_toNativeType(), NSNumber(value: true))
|
||||
XCTAssertEqual(Int16.max.cs_toNativeType(), NSNumber(value: Int16.max))
|
||||
XCTAssertEqual(Int32.max.cs_toNativeType(), NSNumber(value: Int32.max))
|
||||
XCTAssertEqual(Int64.max.cs_toNativeType(), NSNumber(value: Int64.max))
|
||||
XCTAssertEqual(MAXFLOAT.cs_toNativeType(), NSNumber(value: MAXFLOAT))
|
||||
XCTAssertEqual(Double(MAXFLOAT).cs_toNativeType(), NSNumber(value: Double(MAXFLOAT)))
|
||||
XCTAssertEqual(true.cs_toUniqueIDNativeType(), NSNumber(value: true))
|
||||
XCTAssertEqual(Int16.max.cs_toUniqueIDNativeType(), NSNumber(value: Int16.max))
|
||||
XCTAssertEqual(Int32.max.cs_toUniqueIDNativeType(), NSNumber(value: Int32.max))
|
||||
XCTAssertEqual(Int64.max.cs_toUniqueIDNativeType(), NSNumber(value: Int64.max))
|
||||
XCTAssertEqual(MAXFLOAT.cs_toUniqueIDNativeType(), NSNumber(value: MAXFLOAT))
|
||||
XCTAssertEqual(Double(MAXFLOAT).cs_toUniqueIDNativeType(), NSNumber(value: Double(MAXFLOAT)))
|
||||
}
|
||||
|
||||
@objc
|
||||
|
||||
@@ -29,6 +29,25 @@ import XCTest
|
||||
import CoreStore
|
||||
|
||||
|
||||
// MARK: - XCTAssertAllEqual
|
||||
|
||||
private func XCTAssertAllEqual(_ whereClauses: Where...) {
|
||||
|
||||
XCTAssertAllEqual(whereClauses)
|
||||
}
|
||||
|
||||
private func XCTAssertAllEqual(_ whereClauses: [Where]) {
|
||||
|
||||
for i in whereClauses.indices {
|
||||
|
||||
for j in whereClauses.indices where j != i {
|
||||
|
||||
XCTAssertEqual(whereClauses[i], whereClauses[j])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//MARK: - WhereTests
|
||||
|
||||
final class WhereTests: XCTestCase {
|
||||
@@ -93,202 +112,114 @@ final class WhereTests: XCTestCase {
|
||||
do {
|
||||
|
||||
let value: Int = 100
|
||||
let whereClause1 = Where("%K == %d", "key", value)
|
||||
let whereClause2 = Where("%K == %d", "key", value as AnyObject)
|
||||
let whereClause3 = Where("%K == %d", "key", NSNumber(value: value))
|
||||
let whereClause4 = Where("%K == %@", "key", value)
|
||||
let whereClause5 = Where("%K == %@", "key", value as AnyObject)
|
||||
let whereClause6 = Where("%K == %@", "key", NSNumber(value: value))
|
||||
XCTAssertEqual(whereClause1, whereClause2)
|
||||
XCTAssertEqual(whereClause1, whereClause3)
|
||||
XCTAssertEqual(whereClause1, whereClause4)
|
||||
XCTAssertEqual(whereClause1, whereClause5)
|
||||
XCTAssertEqual(whereClause1, whereClause6)
|
||||
XCTAssertEqual(whereClause2, whereClause3)
|
||||
XCTAssertEqual(whereClause2, whereClause4)
|
||||
XCTAssertEqual(whereClause2, whereClause5)
|
||||
XCTAssertEqual(whereClause2, whereClause6)
|
||||
XCTAssertEqual(whereClause3, whereClause4)
|
||||
XCTAssertEqual(whereClause3, whereClause5)
|
||||
XCTAssertEqual(whereClause3, whereClause6)
|
||||
XCTAssertEqual(whereClause4, whereClause5)
|
||||
XCTAssertEqual(whereClause4, whereClause6)
|
||||
XCTAssertEqual(whereClause5, whereClause6)
|
||||
XCTAssertAllEqual(
|
||||
Where("%K == %d", "key", value),
|
||||
Where("%K == %d", "key", value as AnyObject),
|
||||
Where("%K == %d", "key", NSNumber(value: value)),
|
||||
Where("%K == %@", "key", value),
|
||||
Where("%K == %@", "key", value as AnyObject),
|
||||
Where("%K == %@", "key", NSNumber(value: value)),
|
||||
Where("key", isEqualTo: value),
|
||||
Where("key", isEqualTo: NSNumber(value: value))
|
||||
)
|
||||
}
|
||||
do {
|
||||
|
||||
let value = NSNumber(value: 100)
|
||||
let whereClause1 = Where("%K == %d", "key", value)
|
||||
let whereClause2 = Where("%K == %d", "key", value as AnyObject)
|
||||
let whereClause3 = Where("%K == %d", "key", value.intValue)
|
||||
let whereClause4 = Where("%K == %@", "key", value)
|
||||
let whereClause5 = Where("%K == %@", "key", value as AnyObject)
|
||||
let whereClause6 = Where("%K == %@", "key", value.intValue)
|
||||
XCTAssertEqual(whereClause1, whereClause2)
|
||||
XCTAssertEqual(whereClause1, whereClause3)
|
||||
XCTAssertEqual(whereClause1, whereClause4)
|
||||
XCTAssertEqual(whereClause1, whereClause5)
|
||||
XCTAssertEqual(whereClause1, whereClause6)
|
||||
XCTAssertEqual(whereClause2, whereClause3)
|
||||
XCTAssertEqual(whereClause2, whereClause4)
|
||||
XCTAssertEqual(whereClause2, whereClause5)
|
||||
XCTAssertEqual(whereClause2, whereClause6)
|
||||
XCTAssertEqual(whereClause3, whereClause4)
|
||||
XCTAssertEqual(whereClause3, whereClause5)
|
||||
XCTAssertEqual(whereClause3, whereClause6)
|
||||
XCTAssertEqual(whereClause4, whereClause5)
|
||||
XCTAssertEqual(whereClause4, whereClause6)
|
||||
XCTAssertEqual(whereClause5, whereClause6)
|
||||
XCTAssertAllEqual(
|
||||
Where("%K == %d", "key", value),
|
||||
Where("%K == %d", "key", value as AnyObject),
|
||||
Where("%K == %d", "key", value.intValue),
|
||||
Where("%K == %@", "key", value),
|
||||
Where("%K == %@", "key", value as AnyObject),
|
||||
Where("%K == %@", "key", value.intValue),
|
||||
Where("key", isEqualTo: value),
|
||||
Where("key", isEqualTo: value.intValue)
|
||||
)
|
||||
}
|
||||
do {
|
||||
|
||||
let value: Int64 = Int64.max
|
||||
let whereClause1 = Where("%K == %d", "key", value)
|
||||
let whereClause2 = Where("%K == %d", "key", value as AnyObject)
|
||||
let whereClause3 = Where("%K == %d", "key", NSNumber(value: value))
|
||||
let whereClause4 = Where("%K == %@", "key", value)
|
||||
let whereClause5 = Where("%K == %@", "key", value as AnyObject)
|
||||
let whereClause6 = Where("%K == %@", "key", NSNumber(value: value))
|
||||
XCTAssertEqual(whereClause1, whereClause2)
|
||||
XCTAssertEqual(whereClause1, whereClause3)
|
||||
XCTAssertEqual(whereClause1, whereClause4)
|
||||
XCTAssertEqual(whereClause1, whereClause5)
|
||||
XCTAssertEqual(whereClause1, whereClause6)
|
||||
XCTAssertEqual(whereClause2, whereClause3)
|
||||
XCTAssertEqual(whereClause2, whereClause4)
|
||||
XCTAssertEqual(whereClause2, whereClause5)
|
||||
XCTAssertEqual(whereClause2, whereClause6)
|
||||
XCTAssertEqual(whereClause3, whereClause4)
|
||||
XCTAssertEqual(whereClause3, whereClause5)
|
||||
XCTAssertEqual(whereClause3, whereClause6)
|
||||
XCTAssertEqual(whereClause4, whereClause5)
|
||||
XCTAssertEqual(whereClause4, whereClause6)
|
||||
XCTAssertEqual(whereClause5, whereClause6)
|
||||
XCTAssertAllEqual(
|
||||
Where("%K == %d", "key", value),
|
||||
Where("%K == %d", "key", value as AnyObject),
|
||||
Where("%K == %d", "key", NSNumber(value: value)),
|
||||
Where("%K == %@", "key", value),
|
||||
Where("%K == %@", "key", value as AnyObject),
|
||||
Where("%K == %@", "key", NSNumber(value: value)),
|
||||
Where("key", isEqualTo: value),
|
||||
Where("key", isEqualTo: NSNumber(value: value))
|
||||
)
|
||||
}
|
||||
do {
|
||||
|
||||
let value = NSNumber(value: Int64.max)
|
||||
let whereClause1 = Where("%K == %d", "key", value)
|
||||
let whereClause2 = Where("%K == %d", "key", value as AnyObject)
|
||||
let whereClause3 = Where("%K == %d", "key", value.int64Value)
|
||||
let whereClause4 = Where("%K == %@", "key", value)
|
||||
let whereClause5 = Where("%K == %@", "key", value as AnyObject)
|
||||
let whereClause6 = Where("%K == %@", "key", value.int64Value)
|
||||
XCTAssertEqual(whereClause1, whereClause2)
|
||||
XCTAssertEqual(whereClause1, whereClause3)
|
||||
XCTAssertEqual(whereClause1, whereClause4)
|
||||
XCTAssertEqual(whereClause1, whereClause5)
|
||||
XCTAssertEqual(whereClause1, whereClause6)
|
||||
XCTAssertEqual(whereClause2, whereClause3)
|
||||
XCTAssertEqual(whereClause2, whereClause4)
|
||||
XCTAssertEqual(whereClause2, whereClause5)
|
||||
XCTAssertEqual(whereClause2, whereClause6)
|
||||
XCTAssertEqual(whereClause3, whereClause4)
|
||||
XCTAssertEqual(whereClause3, whereClause5)
|
||||
XCTAssertEqual(whereClause3, whereClause6)
|
||||
XCTAssertEqual(whereClause4, whereClause5)
|
||||
XCTAssertEqual(whereClause4, whereClause6)
|
||||
XCTAssertEqual(whereClause5, whereClause6)
|
||||
XCTAssertAllEqual(
|
||||
Where("%K == %d", "key", value),
|
||||
Where("%K == %d", "key", value as AnyObject),
|
||||
Where("%K == %d", "key", value.int64Value),
|
||||
Where("%K == %@", "key", value),
|
||||
Where("%K == %@", "key", value as AnyObject),
|
||||
Where("%K == %@", "key", value.int64Value),
|
||||
Where("key", isEqualTo: value),
|
||||
Where("key", isEqualTo: value.int64Value)
|
||||
)
|
||||
}
|
||||
do {
|
||||
|
||||
let value: String = "value"
|
||||
let whereClause1 = Where("%K == %s", "key", value)
|
||||
let whereClause2 = Where("%K == %s", "key", value as AnyObject)
|
||||
let whereClause3 = Where("%K == %s", "key", NSString(string: value))
|
||||
let whereClause4 = Where("%K == %@", "key", value)
|
||||
let whereClause5 = Where("%K == %@", "key", value as AnyObject)
|
||||
let whereClause6 = Where("%K == %@", "key", NSString(string: value))
|
||||
XCTAssertEqual(whereClause1, whereClause2)
|
||||
XCTAssertEqual(whereClause1, whereClause3)
|
||||
XCTAssertEqual(whereClause1, whereClause4)
|
||||
XCTAssertEqual(whereClause1, whereClause5)
|
||||
XCTAssertEqual(whereClause1, whereClause6)
|
||||
XCTAssertEqual(whereClause2, whereClause3)
|
||||
XCTAssertEqual(whereClause2, whereClause4)
|
||||
XCTAssertEqual(whereClause2, whereClause5)
|
||||
XCTAssertEqual(whereClause2, whereClause6)
|
||||
XCTAssertEqual(whereClause3, whereClause4)
|
||||
XCTAssertEqual(whereClause3, whereClause5)
|
||||
XCTAssertEqual(whereClause3, whereClause6)
|
||||
XCTAssertEqual(whereClause4, whereClause5)
|
||||
XCTAssertEqual(whereClause4, whereClause6)
|
||||
XCTAssertEqual(whereClause5, whereClause6)
|
||||
XCTAssertAllEqual(
|
||||
Where("%K == %s", "key", value),
|
||||
Where("%K == %s", "key", value as AnyObject),
|
||||
Where("%K == %s", "key", NSString(string: value)),
|
||||
Where("%K == %@", "key", value),
|
||||
Where("%K == %@", "key", value as AnyObject),
|
||||
Where("%K == %@", "key", NSString(string: value)),
|
||||
Where("key", isEqualTo: value),
|
||||
Where("key", isEqualTo: value as NSString),
|
||||
Where("key", isEqualTo: NSString(string: value))
|
||||
)
|
||||
}
|
||||
do {
|
||||
|
||||
let value = NSString(string: "value")
|
||||
let whereClause1 = Where("%K == %s", "key", value)
|
||||
let whereClause2 = Where("%K == %s", "key", value as String)
|
||||
let whereClause3 = Where("%K == %s", "key", value as String as AnyObject)
|
||||
let whereClause4 = Where("%K == %@", "key", value)
|
||||
let whereClause5 = Where("%K == %@", "key", value as String)
|
||||
let whereClause6 = Where("%K == %@", "key", value as String as AnyObject)
|
||||
XCTAssertEqual(whereClause1, whereClause2)
|
||||
XCTAssertEqual(whereClause1, whereClause3)
|
||||
XCTAssertEqual(whereClause1, whereClause4)
|
||||
XCTAssertEqual(whereClause1, whereClause5)
|
||||
XCTAssertEqual(whereClause1, whereClause6)
|
||||
XCTAssertEqual(whereClause2, whereClause3)
|
||||
XCTAssertEqual(whereClause2, whereClause4)
|
||||
XCTAssertEqual(whereClause2, whereClause5)
|
||||
XCTAssertEqual(whereClause2, whereClause6)
|
||||
XCTAssertEqual(whereClause3, whereClause4)
|
||||
XCTAssertEqual(whereClause3, whereClause5)
|
||||
XCTAssertEqual(whereClause3, whereClause6)
|
||||
XCTAssertEqual(whereClause4, whereClause5)
|
||||
XCTAssertEqual(whereClause4, whereClause6)
|
||||
XCTAssertEqual(whereClause5, whereClause6)
|
||||
XCTAssertAllEqual(
|
||||
Where("%K == %s", "key", value),
|
||||
Where("%K == %s", "key", value as String),
|
||||
Where("%K == %s", "key", value as String as AnyObject),
|
||||
Where("%K == %@", "key", value),
|
||||
Where("%K == %@", "key", value as String),
|
||||
Where("%K == %@", "key", value as String as AnyObject),
|
||||
Where("key", isEqualTo: value),
|
||||
Where("key", isEqualTo: value as String),
|
||||
Where("key", isEqualTo: value as String as NSString)
|
||||
)
|
||||
}
|
||||
do {
|
||||
|
||||
let value: [Int] = [100, 200]
|
||||
let whereClause1 = Where("%K == %@", "key", value)
|
||||
let whereClause2 = Where("%K == %@", "key", value as AnyObject)
|
||||
let whereClause3 = Where("%K == %@", "key", value as [AnyObject])
|
||||
let whereClause4 = Where("%K == %@", "key", value as NSArray)
|
||||
let whereClause5 = Where("%K == %@", "key", NSArray(array: value))
|
||||
let whereClause6 = Where("%K == %@", "key", value as AnyObject as! NSArray)
|
||||
XCTAssertEqual(whereClause1, whereClause2)
|
||||
XCTAssertEqual(whereClause1, whereClause3)
|
||||
XCTAssertEqual(whereClause1, whereClause4)
|
||||
XCTAssertEqual(whereClause1, whereClause5)
|
||||
XCTAssertEqual(whereClause1, whereClause6)
|
||||
XCTAssertEqual(whereClause2, whereClause3)
|
||||
XCTAssertEqual(whereClause2, whereClause4)
|
||||
XCTAssertEqual(whereClause2, whereClause5)
|
||||
XCTAssertEqual(whereClause2, whereClause6)
|
||||
XCTAssertEqual(whereClause3, whereClause4)
|
||||
XCTAssertEqual(whereClause3, whereClause5)
|
||||
XCTAssertEqual(whereClause3, whereClause6)
|
||||
XCTAssertEqual(whereClause4, whereClause5)
|
||||
XCTAssertEqual(whereClause4, whereClause6)
|
||||
XCTAssertEqual(whereClause5, whereClause6)
|
||||
XCTAssertAllEqual(
|
||||
Where("%K IN %@", "key", value),
|
||||
Where("%K IN %@", "key", value as AnyObject),
|
||||
Where("%K IN %@", "key", value as [AnyObject]),
|
||||
Where("%K IN %@", "key", value as NSArray),
|
||||
Where("%K IN %@", "key", NSArray(array: value)),
|
||||
Where("%K IN %@", "key", value as AnyObject as! NSArray),
|
||||
Where("key", isMemberOf: value)
|
||||
)
|
||||
}
|
||||
do {
|
||||
|
||||
let value: [Int64] = [Int64.min, 100, Int64.max]
|
||||
let whereClause1 = Where("%K == %@", "key", value)
|
||||
let whereClause2 = Where("%K == %@", "key", value as AnyObject)
|
||||
let whereClause3 = Where("%K == %@", "key", value as [AnyObject])
|
||||
let whereClause4 = Where("%K == %@", "key", value as NSArray)
|
||||
let whereClause5 = Where("%K == %@", "key", NSArray(array: value))
|
||||
let whereClause6 = Where("%K == %@", "key", value as AnyObject as! NSArray)
|
||||
XCTAssertEqual(whereClause1, whereClause2)
|
||||
XCTAssertEqual(whereClause1, whereClause3)
|
||||
XCTAssertEqual(whereClause1, whereClause4)
|
||||
XCTAssertEqual(whereClause1, whereClause5)
|
||||
XCTAssertEqual(whereClause1, whereClause6)
|
||||
XCTAssertEqual(whereClause2, whereClause3)
|
||||
XCTAssertEqual(whereClause2, whereClause4)
|
||||
XCTAssertEqual(whereClause2, whereClause5)
|
||||
XCTAssertEqual(whereClause2, whereClause6)
|
||||
XCTAssertEqual(whereClause3, whereClause4)
|
||||
XCTAssertEqual(whereClause3, whereClause5)
|
||||
XCTAssertEqual(whereClause3, whereClause6)
|
||||
XCTAssertEqual(whereClause4, whereClause5)
|
||||
XCTAssertEqual(whereClause4, whereClause6)
|
||||
XCTAssertEqual(whereClause5, whereClause6)
|
||||
XCTAssertAllEqual(
|
||||
Where("%K IN %@", "key", value),
|
||||
Where("%K IN %@", "key", value as AnyObject),
|
||||
Where("%K IN %@", "key", value as [AnyObject]),
|
||||
Where("%K IN %@", "key", value as NSArray),
|
||||
Where("%K IN %@", "key", NSArray(array: value)),
|
||||
Where("%K IN %@", "key", value as AnyObject as! NSArray),
|
||||
Where("key", isMemberOf: value)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,3 +70,8 @@ extension NSManagedObject: CoreDataNativeType {}
|
||||
// MARK: - NSManagedObjectID
|
||||
|
||||
extension NSManagedObjectID: CoreDataNativeType {}
|
||||
|
||||
|
||||
// MARK: - NSNull
|
||||
|
||||
extension NSNull: CoreDataNativeType {}
|
||||
@@ -101,46 +101,17 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
|
||||
- parameter keyPath: the keyPath to compare with
|
||||
- parameter value: the arguments for the `==` operator
|
||||
*/
|
||||
public init(_ keyPath: KeyPath, isEqualTo value: CoreDataNativeType?) {
|
||||
public init<T: CoreStoreQueryingAttributeType>(_ keyPath: KeyPath, isEqualTo value: T?) {
|
||||
|
||||
self.init(value == nil
|
||||
? NSPredicate(format: "\(keyPath) == nil")
|
||||
: NSPredicate(format: "\(keyPath) == %@", argumentArray: [value!]))
|
||||
}
|
||||
|
||||
/**
|
||||
Initializes a `Where` clause that compares equality
|
||||
|
||||
- parameter keyPath: the keyPath to compare with
|
||||
- parameter value: the arguments for the `==` operator
|
||||
*/
|
||||
public init<T: CoreStoreSupportedAttributeType>(_ keyPath: KeyPath, isEqualTo value: T?) {
|
||||
|
||||
self.init(value == nil
|
||||
? NSPredicate(format: "\(keyPath) == nil")
|
||||
: NSPredicate(format: "\(keyPath) == %@", argumentArray: [value!.cs_toNativeType()]))
|
||||
}
|
||||
|
||||
/**
|
||||
Initializes a `Where` clause that compares membership
|
||||
|
||||
- parameter keyPath: the keyPath to compare with
|
||||
- parameter list: the array to check membership of
|
||||
*/
|
||||
public init(_ keyPath: KeyPath, isMemberOf list: [CoreDataNativeType]) {
|
||||
|
||||
self.init(NSPredicate(format: "\(keyPath) IN %@", list))
|
||||
}
|
||||
|
||||
/**
|
||||
Initializes a `Where` clause that compares membership
|
||||
|
||||
- parameter keyPath: the keyPath to compare with
|
||||
- parameter list: the array to check membership of
|
||||
*/
|
||||
public init<T: CoreStoreSupportedAttributeType>(_ keyPath: KeyPath, isMemberOf list: [T]) {
|
||||
|
||||
self.init(NSPredicate(format: "\(keyPath) IN %@", list))
|
||||
switch value {
|
||||
|
||||
case nil,
|
||||
is NSNull:
|
||||
self.init(NSPredicate(format: "\(keyPath) == nil"))
|
||||
|
||||
case let value?:
|
||||
self.init(NSPredicate(format: "\(keyPath) == %@", argumentArray: [value.cs_toQueryingNativeType()]))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,9 +120,9 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
|
||||
- parameter keyPath: the keyPath to compare with
|
||||
- parameter list: the sequence to check membership of
|
||||
*/
|
||||
public init<S: Sequence>(_ keyPath: KeyPath, isMemberOf list: S) where S.Iterator.Element: CoreStoreSupportedAttributeType {
|
||||
public init<S: Sequence>(_ keyPath: KeyPath, isMemberOf list: S) where S.Iterator.Element: CoreStoreQueryingAttributeType {
|
||||
|
||||
self.init(NSPredicate(format: "\(keyPath) IN %@", Array(list) as NSArray))
|
||||
self.init(NSPredicate(format: "\(keyPath) IN %@", list.map({ $0.cs_toQueryingNativeType() }) as NSArray))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,272 @@
|
||||
//
|
||||
// CoreStoreQueryingAttributeType.swift
|
||||
// CoreStore
|
||||
//
|
||||
// Copyright © 2017 John Rommel Estropia
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreGraphics
|
||||
import CoreData
|
||||
|
||||
|
||||
// MARK: - CoreStoreQueryingAttributeType
|
||||
|
||||
public protocol CoreStoreQueryingAttributeType: Hashable {
|
||||
|
||||
associatedtype NativeTypeForQuerying: CoreDataNativeType
|
||||
|
||||
func cs_toQueryingNativeType() -> NativeTypeForQuerying
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSManagedObject
|
||||
|
||||
extension NSManagedObject: CoreStoreQueryingAttributeType {
|
||||
|
||||
public typealias NativeTypeForQuerying = NSManagedObjectID
|
||||
|
||||
public func cs_toQueryingNativeType() -> NativeTypeForQuerying {
|
||||
|
||||
return self.objectID
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSManagedObjectID
|
||||
|
||||
extension NSManagedObjectID: CoreStoreQueryingAttributeType {
|
||||
|
||||
public typealias NativeTypeForQuerying = NSManagedObjectID
|
||||
|
||||
public func cs_toQueryingNativeType() -> NativeTypeForQuerying {
|
||||
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSNumber
|
||||
|
||||
extension NSNumber: CoreStoreQueryingAttributeType {
|
||||
|
||||
public typealias NativeTypeForQuerying = NSNumber
|
||||
|
||||
public func cs_toQueryingNativeType() -> NativeTypeForQuerying {
|
||||
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSString
|
||||
|
||||
extension NSString: CoreStoreQueryingAttributeType {
|
||||
|
||||
public typealias NativeTypeForQuerying = NSString
|
||||
|
||||
public func cs_toQueryingNativeType() -> NativeTypeForQuerying {
|
||||
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSDate
|
||||
|
||||
extension NSDate: CoreStoreQueryingAttributeType {
|
||||
|
||||
public typealias NativeTypeForQuerying = NSDate
|
||||
|
||||
public func cs_toQueryingNativeType() -> NativeTypeForQuerying {
|
||||
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSData
|
||||
|
||||
extension NSData: CoreStoreQueryingAttributeType {
|
||||
|
||||
public typealias NativeTypeForQuerying = NSData
|
||||
|
||||
public func cs_toQueryingNativeType() -> NativeTypeForQuerying {
|
||||
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Bool
|
||||
|
||||
extension Bool: CoreStoreQueryingAttributeType {
|
||||
|
||||
public typealias NativeTypeForQuerying = NSNumber
|
||||
|
||||
public func cs_toQueryingNativeType() -> NativeTypeForQuerying {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Int16
|
||||
|
||||
extension Int16: CoreStoreQueryingAttributeType {
|
||||
|
||||
public typealias NativeTypeForQuerying = NSNumber
|
||||
|
||||
public func cs_toQueryingNativeType() -> NativeTypeForQuerying {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Int32
|
||||
|
||||
extension Int32: CoreStoreQueryingAttributeType {
|
||||
|
||||
public typealias NativeTypeForQuerying = NSNumber
|
||||
|
||||
public func cs_toQueryingNativeType() -> NativeTypeForQuerying {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Int64
|
||||
|
||||
extension Int64: CoreStoreQueryingAttributeType {
|
||||
|
||||
public typealias NativeTypeForQuerying = NSNumber
|
||||
|
||||
public func cs_toQueryingNativeType() -> NativeTypeForQuerying {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Int
|
||||
|
||||
extension Int: CoreStoreQueryingAttributeType {
|
||||
|
||||
public typealias NativeTypeForQuerying = NSNumber
|
||||
|
||||
public func cs_toQueryingNativeType() -> NativeTypeForQuerying {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Double
|
||||
|
||||
extension Double: CoreStoreQueryingAttributeType {
|
||||
|
||||
public typealias NativeTypeForQuerying = NSNumber
|
||||
|
||||
public func cs_toQueryingNativeType() -> NativeTypeForQuerying {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Float
|
||||
|
||||
extension Float: CoreStoreQueryingAttributeType {
|
||||
|
||||
public typealias NativeTypeForQuerying = NSNumber
|
||||
|
||||
public func cs_toQueryingNativeType() -> NativeTypeForQuerying {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - CGFloat
|
||||
|
||||
extension CGFloat: CoreStoreQueryingAttributeType {
|
||||
|
||||
public typealias NativeTypeForQuerying = NSNumber
|
||||
|
||||
public func cs_toQueryingNativeType() -> NativeTypeForQuerying {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Date
|
||||
|
||||
extension Date: CoreStoreQueryingAttributeType {
|
||||
|
||||
public typealias NativeTypeForQuerying = NSDate
|
||||
|
||||
public func cs_toQueryingNativeType() -> NativeTypeForQuerying {
|
||||
|
||||
return self as NSDate
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - String
|
||||
|
||||
extension String: CoreStoreQueryingAttributeType {
|
||||
|
||||
public typealias NativeTypeForQuerying = NSString
|
||||
|
||||
public func cs_toQueryingNativeType() -> NativeTypeForQuerying {
|
||||
|
||||
return self as NSString
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Data
|
||||
|
||||
extension Data: CoreStoreQueryingAttributeType {
|
||||
|
||||
public typealias NativeTypeForQuerying = NSData
|
||||
|
||||
public func cs_toQueryingNativeType() -> NativeTypeForQuerying {
|
||||
|
||||
return self as NSData
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSNull
|
||||
|
||||
extension NSNull: CoreStoreQueryingAttributeType {
|
||||
|
||||
public typealias NativeTypeForQuerying = NSNull
|
||||
|
||||
public func cs_toQueryingNativeType() -> NativeTypeForQuerying {
|
||||
|
||||
return self
|
||||
}
|
||||
}
|
||||
@@ -1,372 +0,0 @@
|
||||
//
|
||||
// CoreStoreSupportedAttributeType.swift
|
||||
// CoreStore
|
||||
//
|
||||
// Copyright © 2017 John Rommel Estropia
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
|
||||
// MARK: - CoreStoreSupportedAttributeType
|
||||
|
||||
public protocol CoreStoreSupportedAttributeType: Hashable {
|
||||
|
||||
associatedtype CoreStoreNativeType: CoreDataNativeType
|
||||
|
||||
static func cs_fromNativeType(_ value: CoreStoreNativeType) -> Self?
|
||||
func cs_toNativeType() -> CoreStoreNativeType
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSManagedObject
|
||||
|
||||
extension NSManagedObject: CoreStoreSupportedAttributeType {
|
||||
|
||||
public typealias CoreStoreNativeType = NSManagedObject
|
||||
|
||||
public class func cs_fromNativeType(_ value: CoreStoreNativeType) -> Self? {
|
||||
|
||||
func forceCast<T: NSManagedObject>(_ value: Any) -> T? {
|
||||
|
||||
return value as? T
|
||||
}
|
||||
return forceCast(value)
|
||||
}
|
||||
|
||||
public func cs_toNativeType() -> CoreStoreNativeType {
|
||||
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSNumber
|
||||
|
||||
extension NSNumber: CoreStoreSupportedAttributeType {
|
||||
|
||||
public typealias CoreStoreNativeType = NSNumber
|
||||
|
||||
public class func cs_fromNativeType(_ value: CoreStoreNativeType) -> Self? {
|
||||
|
||||
func forceCast<T: NSNumber>(_ value: Any) -> T? {
|
||||
|
||||
return value as? T
|
||||
}
|
||||
return forceCast(value)
|
||||
}
|
||||
|
||||
public func cs_toNativeType() -> CoreStoreNativeType {
|
||||
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSString
|
||||
|
||||
extension NSString: CoreStoreSupportedAttributeType {
|
||||
|
||||
public typealias CoreStoreNativeType = NSString
|
||||
|
||||
public class func cs_fromNativeType(_ value: CoreStoreNativeType) -> Self? {
|
||||
|
||||
func forceCast<T: NSString>(_ value: Any) -> T? {
|
||||
|
||||
return value as? T
|
||||
}
|
||||
return forceCast(value)
|
||||
}
|
||||
|
||||
public func cs_toNativeType() -> CoreStoreNativeType {
|
||||
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSDate
|
||||
|
||||
extension NSDate: CoreStoreSupportedAttributeType {
|
||||
|
||||
public typealias CoreStoreNativeType = NSDate
|
||||
|
||||
public class func cs_fromNativeType(_ value: CoreStoreNativeType) -> Self? {
|
||||
|
||||
func forceCast<T: NSDate>(_ value: Any) -> T? {
|
||||
|
||||
return value as? T
|
||||
}
|
||||
return forceCast(value)
|
||||
}
|
||||
|
||||
public func cs_toNativeType() -> CoreStoreNativeType {
|
||||
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSData
|
||||
|
||||
extension NSData: CoreStoreSupportedAttributeType {
|
||||
|
||||
public typealias CoreStoreNativeType = NSData
|
||||
|
||||
public class func cs_fromNativeType(_ value: CoreStoreNativeType) -> Self? {
|
||||
|
||||
func forceCast<T: NSData>(_ value: Any) -> T? {
|
||||
|
||||
return value as? T
|
||||
}
|
||||
return forceCast(value)
|
||||
}
|
||||
|
||||
public func cs_toNativeType() -> CoreStoreNativeType {
|
||||
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSSet
|
||||
|
||||
extension NSSet: CoreStoreSupportedAttributeType {
|
||||
|
||||
public typealias CoreStoreNativeType = NSSet
|
||||
|
||||
public class func cs_fromNativeType(_ value: CoreStoreNativeType) -> Self? {
|
||||
|
||||
func forceCast<T: NSSet>(_ value: Any) -> T? {
|
||||
|
||||
return value as? T
|
||||
}
|
||||
return forceCast(value)
|
||||
}
|
||||
|
||||
public func cs_toNativeType() -> CoreStoreNativeType {
|
||||
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSOrderedSet
|
||||
|
||||
extension NSOrderedSet: CoreStoreSupportedAttributeType {
|
||||
|
||||
public typealias CoreStoreNativeType = NSOrderedSet
|
||||
|
||||
public class func cs_fromNativeType(_ value: CoreStoreNativeType) -> Self? {
|
||||
|
||||
func forceCast<T: NSOrderedSet>(_ value: Any) -> T? {
|
||||
|
||||
return value as? T
|
||||
}
|
||||
return forceCast(value)
|
||||
}
|
||||
|
||||
public func cs_toNativeType() -> CoreStoreNativeType {
|
||||
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Bool
|
||||
|
||||
extension Bool: CoreStoreSupportedAttributeType {
|
||||
|
||||
public typealias CoreStoreNativeType = NSNumber
|
||||
|
||||
public static func cs_fromNativeType(_ value: CoreStoreNativeType) -> Bool? {
|
||||
|
||||
return value.boolValue
|
||||
}
|
||||
|
||||
public func cs_toNativeType() -> CoreStoreNativeType {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Int16
|
||||
|
||||
extension Int16: CoreStoreSupportedAttributeType {
|
||||
|
||||
public typealias CoreStoreNativeType = NSNumber
|
||||
|
||||
public static func cs_fromNativeType(_ value: CoreStoreNativeType) -> Int16? {
|
||||
|
||||
return value.int16Value
|
||||
}
|
||||
|
||||
public func cs_toNativeType() -> CoreStoreNativeType {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Int32
|
||||
|
||||
extension Int32: CoreStoreSupportedAttributeType {
|
||||
|
||||
public typealias CoreStoreNativeType = NSNumber
|
||||
|
||||
public static func cs_fromNativeType(_ value: CoreStoreNativeType) -> Int32? {
|
||||
|
||||
return value.int32Value
|
||||
}
|
||||
|
||||
public func cs_toNativeType() -> CoreStoreNativeType {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Int64
|
||||
|
||||
extension Int64: CoreStoreSupportedAttributeType {
|
||||
|
||||
public typealias CoreStoreNativeType = NSNumber
|
||||
|
||||
public static func cs_fromNativeType(_ value: CoreStoreNativeType) -> Int64? {
|
||||
|
||||
return value.int64Value
|
||||
}
|
||||
|
||||
public func cs_toNativeType() -> CoreStoreNativeType {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Double
|
||||
|
||||
extension Double: CoreStoreSupportedAttributeType {
|
||||
|
||||
public typealias CoreStoreNativeType = NSNumber
|
||||
|
||||
public static func cs_fromNativeType(_ value: CoreStoreNativeType) -> Double? {
|
||||
|
||||
return value.doubleValue
|
||||
}
|
||||
|
||||
public func cs_toNativeType() -> CoreStoreNativeType {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Float
|
||||
|
||||
extension Float: CoreStoreSupportedAttributeType {
|
||||
|
||||
public typealias CoreStoreNativeType = NSNumber
|
||||
|
||||
public static func cs_fromNativeType(_ value: CoreStoreNativeType) -> Float? {
|
||||
|
||||
return value.floatValue
|
||||
}
|
||||
|
||||
public func cs_toNativeType() -> CoreStoreNativeType {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Date
|
||||
|
||||
extension Date: CoreStoreSupportedAttributeType {
|
||||
|
||||
public typealias CoreStoreNativeType = NSDate
|
||||
|
||||
public static func cs_fromNativeType(_ value: CoreStoreNativeType) -> Date? {
|
||||
|
||||
return value as Date
|
||||
}
|
||||
|
||||
public func cs_toNativeType() -> CoreStoreNativeType {
|
||||
|
||||
return self as NSDate
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - String
|
||||
|
||||
extension String: CoreStoreSupportedAttributeType {
|
||||
|
||||
public typealias CoreStoreNativeType = NSString
|
||||
|
||||
public static func cs_fromNativeType(_ value: CoreStoreNativeType) -> String? {
|
||||
|
||||
return value as String
|
||||
}
|
||||
|
||||
public func cs_toNativeType() -> CoreStoreNativeType {
|
||||
|
||||
return self as NSString
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Data
|
||||
|
||||
extension Data: CoreStoreSupportedAttributeType {
|
||||
|
||||
public typealias CoreStoreNativeType = NSData
|
||||
|
||||
public static func cs_fromNativeType(_ value: CoreStoreNativeType) -> Data? {
|
||||
|
||||
return value as Data
|
||||
}
|
||||
|
||||
public func cs_toNativeType() -> CoreStoreNativeType {
|
||||
|
||||
return self as NSData
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Set
|
||||
|
||||
extension Set: CoreStoreSupportedAttributeType {
|
||||
|
||||
public typealias CoreStoreNativeType = NSSet
|
||||
|
||||
public static func cs_fromNativeType(_ value: CoreStoreNativeType) -> Set? {
|
||||
|
||||
return value as? Set
|
||||
}
|
||||
|
||||
public func cs_toNativeType() -> CoreStoreNativeType {
|
||||
|
||||
return self as NSSet
|
||||
}
|
||||
}
|
||||
288
Sources/Importing/CoreStoreUniqueIDAttributeType.swift
Normal file
288
Sources/Importing/CoreStoreUniqueIDAttributeType.swift
Normal file
@@ -0,0 +1,288 @@
|
||||
//
|
||||
// CoreStoreUniqueIDAttributeType.swift
|
||||
// CoreStore
|
||||
//
|
||||
// Copyright © 2017 John Rommel Estropia
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
|
||||
// MARK: - CoreStoreUniqueIDAttributeType
|
||||
|
||||
public protocol CoreStoreUniqueIDAttributeType: CoreStoreQueryingAttributeType {
|
||||
|
||||
associatedtype NativeTypeForUniqueID: CoreDataNativeType
|
||||
|
||||
static func cs_fromUniqueIDNativeType(_ value: NativeTypeForUniqueID) -> Self?
|
||||
func cs_toUniqueIDNativeType() -> NativeTypeForUniqueID
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSNumber
|
||||
|
||||
extension NSNumber: CoreStoreUniqueIDAttributeType {
|
||||
|
||||
public typealias NativeTypeForUniqueID = NSNumber
|
||||
|
||||
public class func cs_fromUniqueIDNativeType(_ value: NativeTypeForUniqueID) -> Self? {
|
||||
|
||||
func forceCast<T: NSNumber>(_ value: Any) -> T? {
|
||||
|
||||
return value as? T
|
||||
}
|
||||
return forceCast(value)
|
||||
}
|
||||
|
||||
public func cs_toUniqueIDNativeType() -> NativeTypeForUniqueID {
|
||||
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSString
|
||||
|
||||
extension NSString: CoreStoreUniqueIDAttributeType {
|
||||
|
||||
public typealias NativeTypeForUniqueID = NSString
|
||||
|
||||
public class func cs_fromUniqueIDNativeType(_ value: NativeTypeForUniqueID) -> Self? {
|
||||
|
||||
func forceCast<T: NSString>(_ value: Any) -> T? {
|
||||
|
||||
return value as? T
|
||||
}
|
||||
return forceCast(value)
|
||||
}
|
||||
|
||||
public func cs_toUniqueIDNativeType() -> NativeTypeForUniqueID {
|
||||
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSDate
|
||||
|
||||
extension NSDate: CoreStoreUniqueIDAttributeType {
|
||||
|
||||
public typealias NativeTypeForUniqueID = NSDate
|
||||
|
||||
public class func cs_fromUniqueIDNativeType(_ value: NativeTypeForUniqueID) -> Self? {
|
||||
|
||||
func forceCast<T: NSDate>(_ value: Any) -> T? {
|
||||
|
||||
return value as? T
|
||||
}
|
||||
return forceCast(value)
|
||||
}
|
||||
|
||||
public func cs_toUniqueIDNativeType() -> NativeTypeForUniqueID {
|
||||
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSData
|
||||
|
||||
extension NSData: CoreStoreUniqueIDAttributeType {
|
||||
|
||||
public typealias NativeTypeForUniqueID = NSData
|
||||
|
||||
public class func cs_fromUniqueIDNativeType(_ value: NativeTypeForUniqueID) -> Self? {
|
||||
|
||||
func forceCast<T: NSData>(_ value: Any) -> T? {
|
||||
|
||||
return value as? T
|
||||
}
|
||||
return forceCast(value)
|
||||
}
|
||||
|
||||
public func cs_toUniqueIDNativeType() -> NativeTypeForUniqueID {
|
||||
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Bool
|
||||
|
||||
extension Bool: CoreStoreUniqueIDAttributeType {
|
||||
|
||||
public typealias NativeTypeForUniqueID = NSNumber
|
||||
|
||||
public static func cs_fromUniqueIDNativeType(_ value: NativeTypeForUniqueID) -> Bool? {
|
||||
|
||||
return value.boolValue
|
||||
}
|
||||
|
||||
public func cs_toUniqueIDNativeType() -> NativeTypeForUniqueID {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Int16
|
||||
|
||||
extension Int16: CoreStoreUniqueIDAttributeType {
|
||||
|
||||
public typealias NativeTypeForUniqueID = NSNumber
|
||||
|
||||
public static func cs_fromUniqueIDNativeType(_ value: NativeTypeForUniqueID) -> Int16? {
|
||||
|
||||
return value.int16Value
|
||||
}
|
||||
|
||||
public func cs_toUniqueIDNativeType() -> NativeTypeForUniqueID {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Int32
|
||||
|
||||
extension Int32: CoreStoreUniqueIDAttributeType {
|
||||
|
||||
public typealias NativeTypeForUniqueID = NSNumber
|
||||
|
||||
public static func cs_fromUniqueIDNativeType(_ value: NativeTypeForUniqueID) -> Int32? {
|
||||
|
||||
return value.int32Value
|
||||
}
|
||||
|
||||
public func cs_toUniqueIDNativeType() -> NativeTypeForUniqueID {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Int64
|
||||
|
||||
extension Int64: CoreStoreUniqueIDAttributeType {
|
||||
|
||||
public typealias NativeTypeForUniqueID = NSNumber
|
||||
|
||||
public static func cs_fromUniqueIDNativeType(_ value: NativeTypeForUniqueID) -> Int64? {
|
||||
|
||||
return value.int64Value
|
||||
}
|
||||
|
||||
public func cs_toUniqueIDNativeType() -> NativeTypeForUniqueID {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Double
|
||||
|
||||
extension Double: CoreStoreUniqueIDAttributeType {
|
||||
|
||||
public typealias NativeTypeForUniqueID = NSNumber
|
||||
|
||||
public static func cs_fromUniqueIDNativeType(_ value: NativeTypeForUniqueID) -> Double? {
|
||||
|
||||
return value.doubleValue
|
||||
}
|
||||
|
||||
public func cs_toUniqueIDNativeType() -> NativeTypeForUniqueID {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Float
|
||||
|
||||
extension Float: CoreStoreUniqueIDAttributeType {
|
||||
|
||||
public typealias NativeTypeForUniqueID = NSNumber
|
||||
|
||||
public static func cs_fromUniqueIDNativeType(_ value: NativeTypeForUniqueID) -> Float? {
|
||||
|
||||
return value.floatValue
|
||||
}
|
||||
|
||||
public func cs_toUniqueIDNativeType() -> NativeTypeForUniqueID {
|
||||
|
||||
return self as NSNumber
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Date
|
||||
|
||||
extension Date: CoreStoreUniqueIDAttributeType {
|
||||
|
||||
public typealias NativeTypeForUniqueID = NSDate
|
||||
|
||||
public static func cs_fromUniqueIDNativeType(_ value: NativeTypeForUniqueID) -> Date? {
|
||||
|
||||
return value as Date
|
||||
}
|
||||
|
||||
public func cs_toUniqueIDNativeType() -> NativeTypeForUniqueID {
|
||||
|
||||
return self as NSDate
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - String
|
||||
|
||||
extension String: CoreStoreUniqueIDAttributeType {
|
||||
|
||||
public typealias NativeTypeForUniqueID = NSString
|
||||
|
||||
public static func cs_fromUniqueIDNativeType(_ value: NativeTypeForUniqueID) -> String? {
|
||||
|
||||
return value as String
|
||||
}
|
||||
|
||||
public func cs_toUniqueIDNativeType() -> NativeTypeForUniqueID {
|
||||
|
||||
return self as NSString
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Data
|
||||
|
||||
extension Data: CoreStoreUniqueIDAttributeType {
|
||||
|
||||
public typealias NativeTypeForUniqueID = NSData
|
||||
|
||||
public static func cs_fromUniqueIDNativeType(_ value: NativeTypeForUniqueID) -> Data? {
|
||||
|
||||
return value as Data
|
||||
}
|
||||
|
||||
public func cs_toUniqueIDNativeType() -> NativeTypeForUniqueID {
|
||||
|
||||
return self as NSData
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public protocol ImportableUniqueObject: ImportableObject {
|
||||
/**
|
||||
The data type for the entity's unique ID attribute
|
||||
*/
|
||||
associatedtype UniqueIDType: CoreStoreSupportedAttributeType
|
||||
associatedtype UniqueIDType: CoreStoreUniqueIDAttributeType
|
||||
|
||||
/**
|
||||
The keyPath to the entity's unique ID attribute
|
||||
@@ -192,14 +192,14 @@ public extension ImportableUniqueObject where Self: NSManagedObject {
|
||||
|
||||
get {
|
||||
|
||||
return UniqueIDType.cs_fromNativeType(
|
||||
self.value(forKey: type(of: self).uniqueIDKeyPath) as! UniqueIDType.CoreStoreNativeType
|
||||
return UniqueIDType.cs_fromUniqueIDNativeType(
|
||||
self.value(forKey: type(of: self).uniqueIDKeyPath) as! UniqueIDType.NativeTypeForUniqueID
|
||||
)!
|
||||
}
|
||||
set {
|
||||
|
||||
self.setValue(
|
||||
newValue.cs_toNativeType(),
|
||||
newValue.cs_toUniqueIDNativeType(),
|
||||
forKey: type(of: self).uniqueIDKeyPath
|
||||
)
|
||||
}
|
||||
|
||||
@@ -87,7 +87,9 @@ public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
|
||||
@objc
|
||||
public convenience init(keyPath: KeyPath, isEqualTo value: CoreDataNativeType?) {
|
||||
|
||||
self.init(Where(keyPath, isEqualTo: value))
|
||||
self.init(value == nil || value is NSNull
|
||||
? Where("\(keyPath) == nil")
|
||||
: Where("\(keyPath) == %@", value!))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +101,7 @@ public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
|
||||
@objc
|
||||
public convenience init(keyPath: KeyPath, isMemberOf list: [CoreDataNativeType]) {
|
||||
|
||||
self.init(Where(keyPath, isMemberOf: list))
|
||||
self.init(Where("\(keyPath) IN %@", list as NSArray))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user