Merge branch 'fetched_records_events_platforms' of https://github.com/reTXT/GRDB.swift

This commit is contained in:
Gwendal Roué committed 2017-01-04 06:32:18 +01:00
commit eeaf3dc2cf
4 files changed
+705 -656

No files matched your search

+18 -36
View File
@@ -32,10 +32,10 @@
5605F1931C6B1A8700235C62 /* QueryInterfaceSelectQueryDefinition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F18C1C6B1A8700235C62 /* QueryInterfaceSelectQueryDefinition.swift */; };
5605F1941C6B1A8700235C62 /* QueryInterfaceSelectQueryDefinition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F18C1C6B1A8700235C62 /* QueryInterfaceSelectQueryDefinition.swift */; };
5606AF911C0ED37000D20487 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 56BB86301BA98AB0001F9168 /* libsqlite3.tbd */; };
56071A411DB54ED000CA6E47 /* FetchedRecordsControlleriOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControlleriOSTests.swift */; };
56071A4E1DB54ED200CA6E47 /* FetchedRecordsControlleriOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControlleriOSTests.swift */; };
56071A4F1DB54ED300CA6E47 /* FetchedRecordsControlleriOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControlleriOSTests.swift */; };
56071A501DB54ED300CA6E47 /* FetchedRecordsControlleriOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControlleriOSTests.swift */; };
56071A411DB54ED000CA6E47 /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift */; };
56071A4E1DB54ED200CA6E47 /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift */; };
56071A4F1DB54ED300CA6E47 /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift */; };
56071A501DB54ED300CA6E47 /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift */; };
5607EFD41BB827FD00605DE3 /* TransactionObserverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5607EFD21BB8254800605DE3 /* TransactionObserverTests.swift */; };
560A37A41C8F625000949E71 /* DatabasePool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37A31C8F625000949E71 /* DatabasePool.swift */; };
560A37A51C8F625000949E71 /* DatabasePool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560A37A31C8F625000949E71 /* DatabasePool.swift */; };
@@ -269,8 +269,6 @@
5636E9C01D22574100B9B05F /* Request.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5636E9BB1D22574100B9B05F /* Request.swift */; };
5636E9C11D22574100B9B05F /* Request.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5636E9BB1D22574100B9B05F /* Request.swift */; };
564A50C81BFF4B7F00B3A3A2 /* CollationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564A50C61BFF4B7F00B3A3A2 /* CollationTests.swift */; };
565049061CE32543000A97D8 /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565049041CE32543000A97D8 /* FetchedRecordsControllerTests.swift */; };
565049071CE32543000A97D8 /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565049041CE32543000A97D8 /* FetchedRecordsControllerTests.swift */; };
565490B41D5A4820005622CB /* GRDB.h in Headers */ = {isa = PBXBuildFile; fileRef = DC3773F819C8CBB3004FCF85 /* GRDB.h */; settings = {ATTRIBUTES = (Public, ); }; };
565490B51D5A4827005622CB /* GRDB-Bridging.h in Headers */ = {isa = PBXBuildFile; fileRef = DC2393C61ABE35F8003FF113 /* GRDB-Bridging.h */; settings = {ATTRIBUTES = (Public, ); }; };
565490B61D5AE236005622CB /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238701B9C75030082EB20 /* Configuration.swift */; };
@@ -577,9 +575,6 @@
5690C3431D23E82A00E59934 /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5690C33F1D23E82A00E59934 /* Data.swift */; };
5690C3441D23E82A00E59934 /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5690C33F1D23E82A00E59934 /* Data.swift */; };
5690C3451D23E82A00E59934 /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5690C33F1D23E82A00E59934 /* Data.swift */; };
569178391CED8E0A00E179EA /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565049041CE32543000A97D8 /* FetchedRecordsControllerTests.swift */; };
569178411CED8E0C00E179EA /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565049041CE32543000A97D8 /* FetchedRecordsControllerTests.swift */; };
569178421CED8E0D00E179EA /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565049041CE32543000A97D8 /* FetchedRecordsControllerTests.swift */; };
569178471CED9B6000E179EA /* DatabaseQueueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569178451CED9B6000E179EA /* DatabaseQueueTests.swift */; };
569178481CED9B6000E179EA /* DatabaseQueueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569178451CED9B6000E179EA /* DatabaseQueueTests.swift */; };
569178491CED9B6000E179EA /* DatabaseQueueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569178451CED9B6000E179EA /* DatabaseQueueTests.swift */; };
@@ -999,9 +994,9 @@
56B14E841D4DAE54000BF4A3 /* RowAsDictionaryLiteralConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B14E7E1D4DAE54000BF4A3 /* RowAsDictionaryLiteralConvertibleTests.swift */; };
56B14E851D4DAE54000BF4A3 /* RowAsDictionaryLiteralConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B14E7E1D4DAE54000BF4A3 /* RowAsDictionaryLiteralConvertibleTests.swift */; };
56B14E861D4DAE54000BF4A3 /* RowAsDictionaryLiteralConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B14E7E1D4DAE54000BF4A3 /* RowAsDictionaryLiteralConvertibleTests.swift */; };
56B15D0B1CD4C35100A24C8B /* FetchedRecordsControlleriOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControlleriOSTests.swift */; };
56B15D0C1CD4C35100A24C8B /* FetchedRecordsControlleriOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControlleriOSTests.swift */; };
56B15D0D1CD4C35100A24C8B /* FetchedRecordsControlleriOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControlleriOSTests.swift */; };
56B15D0B1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift */; };
56B15D0C1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift */; };
56B15D0D1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift */; };
56B7F42A1BE14A1900E39BBF /* CGFloatTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4291BE14A1900E39BBF /* CGFloatTests.swift */; };
56B7F4381BE4C11200E39BBF /* DatabaseCoderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4361BE4C11200E39BBF /* DatabaseCoderTests.swift */; };
56B7F43A1BEB42D500E39BBF /* Migration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4391BEB42D500E39BBF /* Migration.swift */; };
@@ -1107,7 +1102,6 @@
56D496781D81309E008276D7 /* RecordSubClassTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238331B9C74A90082EB20 /* RecordSubClassTests.swift */; };
56D496791D81309E008276D7 /* RecordWithColumnNameManglingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A5E4081BA2BCF900707640 /* RecordWithColumnNameManglingTests.swift */; };
56D4967C1D8130DB008276D7 /* CGFloatTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4291BE14A1900E39BBF /* CGFloatTests.swift */; };
56D4967E1D8130DB008276D7 /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565049041CE32543000A97D8 /* FetchedRecordsControllerTests.swift */; };
56D4967F1D813131008276D7 /* StatementColumnConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56EE573C1BB317B7007A6A95 /* StatementColumnConvertibleTests.swift */; };
56D496801D813131008276D7 /* StatementColumnConvertibleFetchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56E8CE0F1BB4FE5B00828BEC /* StatementColumnConvertibleFetchTests.swift */; };
56D496811D813131008276D7 /* TransactionObserverSavepointsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5634B1061CF9B970005360B9 /* TransactionObserverSavepointsTests.swift */; };
@@ -1396,9 +1390,7 @@
F3BA81001CFB3025003DC1BA /* TransactionObserverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5607EFD21BB8254800605DE3 /* TransactionObserverTests.swift */; };
F3BA81011CFB3032003DC1BA /* CGFloatTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4291BE14A1900E39BBF /* CGFloatTests.swift */; };
F3BA81021CFB3032003DC1BA /* CGFloatTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4291BE14A1900E39BBF /* CGFloatTests.swift */; };
F3BA81031CFB303D003DC1BA /* FetchedRecordsControlleriOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControlleriOSTests.swift */; };
F3BA81041CFB3045003DC1BA /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565049041CE32543000A97D8 /* FetchedRecordsControllerTests.swift */; };
F3BA81051CFB3046003DC1BA /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565049041CE32543000A97D8 /* FetchedRecordsControllerTests.swift */; };
F3BA81031CFB303D003DC1BA /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift */; };
F3BA81081CFB3056003DC1BA /* DatabaseCoderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4361BE4C11200E39BBF /* DatabaseCoderTests.swift */; };
F3BA810A1CFB3056003DC1BA /* NSDateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56F0B98E1B6001C600A2F135 /* NSDateTests.swift */; };
F3BA810B1CFB3056003DC1BA /* Row+FoundationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565D5D701BBC694D00DC9BD4 /* Row+FoundationTests.swift */; };
@@ -1721,7 +1713,6 @@
563633981DA40F0100CB70CA /* FTS4.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS4.swift; sourceTree = "<group>"; };
5636E9BB1D22574100B9B05F /* Request.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Request.swift; sourceTree = "<group>"; };
564A50C61BFF4B7F00B3A3A2 /* CollationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollationTests.swift; sourceTree = "<group>"; };
565049041CE32543000A97D8 /* FetchedRecordsControllerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchedRecordsControllerTests.swift; sourceTree = "<group>"; };
565490A01D5A4798005622CB /* GRDB.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GRDB.framework; sourceTree = BUILT_PRODUCTS_DIR; };
565490E51D5AE282005622CB /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS2.2.sdk/usr/lib/libsqlite3.tbd; sourceTree = DEVELOPER_DIR; };
56553C181C3E906C00522B5C /* GRDBOSXCrashTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBOSXCrashTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -1846,7 +1837,7 @@
56AFCAD71CB1ABC800F48B96 /* GRDBTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
56B021C81D8C0D3900B239BB /* PersistenceConflictPolicyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PersistenceConflictPolicyTests.swift; sourceTree = "<group>"; };
56B14E7E1D4DAE54000BF4A3 /* RowAsDictionaryLiteralConvertibleTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowAsDictionaryLiteralConvertibleTests.swift; sourceTree = "<group>"; };
56B15D0A1CD4C35100A24C8B /* FetchedRecordsControlleriOSTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchedRecordsControlleriOSTests.swift; sourceTree = "<group>"; };
56B15D0A1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchedRecordsControllerTests.swift; sourceTree = "<group>"; };
56B7F4291BE14A1900E39BBF /* CGFloatTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGFloatTests.swift; sourceTree = "<group>"; };
56B7F4361BE4C11200E39BBF /* DatabaseCoderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseCoderTests.swift; sourceTree = "<group>"; };
56B7F4391BEB42D500E39BBF /* Migration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Migration.swift; sourceTree = "<group>"; };
@@ -2566,8 +2557,7 @@
56B15CFC1CD4C33A00A24C8B /* FetchedRecordsController */ = {
isa = PBXGroup;
children = (
56B15D0A1CD4C35100A24C8B /* FetchedRecordsControlleriOSTests.swift */,
565049041CE32543000A97D8 /* FetchedRecordsControllerTests.swift */,
56B15D0A1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift */,
);
path = FetchedRecordsController;
sourceTree = "<group>";
@@ -3752,10 +3742,9 @@
56C3F7541CF9F12400F6A361 /* SavepointTests.swift in Sources */,
567A80541D41350C00C7DCEC /* IndexInfoTests.swift in Sources */,
560FC58B1CB00B880014AA8E /* DatabaseValueTests.swift in Sources */,
565049061CE32543000A97D8 /* FetchedRecordsControllerTests.swift in Sources */,
567156171CB142AA007DC145 /* ReadOnlyDatabaseTests.swift in Sources */,
560FC58D1CB00B880014AA8E /* Row+FoundationTests.swift in Sources */,
56071A4E1DB54ED200CA6E47 /* FetchedRecordsControlleriOSTests.swift in Sources */,
56071A4E1DB54ED200CA6E47 /* FetchedRecordsControllerTests.swift in Sources */,
56A4CDB11D4234B200B1A9B9 /* SQLExpressionLiteralTests.swift in Sources */,
567156141CB141D0007DC145 /* InMemoryDatabaseTests.swift in Sources */,
560FC58E1CB00B880014AA8E /* PrimaryKeyRowIDTests.swift in Sources */,
@@ -3955,14 +3944,13 @@
5690C3391D23E7D200E59934 /* DateTests.swift in Sources */,
567156461CB16729007DC145 /* TransactionObserverTests.swift in Sources */,
567A80551D41350C00C7DCEC /* IndexInfoTests.swift in Sources */,
565049071CE32543000A97D8 /* FetchedRecordsControllerTests.swift in Sources */,
567156481CB16729007DC145 /* DatabaseValueTests.swift in Sources */,
5671564A1CB16729007DC145 /* ReadOnlyDatabaseTests.swift in Sources */,
5671564B1CB16729007DC145 /* Row+FoundationTests.swift in Sources */,
56A8C2431D1918EE0096E9D4 /* NSUUIDTests.swift in Sources */,
5671564C1CB16729007DC145 /* InMemoryDatabaseTests.swift in Sources */,
56A4CDB21D4234B200B1A9B9 /* SQLExpressionLiteralTests.swift in Sources */,
56071A4F1DB54ED300CA6E47 /* FetchedRecordsControlleriOSTests.swift in Sources */,
56071A4F1DB54ED300CA6E47 /* FetchedRecordsControllerTests.swift in Sources */,
5671564D1CB16729007DC145 /* PrimaryKeyRowIDTests.swift in Sources */,
5671564E1CB16729007DC145 /* DatabaseReaderTests.swift in Sources */,
5671564F1CB16729007DC145 /* RecordEditedTests.swift in Sources */,
@@ -4122,7 +4110,7 @@
56AFCA471CB1AA9900F48B96 /* MetalRowTests.swift in Sources */,
56AFCA491CB1AA9900F48B96 /* StatementArgumentsTests.swift in Sources */,
5672DE6B1CDB751D0022BA81 /* DatabasePoolBackupTests.swift in Sources */,
56B15D0C1CD4C35100A24C8B /* FetchedRecordsControlleriOSTests.swift in Sources */,
56B15D0C1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift in Sources */,
56AFCA4A1CB1AA9900F48B96 /* RecordInitializersTests.swift in Sources */,
566AD8CB1D531BED002EC1A8 /* SQLTableBuilderTests.swift in Sources */,
56AFCA4B1CB1AA9900F48B96 /* MutablePersistableTests.swift in Sources */,
@@ -4150,7 +4138,6 @@
56AF74701D41FB9C005E9FF3 /* DatabaseValueConvertibleEscapingTests.swift in Sources */,
5690C33C1D23E7D200E59934 /* DateTests.swift in Sources */,
56AFCA581CB1AA9900F48B96 /* Row+FoundationTests.swift in Sources */,
569178411CED8E0C00E179EA /* FetchedRecordsControllerTests.swift in Sources */,
56AFCA5A1CB1AA9900F48B96 /* RecordSubClassTests.swift in Sources */,
56A4CDB51D4234B200B1A9B9 /* SQLExpressionLiteralTests.swift in Sources */,
56AFCA5B1CB1AA9900F48B96 /* DatabaseValueTests.swift in Sources */,
@@ -4256,7 +4243,6 @@
5657AB6C1D108BA9006283EF /* URLTests.swift in Sources */,
56AFCAA81CB1ABC800F48B96 /* DataMemoryTests.swift in Sources */,
56AFCAA91CB1ABC800F48B96 /* RecordCopyTests.swift in Sources */,
569178421CED8E0D00E179EA /* FetchedRecordsControllerTests.swift in Sources */,
56A8C24B1D1918F10096E9D4 /* NSUUIDTests.swift in Sources */,
56AFCAAB1CB1ABC800F48B96 /* PersistableTests.swift in Sources */,
56FF45461D2C23BA00F21EF9 /* DeleteByKeyTests.swift in Sources */,
@@ -4281,7 +4267,7 @@
56AFCAB51CB1ABC800F48B96 /* ReadOnlyDatabaseTests.swift in Sources */,
56AFCAB61CB1ABC800F48B96 /* DatabaseReaderTests.swift in Sources */,
56AFCAB71CB1ABC800F48B96 /* RowConvertibleTests.swift in Sources */,
56B15D0D1CD4C35100A24C8B /* FetchedRecordsControlleriOSTests.swift in Sources */,
56B15D0D1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift in Sources */,
5623931E1DECC02000A6B01F /* RowFetchTests.swift in Sources */,
56AFCAB81CB1ABC800F48B96 /* DatabaseValueConvertibleFetchTests.swift in Sources */,
5698AC8F1DA389380056AF8C /* FTS3TableBuilderTests.swift in Sources */,
@@ -4438,7 +4424,7 @@
56AF746F1D41FB9C005E9FF3 /* DatabaseValueConvertibleEscapingTests.swift in Sources */,
5672DE6A1CDB751D0022BA81 /* DatabasePoolBackupTests.swift in Sources */,
5698AC4D1DA2D48A0056AF8C /* FTS3RecordTests.swift in Sources */,
56B15D0B1CD4C35100A24C8B /* FetchedRecordsControlleriOSTests.swift in Sources */,
56B15D0B1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift in Sources */,
56A238681B9C74A90082EB20 /* RecordInitializersTests.swift in Sources */,
563363B01C933FF8000BE133 /* MutablePersistableTests.swift in Sources */,
5657AB421D108BA9006283EF /* NSDataTests.swift in Sources */,
@@ -4461,7 +4447,6 @@
5623936D1DEE0CD200A6B01F /* FlattenCursorTests.swift in Sources */,
567A80571D41350C00C7DCEC /* IndexInfoTests.swift in Sources */,
5623935B1DEE013C00A6B01F /* FilterCursorTests.swift in Sources */,
569178391CED8E0A00E179EA /* FetchedRecordsControllerTests.swift in Sources */,
56A2386A1B9C74A90082EB20 /* RecordSubClassTests.swift in Sources */,
56A2383E1B9C74A90082EB20 /* DatabaseValueTests.swift in Sources */,
567156181CB142AA007DC145 /* ReadOnlyDatabaseTests.swift in Sources */,
@@ -4585,7 +4570,6 @@
56D4966F1D81309E008276D7 /* PrimaryKeyNoneTests.swift in Sources */,
56D496621D81304E008276D7 /* StatementArguments+FoundationTests.swift in Sources */,
56D496B21D8133CE008276D7 /* InMemoryDatabaseTests.swift in Sources */,
56D4967E1D8130DB008276D7 /* FetchedRecordsControllerTests.swift in Sources */,
562393601DEE06D300A6B01F /* CursorTests.swift in Sources */,
56D4968F1D81316E008276D7 /* DictionaryRowTests.swift in Sources */,
56D4968E1D81316E008276D7 /* DetachedRowTests.swift in Sources */,
@@ -4620,7 +4604,7 @@
56D4967F1D813131008276D7 /* StatementColumnConvertibleTests.swift in Sources */,
56D496971D81317B008276D7 /* DatabaseReaderTests.swift in Sources */,
56D496911D81316E008276D7 /* MetalRowTests.swift in Sources */,
56071A411DB54ED000CA6E47 /* FetchedRecordsControlleriOSTests.swift in Sources */,
56071A411DB54ED000CA6E47 /* FetchedRecordsControllerTests.swift in Sources */,
56D496B91D81346F008276D7 /* DatabaseValueConvertibleEscapingTests.swift in Sources */,
56D496901D81316E008276D7 /* AdapterRowTests.swift in Sources */,
56D496721D81309E008276D7 /* PrimaryKeySingleWithReplaceConflictResolutionTests.swift in Sources */,
@@ -4832,7 +4816,6 @@
F3BA81121CFB3059003DC1BA /* DatabaseMigratorTests.swift in Sources */,
F3BA80EB1CFB3016003DC1BA /* RowConvertibleTests.swift in Sources */,
F3BA81151CFB305E003DC1BA /* Record+QueryInterfaceRequestTests.swift in Sources */,
F3BA81041CFB3045003DC1BA /* FetchedRecordsControllerTests.swift in Sources */,
F3BA80DC1CFB300E003DC1BA /* DatabaseValueConvertibleFetchTests.swift in Sources */,
5698AD021DAA8ACB0056AF8C /* FTS5CustomTokenizerTests.swift in Sources */,
56B964CA1DA521450002DA19 /* FTS5PatternTests.swift in Sources */,
@@ -4841,7 +4824,7 @@
56DAA2D91DE99DAB006E10C8 /* DatabaseCursorTests.swift in Sources */,
F3BA80F11CFB3019003DC1BA /* SavepointTests.swift in Sources */,
56ED8A801DAB8D6800BD0ABC /* FTS5WrapperTokenizerTests.swift in Sources */,
F3BA81031CFB303D003DC1BA /* FetchedRecordsControlleriOSTests.swift in Sources */,
F3BA81031CFB303D003DC1BA /* FetchedRecordsControllerTests.swift in Sources */,
F3BA80B71CFB2FCD003DC1BA /* DatabaseErrorTests.swift in Sources */,
5698ACCC1DA62A2D0056AF8C /* FTS5TokenizerTests.swift in Sources */,
5690C33E1D23E7D200E59934 /* DateTests.swift in Sources */,
@@ -4993,7 +4976,7 @@
561667041D08A49900ADD404 /* NSDecimalNumberTests.swift in Sources */,
F3BA80E31CFB300F003DC1BA /* DatabaseValueConvertibleSubclassTests.swift in Sources */,
566AD8C91D531BEB002EC1A8 /* SQLTableBuilderTests.swift in Sources */,
56071A501DB54ED300CA6E47 /* FetchedRecordsControlleriOSTests.swift in Sources */,
56071A501DB54ED300CA6E47 /* FetchedRecordsControllerTests.swift in Sources */,
F3BA80AC1CFB2FA6003DC1BA /* DatabaseQueueSchemaCacheTests.swift in Sources */,
56A8C2461D1918EF0096E9D4 /* UUIDTests.swift in Sources */,
F3BA80F61CFB301E003DC1BA /* StatementColumnConvertibleFetchTests.swift in Sources */,
@@ -5049,7 +5032,6 @@
F3BA80D51CFB2FFB003DC1BA /* DatabaseReaderTests.swift in Sources */,
F3BA81321CFB3064003DC1BA /* PrimaryKeySingleWithReplaceConflictResolutionTests.swift in Sources */,
5623935A1DEE013C00A6B01F /* FilterCursorTests.swift in Sources */,
F3BA81051CFB3046003DC1BA /* FetchedRecordsControllerTests.swift in Sources */,
F3BA80FC1CFB3021003DC1BA /* UpdateStatementTests.swift in Sources */,
5623936C1DEE0CD200A6B01F /* FlattenCursorTests.swift in Sources */,
F3BA80E01CFB300F003DC1BA /* DatabaseTimestampTests.swift in Sources */,
File diff suppressed because it is too large. Load diff
@@ -8,16 +8,20 @@ import XCTest
#endif
private class ChangesRecorder<Record: RowConvertible> {
var changes: [(record: Record, event: FetchedRecordsChangeEvent)] = []
var recordsBeforeChanges: [Record]!
var recordsAfterChanges: [Record]!
var countBeforeChanges: Int?
var countAfterChanges: Int?
var recordsOnFirstEvent: [Record]!
var transactionExpectation: XCTestExpectation? {
didSet {
changes = []
recordsBeforeChanges = nil
recordsAfterChanges = nil
countBeforeChanges = nil
countAfterChanges = nil
recordsOnFirstEvent = nil
}
}
@@ -26,6 +30,14 @@ private class ChangesRecorder<Record: RowConvertible> {
countBeforeChanges = count
}
/// The default implementation does nothing.
func controller(_ controller: FetchedRecordsController<Record>, didChangeRecord record: Record, withEvent event:FetchedRecordsChangeEvent) {
if recordsOnFirstEvent == nil {
recordsOnFirstEvent = controller.fetchedRecords!
}
changes.append((record: record, event: event))
}
/// The default implementation does nothing.
func controllerDidChange(_ controller: FetchedRecordsController<Record>, count: Int? = nil) {
recordsAfterChanges = controller.fetchedRecords
@@ -170,12 +182,32 @@ class FetchedRecordsControllerTests: GRDBTestCase {
try arthur.insert(db)
}
let request = Person.all()
let controller = try FetchedRecordsController<Person>(dbQueue, request: request, compareRecordsByPrimaryKey: true)
XCTAssertTrue(controller.fetchedRecords == nil)
try controller.performFetch()
XCTAssertEqual(controller.sections.count, 1)
XCTAssertEqual(controller.sections[0].numberOfRecords, 1)
XCTAssertEqual(controller.sections[0].records.count, 1)
XCTAssertEqual(controller.sections[0].records[0].name, "Arthur")
XCTAssertEqual(controller.fetchedRecords!.count, 1)
XCTAssertEqual(controller.fetchedRecords![0].name, "Arthur")
XCTAssertEqual(controller.record(at: IndexPath(indexes: [0, 0])).name, "Arthur")
XCTAssertEqual(controller.indexPath(for: arthur), IndexPath(indexes: [0, 0]))
}
}
func testEmptyRequestGivesOneSection() {
assertNoError {
let dbQueue = try makeDatabaseQueue()
let request = Person.all()
let controller = try FetchedRecordsController<Person>(dbQueue, request: request)
XCTAssertTrue(controller.fetchedRecords == nil)
try controller.performFetch()
XCTAssertEqual(controller.fetchedRecords!.count, 1)
XCTAssertEqual(controller.fetchedRecords![0].name, "Arthur")
XCTAssertEqual(controller.fetchedRecords!.count, 0)
// Just like NSFetchedResultsController
XCTAssertEqual(controller.sections.count, 1)
}
}
@@ -188,10 +220,11 @@ class FetchedRecordsControllerTests: GRDBTestCase {
func testSimpleInsert() {
assertNoError {
let dbQueue = try makeDatabaseQueue()
let controller = try FetchedRecordsController<Person>(dbQueue, request: Person.order(Column("id")))
let controller = try FetchedRecordsController<Person>(dbQueue, request: Person.order(Column("id")), compareRecordsByPrimaryKey: true)
let recorder = ChangesRecorder<Person>()
controller.trackChanges(
recordsWillChange: { recorder.controllerWillChange($0) },
event: { (controller, record, event) in recorder.controller(controller, didChangeRecord: record, withEvent: event) },
recordsDidChange: { recorder.controllerDidChange($0) })
try controller.performFetch()
@@ -205,8 +238,17 @@ class FetchedRecordsControllerTests: GRDBTestCase {
waitForExpectations(timeout: 1, handler: nil)
XCTAssertEqual(recorder.recordsBeforeChanges.count, 0)
XCTAssertEqual(recorder.recordsAfterChanges.count, 1)
XCTAssertEqual(recorder.recordsAfterChanges.map { $0.name }, ["Arthur"])
XCTAssertEqual(recorder.recordsOnFirstEvent.count, 1)
XCTAssertEqual(recorder.recordsOnFirstEvent.map { $0.name }, ["Arthur"])
XCTAssertEqual(recorder.changes.count, 1)
XCTAssertEqual(recorder.changes[0].record.id, 1)
XCTAssertEqual(recorder.changes[0].record.name, "Arthur")
switch recorder.changes[0].event {
case .insertion(let indexPath):
XCTAssertEqual(indexPath, IndexPath(indexes: [0, 0]))
default:
XCTFail()
}
// Second insert
recorder.transactionExpectation = expectation(description: "expectation")
@@ -220,18 +262,29 @@ class FetchedRecordsControllerTests: GRDBTestCase {
XCTAssertEqual(recorder.recordsBeforeChanges.count, 1)
XCTAssertEqual(recorder.recordsBeforeChanges.map { $0.name }, ["Arthur"])
XCTAssertEqual(recorder.recordsAfterChanges.count, 2)
XCTAssertEqual(recorder.recordsAfterChanges.map { $0.name }, ["Arthur", "Barbara"])
XCTAssertEqual(recorder.recordsOnFirstEvent.count, 2)
XCTAssertEqual(recorder.recordsOnFirstEvent.map { $0.name }, ["Arthur", "Barbara"])
XCTAssertEqual(recorder.changes.count, 1)
XCTAssertEqual(recorder.changes[0].record.id, 2)
XCTAssertEqual(recorder.changes[0].record.name, "Barbara")
switch recorder.changes[0].event {
case .insertion(let indexPath):
XCTAssertEqual(indexPath, IndexPath(indexes: [0, 1]))
default:
XCTFail()
}
}
}
func testSimpleUpdate() {
assertNoError {
let dbQueue = try makeDatabaseQueue()
let controller = try FetchedRecordsController<Person>(dbQueue, request: Person.order(Column("id")))
let controller = try FetchedRecordsController<Person>(dbQueue, request: Person.order(Column("id")), compareRecordsByPrimaryKey: true)
let recorder = ChangesRecorder<Person>()
controller.trackChanges(
recordsWillChange: { recorder.controllerWillChange($0) },
event: { (controller, record, event) in recorder.controller(controller, didChangeRecord: record, withEvent: event) },
recordsDidChange: { recorder.controllerDidChange($0) })
try controller.performFetch()
@@ -263,8 +316,18 @@ class FetchedRecordsControllerTests: GRDBTestCase {
XCTAssertEqual(recorder.recordsBeforeChanges.count, 2)
XCTAssertEqual(recorder.recordsBeforeChanges.map { $0.name }, ["Arthur", "Barbara"])
XCTAssertEqual(recorder.recordsAfterChanges.count, 2)
XCTAssertEqual(recorder.recordsAfterChanges.map { $0.name }, ["Craig", "Barbara"])
XCTAssertEqual(recorder.recordsOnFirstEvent.count, 2)
XCTAssertEqual(recorder.recordsOnFirstEvent.map { $0.name }, ["Craig", "Barbara"])
XCTAssertEqual(recorder.changes.count, 1)
XCTAssertEqual(recorder.changes[0].record.id, 1)
XCTAssertEqual(recorder.changes[0].record.name, "Craig")
switch recorder.changes[0].event {
case .update(let indexPath, let changes):
XCTAssertEqual(indexPath, IndexPath(indexes: [0, 0]))
XCTAssertEqual(changes, ["name": "Arthur".databaseValue])
default:
XCTFail()
}
// Second update
recorder.transactionExpectation = expectation(description: "expectation")
@@ -278,18 +341,29 @@ class FetchedRecordsControllerTests: GRDBTestCase {
XCTAssertEqual(recorder.recordsBeforeChanges.count, 2)
XCTAssertEqual(recorder.recordsBeforeChanges.map { $0.name }, ["Craig", "Barbara"])
XCTAssertEqual(recorder.recordsAfterChanges.count, 2)
XCTAssertEqual(recorder.recordsAfterChanges.map { $0.name }, ["Craig", "Danielle"])
XCTAssertEqual(recorder.recordsOnFirstEvent.count, 2)
XCTAssertEqual(recorder.recordsOnFirstEvent.map { $0.name }, ["Craig", "Danielle"])
XCTAssertEqual(recorder.changes.count, 1)
XCTAssertEqual(recorder.changes[0].record.id, 2)
XCTAssertEqual(recorder.changes[0].record.name, "Danielle")
switch recorder.changes[0].event {
case .update(let indexPath, let changes):
XCTAssertEqual(indexPath, IndexPath(indexes: [0, 1]))
XCTAssertEqual(changes, ["name": "Barbara".databaseValue])
default:
XCTFail()
}
}
}
func testSimpleDelete() {
assertNoError {
let dbQueue = try makeDatabaseQueue()
let controller = try FetchedRecordsController<Person>(dbQueue, request: Person.order(Column("id")))
let controller = try FetchedRecordsController<Person>(dbQueue, request: Person.order(Column("id")), compareRecordsByPrimaryKey: true)
let recorder = ChangesRecorder<Person>()
controller.trackChanges(
recordsWillChange: { recorder.controllerWillChange($0) },
event: { (controller, record, event) in recorder.controller(controller, didChangeRecord: record, withEvent: event) },
recordsDidChange: { recorder.controllerDidChange($0) })
try controller.performFetch()
@@ -314,8 +388,17 @@ class FetchedRecordsControllerTests: GRDBTestCase {
XCTAssertEqual(recorder.recordsBeforeChanges.count, 2)
XCTAssertEqual(recorder.recordsBeforeChanges.map { $0.name }, ["Arthur", "Barbara"])
XCTAssertEqual(recorder.recordsAfterChanges.count, 1)
XCTAssertEqual(recorder.recordsAfterChanges.map { $0.name }, ["Barbara"])
XCTAssertEqual(recorder.recordsOnFirstEvent.count, 1)
XCTAssertEqual(recorder.recordsOnFirstEvent.map { $0.name }, ["Barbara"])
XCTAssertEqual(recorder.changes.count, 1)
XCTAssertEqual(recorder.changes[0].record.id, 1)
XCTAssertEqual(recorder.changes[0].record.name, "Arthur")
switch recorder.changes[0].event {
case .deletion(let indexPath):
XCTAssertEqual(indexPath, IndexPath(indexes: [0, 0]))
default:
XCTFail()
}
// Second delete
recorder.transactionExpectation = expectation(description: "expectation")
@@ -327,17 +410,27 @@ class FetchedRecordsControllerTests: GRDBTestCase {
XCTAssertEqual(recorder.recordsBeforeChanges.count, 1)
XCTAssertEqual(recorder.recordsBeforeChanges.map { $0.name }, ["Barbara"])
XCTAssertEqual(recorder.recordsAfterChanges.count, 0)
XCTAssertEqual(recorder.recordsOnFirstEvent.count, 0)
XCTAssertEqual(recorder.changes.count, 1)
XCTAssertEqual(recorder.changes[0].record.id, 2)
XCTAssertEqual(recorder.changes[0].record.name, "Barbara")
switch recorder.changes[0].event {
case .deletion(let indexPath):
XCTAssertEqual(indexPath, IndexPath(indexes: [0, 0]))
default:
XCTFail()
}
}
}
func testSimpleMove() {
assertNoError {
let dbQueue = try makeDatabaseQueue()
let controller = try FetchedRecordsController<Person>(dbQueue, request: Person.order(Column("name")))
let controller = try FetchedRecordsController<Person>(dbQueue, request: Person.order(Column("name")), compareRecordsByPrimaryKey: true)
let recorder = ChangesRecorder<Person>()
controller.trackChanges(
recordsWillChange: { recorder.controllerWillChange($0) },
event: { (controller, record, event) in recorder.controller(controller, didChangeRecord: record, withEvent: event) },
recordsDidChange: { recorder.controllerDidChange($0) })
try controller.performFetch()
@@ -363,8 +456,19 @@ class FetchedRecordsControllerTests: GRDBTestCase {
XCTAssertEqual(recorder.recordsBeforeChanges.count, 2)
XCTAssertEqual(recorder.recordsBeforeChanges.map { $0.name }, ["Arthur", "Barbara"])
XCTAssertEqual(recorder.recordsAfterChanges.count, 2)
XCTAssertEqual(recorder.recordsAfterChanges.map { $0.name }, ["Barbara", "Craig"])
XCTAssertEqual(recorder.recordsOnFirstEvent.count, 2)
XCTAssertEqual(recorder.recordsOnFirstEvent.map { $0.name }, ["Barbara", "Craig"])
XCTAssertEqual(recorder.changes.count, 1)
XCTAssertEqual(recorder.changes[0].record.id, 1)
XCTAssertEqual(recorder.changes[0].record.name, "Craig")
switch recorder.changes[0].event {
case .move(let indexPath, let newIndexPath, let changes):
XCTAssertEqual(indexPath, IndexPath(indexes: [0, 0]))
XCTAssertEqual(newIndexPath, IndexPath(indexes: [0, 1]))
XCTAssertEqual(changes, ["name": "Arthur".databaseValue])
default:
XCTFail()
}
}
}
@@ -375,20 +479,22 @@ class FetchedRecordsControllerTests: GRDBTestCase {
dbQueue,
sql: ("SELECT persons.*, COUNT(books.id) AS bookCount " +
"FROM persons " +
"LEFT JOIN books ON books.authorID = persons.id " +
"LEFT JOIN books ON books.authorId = persons.id " +
"GROUP BY persons.id " +
"ORDER BY persons.name"))
"ORDER BY persons.name"),
compareRecordsByPrimaryKey: true)
let recorder = ChangesRecorder<Person>()
controller.trackChanges(
recordsWillChange: { recorder.controllerWillChange($0) },
event: { (controller, record, event) in recorder.controller(controller, didChangeRecord: record, withEvent: event) },
recordsDidChange: { recorder.controllerDidChange($0) })
try controller.performFetch()
// Insert
recorder.transactionExpectation = expectation(description: "expectation")
try dbQueue.inTransaction { db in
try db.execute("INSERT INTO persons (name) VALUES (?)", arguments: ["Herman Melville"])
try db.execute("INSERT INTO books (authorID, title) VALUES (?, ?)", arguments: [1, "Moby-Dick"])
try db.execute("INSERT INTO persons (name) VALUES (?)", arguments: ["Arthur"])
try db.execute("INSERT INTO books (authorId, title) VALUES (?, ?)", arguments: [1, "Moby Dick"])
return .commit
}
waitForExpectations(timeout: 1, handler: nil)
@@ -402,11 +508,144 @@ class FetchedRecordsControllerTests: GRDBTestCase {
waitForExpectations(timeout: 1, handler: nil)
XCTAssertEqual(recorder.recordsBeforeChanges.count, 1)
XCTAssertEqual(recorder.recordsBeforeChanges.map { $0.name }, ["Herman Melville"])
XCTAssertEqual(recorder.recordsBeforeChanges.map { $0.name }, ["Arthur"])
XCTAssertEqual(recorder.recordsBeforeChanges.map { $0.bookCount! }, [1])
XCTAssertEqual(recorder.recordsAfterChanges.count, 1)
XCTAssertEqual(recorder.recordsAfterChanges.map { $0.name }, ["Herman Melville"])
XCTAssertEqual(recorder.recordsAfterChanges.map { $0.bookCount! }, [0])
XCTAssertEqual(recorder.recordsOnFirstEvent.count, 1)
XCTAssertEqual(recorder.recordsOnFirstEvent.map { $0.name }, ["Arthur"])
XCTAssertEqual(recorder.recordsOnFirstEvent.map { $0.bookCount! }, [0])
XCTAssertEqual(recorder.changes.count, 1)
XCTAssertEqual(recorder.changes[0].record.id, 1)
XCTAssertEqual(recorder.changes[0].record.name, "Arthur")
XCTAssertEqual(recorder.changes[0].record.bookCount, 0)
switch recorder.changes[0].event {
case .update(let indexPath, let changes):
XCTAssertEqual(indexPath, IndexPath(indexes: [0, 0]))
XCTAssertEqual(changes, ["bookCount": 1.databaseValue])
default:
XCTFail()
}
}
}
func testComplexChanges() {
assertNoError {
let dbQueue = try makeDatabaseQueue()
let controller = try FetchedRecordsController<Person>(dbQueue, request: Person.order(Column("name")), compareRecordsByPrimaryKey: true)
let recorder = ChangesRecorder<Person>()
controller.trackChanges(
recordsWillChange: { recorder.controllerWillChange($0) },
event: { (controller, record, event) in recorder.controller(controller, didChangeRecord: record, withEvent: event) },
recordsDidChange: { recorder.controllerDidChange($0) })
try controller.performFetch()
enum EventTest {
case I(String, Int) // insert string at index
case M(String, Int, Int, String) // move string from index to index with changed string
case D(String, Int) // delete string at index
case U(String, Int, String) // update string at index with changed string
func match(name: String, event: FetchedRecordsChangeEvent) -> Bool {
switch self {
case .I(let s, let i):
switch event {
case .insertion(let indexPath):
return s == name && i == indexPath[1]
default:
return false
}
case .M(let s, let i, let j, let c):
switch event {
case .move(let indexPath, let newIndexPath, let changes):
return s == name && i == indexPath[1] && j == newIndexPath[1] && c == changes["name"]!.value()
default:
return false
}
case .D(let s, let i):
switch event {
case .deletion(let indexPath):
return s == name && i == indexPath[1]
default:
return false
}
case .U(let s, let i, let c):
switch event {
case .update(let indexPath, let changes):
return s == name && i == indexPath[1] && c == changes["name"]!.value()
default:
return false
}
}
}
}
// A list of random updates. We hope to cover most cases if not all cases here.
let steps: [(word: String, events: [EventTest])] = [
(word: "B", events: [.I("B",0)]),
(word: "BA", events: [.I("A",0)]),
(word: "ABF", events: [.M("B",0,1,"A"), .M("A",1,0,"B"), .I("F",2)]),
(word: "AB", events: [.D("F",2)]),
(word: "A", events: [.D("B",1)]),
(word: "C", events: [.U("C",0,"A")]),
(word: "", events: [.D("C",0)]),
(word: "C", events: [.I("C",0)]),
(word: "CD", events: [.I("D",1)]),
(word: "B", events: [.D("D",1), .U("B",0,"C")]),
(word: "BCAEFD", events: [.I("A",0), .I("C",2), .I("D",3), .I("E",4), .I("F",5)]),
(word: "CADBE", events: [.M("A",2,0,"C"), .D("D",3), .M("C",1,2,"B"), .M("B",4,1,"E"), .M("D",0,3,"A"), .M("E",5,4,"F")]),
(word: "EB", events: [.D("B",1), .D("D",3), .D("E",4), .M("E",2,1,"C"), .U("B",0,"A")]),
(word: "BEC", events: [.I("C",1), .M("B",1,0,"E"), .M("E",0,2,"B")]),
(word: "AB", events: [.D("C",1), .M("B",2,1,"E"), .U("A",0,"B")]),
(word: "ADEFCB", events: [.I("B",1), .I("C",2), .I("E",4), .M("D",1,3,"B"), .I("F",5)]),
(word: "DA", events: [.D("B",1), .D("C",2), .D("E",4), .M("A",3,0,"D"), .D("F",5), .M("D",0,1,"A")]),
(word: "BACEF", events: [.I("C",2), .I("E",3), .I("F",4), .U("B",1,"D")]),
(word: "BACD", events: [.D("F",4), .U("D",3,"E")]),
(word: "EABDFC", events: [.M("B",2,1,"C"), .I("C",2), .M("E",1,4,"B"), .I("F",5)]),
(word: "CAB", events: [.D("C",2), .D("D",3), .D("F",5), .M("C",4,2,"E")]),
(word: "CBAD", events: [.M("A",1,0,"B"), .M("B",0,1,"A"), .I("D",3)]),
(word: "BAC", events: [.M("A",1,0,"B"), .M("B",2,1,"C"), .D("D",3), .M("C",0,2,"A")]),
(word: "CBEADF", events: [.I("A",0), .M("B",0,1,"A"), .I("D",3), .M("C",1,2,"B"), .M("E",2,4,"C"), .I("F",5)]),
(word: "CBA", events: [.D("A",0), .D("D",3), .M("A",4,0,"E"), .D("F",5)]),
(word: "CBDAF", events: [.I("A",0), .M("D",0,3,"A"), .I("F",4)]),
(word: "B", events: [.D("A",0), .D("B",1), .D("D",3), .D("F",4), .M("B",2,0,"C")]),
(word: "BDECAF", events: [.I("A",0), .I("C",2), .I("D",3), .I("E",4), .I("F",5)]),
(word: "ABCDEF", events: [.M("A",1,0,"B"), .M("B",3,1,"D"), .M("D",2,3,"C"), .M("C",4,2,"E"), .M("E",0,4,"A")]),
(word: "ADBCF", events: [.M("B",2,1,"C"), .M("C",3,2,"D"), .M("D",1,3,"B"), .D("F",5), .U("F",4,"E")]),
(word: "A", events: [.D("B",1), .D("C",2), .D("D",3), .D("F",4)]),
(word: "AEBDCF", events: [.I("B",1), .I("C",2), .I("D",3), .I("E",4), .I("F",5)]),
(word: "B", events: [.D("B",1), .D("C",2), .D("D",3), .D("E",4), .D("F",5), .U("B",0,"A")]),
(word: "ABCDF", events: [.I("B",1), .I("C",2), .I("D",3), .I("F",4), .U("A",0,"B")]),
(word: "CAB", events: [.M("A",1,0,"B"), .D("D",3), .M("B",2,1,"C"), .D("F",4), .M("C",0,2,"A")]),
(word: "AC", events: [.D("B",1), .M("A",2,0,"C"), .M("C",0,1,"A")]),
(word: "DABC", events: [.I("B",1), .I("C",2), .M("A",1,0,"C"), .M("D",0,3,"A")]),
(word: "BACD", events: [.M("C",1,2,"B"), .M("B",3,1,"D"), .M("D",2,3,"C")]),
(word: "D", events: [.D("A",0), .D("C",2), .D("D",3), .M("D",1,0,"B")]),
(word: "CABDFE", events: [.I("A",0), .I("B",1), .I("D",3), .I("E",4), .M("C",0,2,"D"), .I("F",5)]),
(word: "BACDEF", events: [.M("B",2,1,"C"), .M("C",1,2,"B"), .M("E",5,4,"F"), .M("F",4,5,"E")]),
(word: "AB", events: [.D("C",2), .D("D",3), .D("E",4), .M("A",1,0,"B"), .D("F",5), .M("B",0,1,"A")]),
(word: "BACDE", events: [.I("C",2), .M("B",0,1,"A"), .I("D",3), .M("A",1,0,"B"), .I("E",4)]),
(word: "E", events: [.D("A",0), .D("C",2), .D("D",3), .D("E",4), .M("E",1,0,"B")]),
(word: "A", events: [.U("A",0,"E")]),
(word: "ABCDE", events: [.I("B",1), .I("C",2), .I("D",3), .I("E",4)]),
(word: "BA", events: [.D("C",2), .D("D",3), .M("A",1,0,"B"), .D("E",4), .M("B",0,1,"A")]),
(word: "A", events: [.D("A",0), .M("A",1,0,"B")]),
(word: "CAB", events: [.I("A",0), .I("B",1), .M("C",0,2,"A")]),
(word: "EA", events: [.D("B",1), .M("E",2,1,"C")]),
(word: "B", events: [.D("A",0), .M("B",1,0,"E")]),
]
for step in steps {
recorder.transactionExpectation = expectation(description: "expectation")
try dbQueue.inTransaction { db in
try synchronizePersons(db, step.word.characters.enumerated().map { Person(id: Int64($0), name: String($1)) })
return .commit
}
waitForExpectations(timeout: 1, handler: nil)
XCTAssertEqual(recorder.changes.count, step.events.count)
for (change, event) in zip(recorder.changes, step.events) {
XCTAssertTrue(event.match(name: change.record.name, event: change.event))
}
}
}
}
@@ -424,11 +663,11 @@ class FetchedRecordsControllerTests: GRDBTestCase {
func testRequestChange() {
assertNoError {
let dbQueue = try makeDatabaseQueue()
let request = Person.select(Column("name")).order(Column("name"))
let controller = try FetchedRecordsController<Person>(dbQueue, request: request)
let controller = try FetchedRecordsController<Person>(dbQueue, request: Person.order(Column("name")), compareRecordsByPrimaryKey: true)
let recorder = ChangesRecorder<Person>()
controller.trackChanges(
recordsWillChange: { recorder.controllerWillChange($0) },
event: { (controller, record, event) in recorder.controller(controller, didChangeRecord: record, withEvent: event) },
recordsDidChange: { recorder.controllerDidChange($0) })
try controller.performFetch()
@@ -449,8 +688,19 @@ class FetchedRecordsControllerTests: GRDBTestCase {
XCTAssertEqual(recorder.recordsBeforeChanges.count, 2)
XCTAssertEqual(recorder.recordsBeforeChanges.map { $0.name }, ["Arthur", "Barbara"])
XCTAssertEqual(recorder.recordsAfterChanges.count, 2)
XCTAssertEqual(recorder.recordsAfterChanges.map { $0.name }, ["Barbara", "Arthur"])
XCTAssertEqual(recorder.recordsOnFirstEvent.count, 2)
XCTAssertEqual(recorder.recordsOnFirstEvent.map { $0.name }, ["Barbara", "Arthur"])
XCTAssertEqual(recorder.changes.count, 1)
XCTAssertEqual(recorder.changes[0].record.id, 2)
XCTAssertEqual(recorder.changes[0].record.name, "Barbara")
switch recorder.changes[0].event {
case .move(let indexPath, let newIndexPath, let changes):
XCTAssertEqual(indexPath, IndexPath(indexes: [0, 1]))
XCTAssertEqual(newIndexPath, IndexPath(indexes: [0, 0]))
XCTAssertTrue(changes.isEmpty)
default:
XCTFail()
}
// Change request with SQL and arguments
recorder.transactionExpectation = expectation(description: "expectation")
@@ -459,49 +709,36 @@ class FetchedRecordsControllerTests: GRDBTestCase {
XCTAssertEqual(recorder.recordsBeforeChanges.count, 2)
XCTAssertEqual(recorder.recordsBeforeChanges.map { $0.name }, ["Barbara", "Arthur"])
XCTAssertEqual(recorder.recordsAfterChanges.count, 1)
XCTAssertEqual(recorder.recordsAfterChanges.map { $0.name }, ["Craig"])
// Change request with a different set of tracked columns
recorder.transactionExpectation = expectation(description: "expectation")
try controller.setRequest(Person.select(Column("name"), Column("email")).order(Column("name")))
waitForExpectations(timeout: 1, handler: nil)
XCTAssertEqual(recorder.recordsBeforeChanges.count, 1)
XCTAssertEqual(recorder.recordsBeforeChanges.map { $0.name }, ["Craig"])
XCTAssertEqual(recorder.recordsAfterChanges.count, 2)
XCTAssertEqual(recorder.recordsAfterChanges.map { $0.name }, ["Arthur", "Barbara"])
recorder.transactionExpectation = expectation(description: "expectation")
try dbQueue.inTransaction { db in
try db.execute("UPDATE persons SET email = ? WHERE name = ?", arguments: ["arthur@example.com", "Arthur"])
return .commit
XCTAssertEqual(recorder.recordsOnFirstEvent.count, 1)
XCTAssertEqual(recorder.recordsOnFirstEvent.map { $0.name }, ["Craig"])
XCTAssertEqual(recorder.changes.count, 2)
XCTAssertEqual(recorder.changes[0].record.id, 2)
XCTAssertEqual(recorder.changes[0].record.name, "Barbara")
XCTAssertEqual(recorder.changes[1].record.id, 1)
XCTAssertEqual(recorder.changes[1].record.name, "Craig")
switch recorder.changes[0].event {
case .deletion(let indexPath):
XCTAssertEqual(indexPath, IndexPath(indexes: [0, 0]))
default:
XCTFail()
}
waitForExpectations(timeout: 1, handler: nil)
XCTAssertEqual(recorder.recordsBeforeChanges.count, 2)
XCTAssertEqual(recorder.recordsBeforeChanges.map { $0.name }, ["Arthur", "Barbara"])
XCTAssertEqual(recorder.recordsAfterChanges.count, 2)
XCTAssertEqual(recorder.recordsAfterChanges.map { $0.name }, ["Arthur", "Barbara"])
recorder.transactionExpectation = expectation(description: "expectation")
try dbQueue.inTransaction { db in
try db.execute("UPDATE PERSONS SET EMAIL = ? WHERE NAME = ?", arguments: ["barbara@example.com", "Barbara"])
return .commit
switch recorder.changes[1].event {
case .move(let indexPath, let newIndexPath, let changes):
// TODO: is it really what we should expect? Wouldn't an update fit better?
// What does UITableView think?
XCTAssertEqual(indexPath, IndexPath(indexes: [0, 1]))
XCTAssertEqual(newIndexPath, IndexPath(indexes: [0, 0]))
XCTAssertEqual(changes, ["name": "Arthur".databaseValue])
default:
XCTFail()
}
waitForExpectations(timeout: 1, handler: nil)
XCTAssertEqual(recorder.recordsBeforeChanges.count, 2)
XCTAssertEqual(recorder.recordsBeforeChanges.map { $0.name }, ["Arthur", "Barbara"])
XCTAssertEqual(recorder.recordsAfterChanges.count, 2)
XCTAssertEqual(recorder.recordsAfterChanges.map { $0.name }, ["Arthur", "Barbara"])
}
}
func testSetCallbacksAfterUpdate() {
assertNoError {
let dbQueue = try makeDatabaseQueue()
let controller = try FetchedRecordsController<Person>(dbQueue, request: Person.order(Column("name")))
let controller = try FetchedRecordsController<Person>(dbQueue, request: Person.order(Column("name")), compareRecordsByPrimaryKey: true)
let recorder = ChangesRecorder<Person>()
try controller.performFetch()
@@ -516,19 +753,29 @@ class FetchedRecordsControllerTests: GRDBTestCase {
recorder.transactionExpectation = expectation(description: "expectation")
controller.trackChanges(
recordsWillChange: { recorder.controllerWillChange($0) },
event: { (controller, record, event) in recorder.controller(controller, didChangeRecord: record, withEvent: event) },
recordsDidChange: { recorder.controllerDidChange($0) })
waitForExpectations(timeout: 1, handler: nil)
XCTAssertEqual(recorder.recordsBeforeChanges.count, 0)
XCTAssertEqual(recorder.recordsAfterChanges.count, 1)
XCTAssertEqual(recorder.recordsAfterChanges.map { $0.name }, ["Arthur"])
XCTAssertEqual(recorder.recordsOnFirstEvent.count, 1)
XCTAssertEqual(recorder.recordsOnFirstEvent.map { $0.name }, ["Arthur"])
XCTAssertEqual(recorder.changes.count, 1)
XCTAssertEqual(recorder.changes[0].record.id, 1)
XCTAssertEqual(recorder.changes[0].record.name, "Arthur")
switch recorder.changes[0].event {
case .insertion(let indexPath):
XCTAssertEqual(indexPath, IndexPath(indexes: [0, 0]))
default:
XCTFail()
}
}
}
func testTrailingClosureCallback() {
assertNoError {
let dbQueue = try makeDatabaseQueue()
let controller = try FetchedRecordsController<Person>(dbQueue, request: Person.order(Column("name")))
let controller = try FetchedRecordsController<Person>(dbQueue, request: Person.order(Column("name")), compareRecordsByPrimaryKey: true)
var persons: [Person] = []
try controller.performFetch()
@@ -555,6 +802,7 @@ class FetchedRecordsControllerTests: GRDBTestCase {
controller.trackChanges(
fetchAlongside: { db in try Person.fetchCount(db) },
recordsWillChange: { (controller, count) in recorder.controllerWillChange(controller, count: count) },
event: { (controller, record, event) in recorder.controller(controller, didChangeRecord: record, withEvent: event) },
recordsDidChange: { (controller, count) in recorder.controllerDidChange(controller, count: count) })
try controller.performFetch()
@@ -636,12 +884,12 @@ private func synchronizePersons(_ db: Database, _ newPersons: [Person]) throws {
//
// We'll delete, insert or update persons, depending on their presence
// in either lists.
let steps = sortedMerge(
for mergeStep in sortedMerge(
left: databasePersons,
right: newPersons,
leftKey: { $0.id! },
rightKey: { $0.id! })
for mergeStep in steps {
{
switch mergeStep {
case .left(let databasePerson):
try databasePerson.delete(db)
@@ -657,28 +657,21 @@ class PrimaryKeyHiddenRowIDTests : GRDBTestCase {
}
let expectation = self.expectation(description: "expectation")
let controller: FetchedRecordsController<Person>
#if os(iOS)
controller = try FetchedRecordsController<Person>(dbQueue, request: Person.all(), compareRecordsByPrimaryKey: true)
var update = false
controller.trackChanges(
tableViewEvent: { (_, _, event) in
switch event {
case .update:
update = true
default:
break
}
},
recordsDidChange: { _ in
expectation.fulfill()
})
#else
controller = try FetchedRecordsController<Person>(dbQueue, request: Person.all())
controller.trackChanges { _ in
let controller =
try FetchedRecordsController<Person>(dbQueue, request: Person.all(), compareRecordsByPrimaryKey: true)
var update = false
controller.trackChanges(
event: { (_, _, event) in
switch event {
case .update:
update = true
default:
break
}
},
recordsDidChange: { _ in
expectation.fulfill()
}
#endif
})
try controller.performFetch()
try dbQueue.inDatabase { db in
person.name = "Barbara"
@@ -686,9 +679,7 @@ class PrimaryKeyHiddenRowIDTests : GRDBTestCase {
}
waitForExpectations(timeout: 1, handler: nil)
#if os(iOS)
XCTAssertTrue(update)
#endif
XCTAssertTrue(update)
}
}
}