diff --git a/GRDB.xcodeproj/project.pbxproj b/GRDB.xcodeproj/project.pbxproj index 90ffa4242..4720f0afe 100755 --- a/GRDB.xcodeproj/project.pbxproj +++ b/GRDB.xcodeproj/project.pbxproj @@ -35,12 +35,6 @@ 5605F1881C69111300235C62 /* DatabaseRegionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1861C69111300235C62 /* DatabaseRegionTests.swift */; }; 5605F18D1C6B1A8700235C62 /* SQLCollatedExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1891C6B1A8700235C62 /* SQLCollatedExpression.swift */; }; 5605F18E1C6B1A8700235C62 /* SQLCollatedExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1891C6B1A8700235C62 /* SQLCollatedExpression.swift */; }; - 5607148C227617690091BB10 /* FetchableRecord+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5607148B227617690091BB10 /* FetchableRecord+QueryInterface.swift */; }; - 5607148D227617690091BB10 /* FetchableRecord+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5607148B227617690091BB10 /* FetchableRecord+QueryInterface.swift */; }; - 5607148E227617690091BB10 /* FetchableRecord+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5607148B227617690091BB10 /* FetchableRecord+QueryInterface.swift */; }; - 560714962276177C0091BB10 /* Row+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560714952276177C0091BB10 /* Row+QueryInterface.swift */; }; - 560714972276177C0091BB10 /* Row+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560714952276177C0091BB10 /* Row+QueryInterface.swift */; }; - 560714982276177C0091BB10 /* Row+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560714952276177C0091BB10 /* Row+QueryInterface.swift */; }; 560714E3227DD0810091BB10 /* AssociationPrefetchingSQLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560714E2227DD0810091BB10 /* AssociationPrefetchingSQLTests.swift */; }; 560714E4227DD0810091BB10 /* AssociationPrefetchingSQLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560714E2227DD0810091BB10 /* AssociationPrefetchingSQLTests.swift */; }; 56071A411DB54ED000CA6E47 /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift */; }; @@ -287,18 +281,15 @@ 5653EB0320944C7C00F46237 /* BelongsToAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAF820944C7B00F46237 /* BelongsToAssociation.swift */; }; 5653EB0420944C7C00F46237 /* BelongsToAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAF820944C7B00F46237 /* BelongsToAssociation.swift */; }; 5653EB0520944C7C00F46237 /* BelongsToAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAF820944C7B00F46237 /* BelongsToAssociation.swift */; }; - 5653EB0620944C7C00F46237 /* ForeignKeyRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAF920944C7B00F46237 /* ForeignKeyRequest.swift */; }; - 5653EB0720944C7C00F46237 /* ForeignKeyRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAF920944C7B00F46237 /* ForeignKeyRequest.swift */; }; - 5653EB0820944C7C00F46237 /* ForeignKeyRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAF920944C7B00F46237 /* ForeignKeyRequest.swift */; }; + 5653EB0620944C7C00F46237 /* SQLForeignKeyRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAF920944C7B00F46237 /* SQLForeignKeyRequest.swift */; }; + 5653EB0720944C7C00F46237 /* SQLForeignKeyRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAF920944C7B00F46237 /* SQLForeignKeyRequest.swift */; }; + 5653EB0820944C7C00F46237 /* SQLForeignKeyRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAF920944C7B00F46237 /* SQLForeignKeyRequest.swift */; }; 5653EB0920944C7C00F46237 /* Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFA20944C7B00F46237 /* Association.swift */; }; 5653EB0A20944C7C00F46237 /* Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFA20944C7B00F46237 /* Association.swift */; }; 5653EB0B20944C7C00F46237 /* Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFA20944C7B00F46237 /* Association.swift */; }; 5653EB0C20944C7C00F46237 /* HasManyAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFB20944C7B00F46237 /* HasManyAssociation.swift */; }; 5653EB0D20944C7C00F46237 /* HasManyAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFB20944C7B00F46237 /* HasManyAssociation.swift */; }; 5653EB0E20944C7C00F46237 /* HasManyAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFB20944C7B00F46237 /* HasManyAssociation.swift */; }; - 5653EB1820944C7C00F46237 /* ForeignKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFF20944C7C00F46237 /* ForeignKey.swift */; }; - 5653EB1920944C7C00F46237 /* ForeignKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFF20944C7C00F46237 /* ForeignKey.swift */; }; - 5653EB1A20944C7C00F46237 /* ForeignKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EAFF20944C7C00F46237 /* ForeignKey.swift */; }; 5653EB2120944C7C00F46237 /* HasOneAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB0220944C7C00F46237 /* HasOneAssociation.swift */; }; 5653EB2220944C7C00F46237 /* HasOneAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB0220944C7C00F46237 /* HasOneAssociation.swift */; }; 5653EB2320944C7C00F46237 /* HasOneAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB0220944C7C00F46237 /* HasOneAssociation.swift */; }; @@ -352,6 +343,21 @@ 56553C131C3E906C00522B5C /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC3773F319C8CBB3004FCF85 /* GRDB.framework */; }; 5656A7FF22946B34001FF3FF /* ValueObservationQueryInterfaceRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A7F822946B33001FF3FF /* ValueObservationQueryInterfaceRequestTests.swift */; }; 5656A80022946B34001FF3FF /* ValueObservationQueryInterfaceRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A7F822946B33001FF3FF /* ValueObservationQueryInterfaceRequestTests.swift */; }; + 5656A81E2295B12F001FF3FF /* SQLAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A81D2295B12F001FF3FF /* SQLAssociation.swift */; }; + 5656A81F2295B12F001FF3FF /* SQLAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A81D2295B12F001FF3FF /* SQLAssociation.swift */; }; + 5656A8202295B12F001FF3FF /* SQLAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A81D2295B12F001FF3FF /* SQLAssociation.swift */; }; + 5656A8AD2295BFD7001FF3FF /* TableRecord+Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8A92295BFD5001FF3FF /* TableRecord+Association.swift */; }; + 5656A8AE2295BFD7001FF3FF /* TableRecord+Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8A92295BFD5001FF3FF /* TableRecord+Association.swift */; }; + 5656A8AF2295BFD7001FF3FF /* TableRecord+Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8A92295BFD5001FF3FF /* TableRecord+Association.swift */; }; + 5656A8B02295BFD7001FF3FF /* TableRecord+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8AA2295BFD6001FF3FF /* TableRecord+QueryInterfaceRequest.swift */; }; + 5656A8B12295BFD7001FF3FF /* TableRecord+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8AA2295BFD6001FF3FF /* TableRecord+QueryInterfaceRequest.swift */; }; + 5656A8B22295BFD7001FF3FF /* TableRecord+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8AA2295BFD6001FF3FF /* TableRecord+QueryInterfaceRequest.swift */; }; + 5656A8B32295BFD7001FF3FF /* Row+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8AB2295BFD6001FF3FF /* Row+QueryInterfaceRequest.swift */; }; + 5656A8B42295BFD7001FF3FF /* Row+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8AB2295BFD6001FF3FF /* Row+QueryInterfaceRequest.swift */; }; + 5656A8B52295BFD7001FF3FF /* Row+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8AB2295BFD6001FF3FF /* Row+QueryInterfaceRequest.swift */; }; + 5656A8B62295BFD7001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8AC2295BFD6001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift */; }; + 5656A8B72295BFD7001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8AC2295BFD6001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift */; }; + 5656A8B82295BFD7001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8AC2295BFD6001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift */; }; 5657AAB91D107001006283EF /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AAB81D107001006283EF /* NSData.swift */; }; 5657AABC1D107001006283EF /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AAB81D107001006283EF /* NSData.swift */; }; 5657AB0F1D10899D006283EF /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AB0E1D10899D006283EF /* URL.swift */; }; @@ -477,9 +483,9 @@ 568068311EBBA26100EFB8AA /* SQLRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568068301EBBA26100EFB8AA /* SQLRequestTests.swift */; }; 568068351EBBA26100EFB8AA /* SQLRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568068301EBBA26100EFB8AA /* SQLRequestTests.swift */; }; 568735A21CEDE16C009B9116 /* Betty.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = 5687359E1CEDE16C009B9116 /* Betty.jpeg */; }; - 568D131F2207213E00674B58 /* SQLSelectQueryGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568D13182207213E00674B58 /* SQLSelectQueryGenerator.swift */; }; - 568D13202207213E00674B58 /* SQLSelectQueryGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568D13182207213E00674B58 /* SQLSelectQueryGenerator.swift */; }; - 568D13212207213F00674B58 /* SQLSelectQueryGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568D13182207213E00674B58 /* SQLSelectQueryGenerator.swift */; }; + 568D131F2207213E00674B58 /* SQLQueryGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568D13182207213E00674B58 /* SQLQueryGenerator.swift */; }; + 568D13202207213E00674B58 /* SQLQueryGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568D13182207213E00674B58 /* SQLQueryGenerator.swift */; }; + 568D13212207213F00674B58 /* SQLQueryGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568D13182207213E00674B58 /* SQLQueryGenerator.swift */; }; 5690AFD82120589A001530EA /* InsertRecordCodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5690AFD72120589A001530EA /* InsertRecordCodableTests.swift */; }; 5690AFD92120589A001530EA /* InsertRecordCodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5690AFD72120589A001530EA /* InsertRecordCodableTests.swift */; }; 5690AFDB212058CB001530EA /* FetchRecordCodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5690AFDA212058CB001530EA /* FetchRecordCodableTests.swift */; }; @@ -656,9 +662,9 @@ 56CEB5011EAA2F4D00BFAF62 /* FTS4.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB4F91EAA2F4D00BFAF62 /* FTS4.swift */; }; 56CEB5041EAA2F4D00BFAF62 /* FTS4.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB4F91EAA2F4D00BFAF62 /* FTS4.swift */; }; 56CEB5071EAA2F4D00BFAF62 /* FTS4.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB4F91EAA2F4D00BFAF62 /* FTS4.swift */; }; - 56CEB5111EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5101EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift */; }; - 56CEB5141EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5101EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift */; }; - 56CEB5171EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5101EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift */; }; + 56CEB5111EAA324B00BFAF62 /* FTS3+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5101EAA324B00BFAF62 /* FTS3+QueryInterface.swift */; }; + 56CEB5141EAA324B00BFAF62 /* FTS3+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5101EAA324B00BFAF62 /* FTS3+QueryInterface.swift */; }; + 56CEB5171EAA324B00BFAF62 /* FTS3+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5101EAA324B00BFAF62 /* FTS3+QueryInterface.swift */; }; 56CEB5191EAA328900BFAF62 /* FTS5+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5181EAA328900BFAF62 /* FTS5+QueryInterface.swift */; }; 56CEB51C1EAA328900BFAF62 /* FTS5+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5181EAA328900BFAF62 /* FTS5+QueryInterface.swift */; }; 56CEB51F1EAA328900BFAF62 /* FTS5+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5181EAA328900BFAF62 /* FTS5+QueryInterface.swift */; }; @@ -770,9 +776,9 @@ 56D91AA92205F2F100770D8D /* DatabasePromise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D91AA82205F2F000770D8D /* DatabasePromise.swift */; }; 56D91AAA2205F2F100770D8D /* DatabasePromise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D91AA82205F2F000770D8D /* DatabasePromise.swift */; }; 56D91AAB2205F2F100770D8D /* DatabasePromise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D91AA82205F2F000770D8D /* DatabasePromise.swift */; }; - 56D91AB02205F8AC00770D8D /* SQLSelectQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D91AAF2205F8AC00770D8D /* SQLSelectQuery.swift */; }; - 56D91AB12205F8AC00770D8D /* SQLSelectQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D91AAF2205F8AC00770D8D /* SQLSelectQuery.swift */; }; - 56D91AB22205F8AC00770D8D /* SQLSelectQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D91AAF2205F8AC00770D8D /* SQLSelectQuery.swift */; }; + 56D91AB02205F8AC00770D8D /* SQLQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D91AAF2205F8AC00770D8D /* SQLQuery.swift */; }; + 56D91AB12205F8AC00770D8D /* SQLQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D91AAF2205F8AC00770D8D /* SQLQuery.swift */; }; + 56D91AB22205F8AC00770D8D /* SQLQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D91AAF2205F8AC00770D8D /* SQLQuery.swift */; }; 56DAA2D21DE99DAB006E10C8 /* DatabaseCursorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56DAA2D11DE99DAB006E10C8 /* DatabaseCursorTests.swift */; }; 56DAA2D61DE99DAB006E10C8 /* DatabaseCursorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56DAA2D11DE99DAB006E10C8 /* DatabaseCursorTests.swift */; }; 56DAA2DB1DE9C827006E10C8 /* Cursor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56DAA2DA1DE9C827006E10C8 /* Cursor.swift */; }; @@ -959,8 +965,6 @@ 5605F1581C672E4000235C62 /* StandardLibrary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StandardLibrary.swift; sourceTree = ""; }; 5605F1861C69111300235C62 /* DatabaseRegionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseRegionTests.swift; sourceTree = ""; }; 5605F1891C6B1A8700235C62 /* SQLCollatedExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLCollatedExpression.swift; sourceTree = ""; }; - 5607148B227617690091BB10 /* FetchableRecord+QueryInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FetchableRecord+QueryInterface.swift"; sourceTree = ""; }; - 560714952276177C0091BB10 /* Row+QueryInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Row+QueryInterface.swift"; sourceTree = ""; }; 560714E2227DD0810091BB10 /* AssociationPrefetchingSQLTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssociationPrefetchingSQLTests.swift; sourceTree = ""; }; 5607EFD21BB8254800605DE3 /* TransactionObserverTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransactionObserverTests.swift; sourceTree = ""; }; 560A37A31C8F625000949E71 /* DatabasePool.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabasePool.swift; sourceTree = ""; }; @@ -1062,16 +1066,20 @@ 5653EAD420944B4E00F46237 /* AssociationBelongsToDecodableRecordTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationBelongsToDecodableRecordTests.swift; sourceTree = ""; }; 5653EAD520944B4F00F46237 /* AssociationParallelSQLTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationParallelSQLTests.swift; sourceTree = ""; }; 5653EAF820944C7B00F46237 /* BelongsToAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BelongsToAssociation.swift; sourceTree = ""; }; - 5653EAF920944C7B00F46237 /* ForeignKeyRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForeignKeyRequest.swift; sourceTree = ""; }; + 5653EAF920944C7B00F46237 /* SQLForeignKeyRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLForeignKeyRequest.swift; sourceTree = ""; }; 5653EAFA20944C7B00F46237 /* Association.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Association.swift; sourceTree = ""; }; 5653EAFB20944C7B00F46237 /* HasManyAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HasManyAssociation.swift; sourceTree = ""; }; - 5653EAFF20944C7C00F46237 /* ForeignKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForeignKey.swift; sourceTree = ""; }; 5653EB0220944C7C00F46237 /* HasOneAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HasOneAssociation.swift; sourceTree = ""; }; 5653EB242094A14400F46237 /* QueryInterfaceRequest+Association.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "QueryInterfaceRequest+Association.swift"; sourceTree = ""; }; 5653EC0B2098738B00F46237 /* SQLGenerationContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLGenerationContext.swift; sourceTree = ""; }; 565490A01D5A4798005622CB /* GRDB.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GRDB.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 56553C181C3E906C00522B5C /* GRDBOSXCrashTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBOSXCrashTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5656A7F822946B33001FF3FF /* ValueObservationQueryInterfaceRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationQueryInterfaceRequestTests.swift; sourceTree = ""; }; + 5656A81D2295B12F001FF3FF /* SQLAssociation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SQLAssociation.swift; sourceTree = ""; }; + 5656A8A92295BFD5001FF3FF /* TableRecord+Association.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "TableRecord+Association.swift"; sourceTree = ""; }; + 5656A8AA2295BFD6001FF3FF /* TableRecord+QueryInterfaceRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "TableRecord+QueryInterfaceRequest.swift"; sourceTree = ""; }; + 5656A8AB2295BFD6001FF3FF /* Row+QueryInterfaceRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Row+QueryInterfaceRequest.swift"; sourceTree = ""; }; + 5656A8AC2295BFD6001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FetchableRecord+QueryInterfaceRequest.swift"; sourceTree = ""; }; 5657AAB81D107001006283EF /* NSData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSData.swift; sourceTree = ""; }; 5657AB0E1D10899D006283EF /* URL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = URL.swift; sourceTree = ""; }; 5657AB2F1D108BA9006283EF /* FoundationDataTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FoundationDataTests.swift; sourceTree = ""; }; @@ -1134,7 +1142,7 @@ 567F45A71F888B2600030B59 /* TruncateOptimizationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TruncateOptimizationTests.swift; sourceTree = ""; }; 568068301EBBA26100EFB8AA /* SQLRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLRequestTests.swift; sourceTree = ""; }; 5687359E1CEDE16C009B9116 /* Betty.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = Betty.jpeg; sourceTree = ""; }; - 568D13182207213E00674B58 /* SQLSelectQueryGenerator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLSelectQueryGenerator.swift; sourceTree = ""; }; + 568D13182207213E00674B58 /* SQLQueryGenerator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLQueryGenerator.swift; sourceTree = ""; }; 5690AFD72120589A001530EA /* InsertRecordCodableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InsertRecordCodableTests.swift; sourceTree = ""; }; 5690AFDA212058CB001530EA /* FetchRecordCodableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchRecordCodableTests.swift; sourceTree = ""; }; 5690C3251D23E6D800E59934 /* FoundationDateComponentsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FoundationDateComponentsTests.swift; sourceTree = ""; }; @@ -1265,7 +1273,7 @@ 56CEB4F01EAA2EFA00BFAF62 /* FetchableRecord.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchableRecord.swift; sourceTree = ""; }; 56CEB4F81EAA2F4D00BFAF62 /* FTS3.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS3.swift; sourceTree = ""; }; 56CEB4F91EAA2F4D00BFAF62 /* FTS4.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS4.swift; sourceTree = ""; }; - 56CEB5101EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FTS3+QueryInterfaceRequest.swift"; sourceTree = ""; }; + 56CEB5101EAA324B00BFAF62 /* FTS3+QueryInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FTS3+QueryInterface.swift"; sourceTree = ""; }; 56CEB5181EAA328900BFAF62 /* FTS5+QueryInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FTS5+QueryInterface.swift"; sourceTree = ""; }; 56CEB5401EAA359A00BFAF62 /* Column.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Column.swift; sourceTree = ""; }; 56CEB5411EAA359A00BFAF62 /* SQLExpressible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLExpressible.swift; sourceTree = ""; }; @@ -1278,7 +1286,7 @@ 56D51CFF1EA789FA0074638A /* FetchableRecord+TableRecord.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FetchableRecord+TableRecord.swift"; sourceTree = ""; }; 56D91AA12205E03700770D8D /* SQLRelation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLRelation.swift; sourceTree = ""; }; 56D91AA82205F2F000770D8D /* DatabasePromise.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabasePromise.swift; sourceTree = ""; }; - 56D91AAF2205F8AC00770D8D /* SQLSelectQuery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLSelectQuery.swift; sourceTree = ""; }; + 56D91AAF2205F8AC00770D8D /* SQLQuery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLQuery.swift; sourceTree = ""; }; 56DAA2D11DE99DAB006E10C8 /* DatabaseCursorTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseCursorTests.swift; sourceTree = ""; }; 56DAA2DA1DE9C827006E10C8 /* Cursor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Cursor.swift; sourceTree = ""; }; 56DE7B101C3D93ED00861EB8 /* StatementArgumentsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementArgumentsTests.swift; sourceTree = ""; }; @@ -1588,33 +1596,17 @@ 56300B6D1C53F592005A543B /* QueryInterface */ = { isa = PBXGroup; children = ( - 5653EAF720944BC900F46237 /* Association */, - 56CEB5401EAA359A00BFAF62 /* Column.swift */, - 56D91AA82205F2F000770D8D /* DatabasePromise.swift */, - 5607148B227617690091BB10 /* FetchableRecord+QueryInterface.swift */, - 56CEB5101EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift */, + 5656A8AC2295BFD6001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift */, + 56CEB5101EAA324B00BFAF62 /* FTS3+QueryInterface.swift */, 56CEB5181EAA328900BFAF62 /* FTS5+QueryInterface.swift */, - 56300B6F1C53F592005A543B /* QueryInterfaceRequest.swift */, - 5653EB242094A14400F46237 /* QueryInterfaceRequest+Association.swift */, - 5616AAF0207CD45E00AC3664 /* RequestProtocols.swift */, - 560714952276177C0091BB10 /* Row+QueryInterface.swift */, - 5605F1891C6B1A8700235C62 /* SQLCollatedExpression.swift */, - 566475991D97D8A000FF74B8 /* SQLCollection.swift */, - 56CEB5411EAA359A00BFAF62 /* SQLExpressible.swift */, - 56CEB5421EAA359A00BFAF62 /* SQLExpression.swift */, - 56FC98771D969DEF00E3C842 /* SQLExpression+QueryInterface.swift */, - 5653EC0B2098738B00F46237 /* SQLGenerationContext.swift */, + 5656A8182295B044001FF3FF /* Request */, + 5656A8AB2295BFD6001FF3FF /* Row+QueryInterfaceRequest.swift */, + 5656A8142295AF75001FF3FF /* Schema */, + 5656A8172295B00E001FF3FF /* SQL */, + 5656A8162295AFD6001FF3FF /* SQLGeneration */, 56E9FACA221046FD00C703A8 /* SQLInterpolation+QueryInterface.swift */, - 56CEB5431EAA359A00BFAF62 /* SQLOrdering.swift */, - 56D91AA12205E03700770D8D /* SQLRelation.swift */, - 56CEB5441EAA359A00BFAF62 /* SQLSelectable.swift */, - 566475A11D9810A400FF74B8 /* SQLSelectable+QueryInterface.swift */, - 56D91AAF2205F8AC00770D8D /* SQLSelectQuery.swift */, - 568D13182207213E00674B58 /* SQLSelectQueryGenerator.swift */, - 566475B91D981AD200FF74B8 /* SQLSpecificExpressible+QueryInterface.swift */, - 566475C91D981D5E00FF74B8 /* Support */, - 566AD8B11D5318F4002EC1A8 /* TableDefinition.swift */, - 5698AC771DA37DCB0056AF8C /* VirtualTableModule.swift */, + 5656A8A92295BFD5001FF3FF /* TableRecord+Association.swift */, + 5656A8AA2295BFD6001FF3FF /* TableRecord+QueryInterfaceRequest.swift */, ); path = QueryInterface; sourceTree = ""; @@ -1694,8 +1686,6 @@ 5653EAFA20944C7B00F46237 /* Association.swift */, 563EF42C2161180D007DAACD /* AssociationAggregate.swift */, 5653EAF820944C7B00F46237 /* BelongsToAssociation.swift */, - 5653EAFF20944C7C00F46237 /* ForeignKey.swift */, - 5653EAF920944C7B00F46237 /* ForeignKeyRequest.swift */, 5653EAFB20944C7B00F46237 /* HasManyAssociation.swift */, 56959628222C462D002CB7C9 /* HasManyThroughAssociation.swift */, 5653EB0220944C7C00F46237 /* HasOneAssociation.swift */, @@ -1704,6 +1694,59 @@ path = Association; sourceTree = ""; }; + 5656A8142295AF75001FF3FF /* Schema */ = { + isa = PBXGroup; + children = ( + 566AD8B11D5318F4002EC1A8 /* TableDefinition.swift */, + 5698AC771DA37DCB0056AF8C /* VirtualTableModule.swift */, + ); + path = Schema; + sourceTree = ""; + }; + 5656A8162295AFD6001FF3FF /* SQLGeneration */ = { + isa = PBXGroup; + children = ( + 5653EC0B2098738B00F46237 /* SQLGenerationContext.swift */, + 568D13182207213E00674B58 /* SQLQueryGenerator.swift */, + ); + path = SQLGeneration; + sourceTree = ""; + }; + 5656A8172295B00E001FF3FF /* SQL */ = { + isa = PBXGroup; + children = ( + 56CEB5401EAA359A00BFAF62 /* Column.swift */, + 56D91AA82205F2F000770D8D /* DatabasePromise.swift */, + 5656A81D2295B12F001FF3FF /* SQLAssociation.swift */, + 5605F1891C6B1A8700235C62 /* SQLCollatedExpression.swift */, + 566475991D97D8A000FF74B8 /* SQLCollection.swift */, + 56CEB5411EAA359A00BFAF62 /* SQLExpressible.swift */, + 56CEB5421EAA359A00BFAF62 /* SQLExpression.swift */, + 56FC98771D969DEF00E3C842 /* SQLExpression+QueryInterface.swift */, + 5653EAF920944C7B00F46237 /* SQLForeignKeyRequest.swift */, + 566475CA1D981D5E00FF74B8 /* SQLFunctions.swift */, + 566475CB1D981D5E00FF74B8 /* SQLOperators.swift */, + 56CEB5431EAA359A00BFAF62 /* SQLOrdering.swift */, + 56D91AAF2205F8AC00770D8D /* SQLQuery.swift */, + 56D91AA12205E03700770D8D /* SQLRelation.swift */, + 56CEB5441EAA359A00BFAF62 /* SQLSelectable.swift */, + 566475A11D9810A400FF74B8 /* SQLSelectable+QueryInterface.swift */, + 566475B91D981AD200FF74B8 /* SQLSpecificExpressible+QueryInterface.swift */, + ); + path = SQL; + sourceTree = ""; + }; + 5656A8182295B044001FF3FF /* Request */ = { + isa = PBXGroup; + children = ( + 5653EAF720944BC900F46237 /* Association */, + 56300B6F1C53F592005A543B /* QueryInterfaceRequest.swift */, + 5653EB242094A14400F46237 /* QueryInterfaceRequest+Association.swift */, + 5616AAF0207CD45E00AC3664 /* RequestProtocols.swift */, + ); + path = Request; + sourceTree = ""; + }; 5659F4861EA8D94E004A4992 /* Utils */ = { isa = PBXGroup; children = ( @@ -1718,15 +1761,6 @@ path = Utils; sourceTree = ""; }; - 566475C91D981D5E00FF74B8 /* Support */ = { - isa = PBXGroup; - children = ( - 566475CA1D981D5E00FF74B8 /* SQLFunctions.swift */, - 566475CB1D981D5E00FF74B8 /* SQLOperators.swift */, - ); - path = Support; - sourceTree = ""; - }; 5674A7251F30A8EF0095F066 /* FetchableRecord */ = { isa = PBXGroup; children = ( @@ -2573,8 +2607,10 @@ files = ( 5616AAF3207CD45E00AC3664 /* RequestProtocols.swift in Sources */, 56B964BF1DA51D0A0002DA19 /* FTS5Pattern.swift in Sources */, + 5656A8B82295BFD7001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift in Sources */, 56D51D061EA789FA0074638A /* FetchableRecord+TableRecord.swift in Sources */, 565490CE1D5AE252005622CB /* NSNull.swift in Sources */, + 5656A8202295B12F001FF3FF /* SQLAssociation.swift in Sources */, 565490E41D5AE252005622CB /* TableRecord.swift in Sources */, 564CE5AE21B8FAB400652B19 /* DatabaseRegionObservation.swift in Sources */, 565490CF1D5AE252005622CB /* NSNumber.swift in Sources */, @@ -2585,8 +2621,9 @@ 565490C11D5AE236005622CB /* FetchRequest.swift in Sources */, 5613ED4621A95B2C00DC7A68 /* ValueReducer.swift in Sources */, 5698AD1C1DAAD17F0056AF8C /* FTS5Tokenizer.swift in Sources */, - 56CEB5171EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift in Sources */, - 56D91AB22205F8AC00770D8D /* SQLSelectQuery.swift in Sources */, + 56CEB5171EAA324B00BFAF62 /* FTS3+QueryInterface.swift in Sources */, + 5656A8B22295BFD7001FF3FF /* TableRecord+QueryInterfaceRequest.swift in Sources */, + 56D91AB22205F8AC00770D8D /* SQLQuery.swift in Sources */, 56B964B71DA51D010002DA19 /* FTS5TokenizerDescriptor.swift in Sources */, 5613ED5221A95C6D00DC7A68 /* ValueObservation+DatabaseValueConvertible.swift in Sources */, 5653EB0B20944C7C00F46237 /* Association.swift in Sources */, @@ -2606,6 +2643,7 @@ 563B06AD217EF0CC00B38F35 /* ValueObservation.swift in Sources */, 5674A6EF1F307F0E0095F066 /* DatabaseValueConvertible+Encodable.swift in Sources */, 565490D81D5AE252005622CB /* DatabaseMigrator.swift in Sources */, + 5656A8AF2295BFD7001FF3FF /* TableRecord+Association.swift in Sources */, 56CEB5601EAA359A00BFAF62 /* SQLOrdering.swift in Sources */, 565490C21D5AE236005622CB /* Row.swift in Sources */, 565490C71D5AE236005622CB /* StatementColumnConvertible.swift in Sources */, @@ -2618,11 +2656,8 @@ 5613ED4A21A95C1200DC7A68 /* ValueObservation+Row.swift in Sources */, 565490D51D5AE252005622CB /* DatabaseValueConvertible+RawRepresentable.swift in Sources */, 565490C51D5AE236005622CB /* SerializedDatabase.swift in Sources */, - 560714982276177C0091BB10 /* Row+QueryInterface.swift in Sources */, 5698AC7E1DA37DCB0056AF8C /* VirtualTableModule.swift in Sources */, 564CE52221B3129A00652B19 /* ValueObservation+MapReducer.swift in Sources */, - 5653EB1A20944C7C00F46237 /* ForeignKey.swift in Sources */, - 5607148E227617690091BB10 /* FetchableRecord+QueryInterface.swift in Sources */, 5698AC3D1D9E5A590056AF8C /* FTS3Pattern.swift in Sources */, 563EF45D2163309F007DAACD /* Inflections.swift in Sources */, 569D6DE0220EF9E100A058A9 /* SQLInterpolation.swift in Sources */, @@ -2661,7 +2696,7 @@ 5671FC261DA3CAC9003BF4FF /* FTS3TokenizerDescriptor.swift in Sources */, 5653EC142098738B00F46237 /* SQLGenerationContext.swift in Sources */, 56CEB5521EAA359A00BFAF62 /* SQLExpressible.swift in Sources */, - 568D13212207213F00674B58 /* SQLSelectQueryGenerator.swift in Sources */, + 568D13212207213F00674B58 /* SQLQueryGenerator.swift in Sources */, 565490DB1D5AE252005622CB /* SQLCollatedExpression.swift in Sources */, 5674A7071F307FCD0095F066 /* DatabaseValueConvertible+ReferenceConvertible.swift in Sources */, 565490C61D5AE236005622CB /* Statement.swift in Sources */, @@ -2688,6 +2723,7 @@ 565490CB1D5AE252005622CB /* (null) in Sources */, 563EF417215F87EB007DAACD /* OrderedDictionary.swift in Sources */, 565490D61D5AE252005622CB /* StandardLibrary.swift in Sources */, + 5656A8B52295BFD7001FF3FF /* Row+QueryInterfaceRequest.swift in Sources */, 565490B81D5AE236005622CB /* DatabaseError.swift in Sources */, 564CE4D821B2DEB600652B19 /* ValueObservation+CompactMap.swift in Sources */, 56DAA2E11DE9C827006E10C8 /* Cursor.swift in Sources */, @@ -2697,7 +2733,7 @@ 563EF42F2161180D007DAACD /* AssociationAggregate.swift in Sources */, 565490BA1D5AE236005622CB /* DatabaseQueue.swift in Sources */, 565490CD1D5AE252005622CB /* Date.swift in Sources */, - 5653EB0820944C7C00F46237 /* ForeignKeyRequest.swift in Sources */, + 5653EB0820944C7C00F46237 /* SQLForeignKeyRequest.swift in Sources */, 565490BE1D5AE236005622CB /* DatabaseValue.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2726,6 +2762,7 @@ 563EF42E2161180D007DAACD /* AssociationAggregate.swift in Sources */, 56BB6EAC1D3009B100A1CA52 /* SchedulingWatchdog.swift in Sources */, 56300B791C53F592005A543B /* QueryInterfaceRequest.swift in Sources */, + 5656A8B12295BFD7001FF3FF /* TableRecord+QueryInterfaceRequest.swift in Sources */, 56CEB5561EAA359A00BFAF62 /* SQLExpression.swift in Sources */, 5674A6F91F307F600095F066 /* EncodableRecord+Encodable.swift in Sources */, 5605F18E1C6B1A8700235C62 /* SQLCollatedExpression.swift in Sources */, @@ -2740,16 +2777,17 @@ 5605F1641C672E4000235C62 /* Date.swift in Sources */, 5613ED4921A95C1200DC7A68 /* ValueObservation+Row.swift in Sources */, 566B91361FA4D3810012D5B0 /* TransactionObserver.swift in Sources */, + 5656A8B42295BFD7001FF3FF /* Row+QueryInterfaceRequest.swift in Sources */, 564CE43221AA901800652B19 /* ValueObserver.swift in Sources */, 5605F1721C672E4000235C62 /* DatabaseValueConvertible+RawRepresentable.swift in Sources */, - 56CEB5141EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift in Sources */, + 56CEB5141EAA324B00BFAF62 /* FTS3+QueryInterface.swift in Sources */, 566475CF1D981D5E00FF74B8 /* SQLFunctions.swift in Sources */, 5659F49B1EA8D989004A4992 /* Pool.swift in Sources */, 5653EB2220944C7C00F46237 /* HasOneAssociation.swift in Sources */, 56CEB51C1EAA328900BFAF62 /* FTS5+QueryInterface.swift in Sources */, 5698AC3A1D9E5A590056AF8C /* FTS3Pattern.swift in Sources */, 5664759D1D97D8A000FF74B8 /* SQLCollection.swift in Sources */, - 568D13202207213E00674B58 /* SQLSelectQueryGenerator.swift in Sources */, + 568D13202207213E00674B58 /* SQLQueryGenerator.swift in Sources */, 5674048A1CEF84C8003ED5CC /* RowAdapter.swift in Sources */, 563EF416215F87EB007DAACD /* OrderedDictionary.swift in Sources */, 563363C51C942C37000BE133 /* DatabaseWriter.swift in Sources */, @@ -2766,15 +2804,16 @@ 560D92411C672C3E00F4F92B /* DatabaseValueConvertible.swift in Sources */, 566475BD1D981AD200FF74B8 /* SQLSpecificExpressible+QueryInterface.swift in Sources */, 56A238A51B9C753B0082EB20 /* Record.swift in Sources */, + 5656A8B72295BFD7001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift in Sources */, 5671FC231DA3CAC9003BF4FF /* FTS3TokenizerDescriptor.swift in Sources */, 56D51D031EA789FA0074638A /* FetchableRecord+TableRecord.swift in Sources */, 560D924C1C672C4B00F4F92B /* TableRecord.swift in Sources */, 569BBA4F229170F900478429 /* Inflections+English.swift in Sources */, + 5656A81F2295B12F001FF3FF /* SQLAssociation.swift in Sources */, 5617294F223533F40006E219 /* EncodableRecord.swift in Sources */, 564CE52121B3129A00652B19 /* ValueObservation+MapReducer.swift in Sources */, 5653EC132098738B00F46237 /* SQLGenerationContext.swift in Sources */, 5657AB121D10899D006283EF /* URL.swift in Sources */, - 560714972276177C0091BB10 /* Row+QueryInterface.swift in Sources */, 5616AAF2207CD45E00AC3664 /* RequestProtocols.swift in Sources */, 5659F48B1EA8D94E004A4992 /* Utils.swift in Sources */, 56A2387C1B9C75030082EB20 /* Configuration.swift in Sources */, @@ -2784,7 +2823,7 @@ 56AE64132229A53700AD1B0B /* HasOneThroughAssociation.swift in Sources */, 56A2388C1B9C75030082EB20 /* Statement.swift in Sources */, 5659F4931EA8D964004A4992 /* ReadWriteBox.swift in Sources */, - 56D91AB12205F8AC00770D8D /* SQLSelectQuery.swift in Sources */, + 56D91AB12205F8AC00770D8D /* SQLQuery.swift in Sources */, 56B7F43B1BEB42D500E39BBF /* Migration.swift in Sources */, 5690C3431D23E82A00E59934 /* Data.swift in Sources */, 5674A7001F307F600095F066 /* FetchableRecord+Decodable.swift in Sources */, @@ -2800,10 +2839,10 @@ 5605F15E1C672E4000235C62 /* DatabaseDateComponents.swift in Sources */, 5695962A222C462D002CB7C9 /* HasManyThroughAssociation.swift in Sources */, 563363C11C942C04000BE133 /* DatabaseReader.swift in Sources */, - 5653EB1920944C7C00F46237 /* ForeignKey.swift in Sources */, 5659F4A31EA8D997004A4992 /* Result.swift in Sources */, 56B964BC1DA51D0A0002DA19 /* FTS5Pattern.swift in Sources */, 5605F1661C672E4000235C62 /* NSNull.swift in Sources */, + 5656A8AE2295BFD7001FF3FF /* TableRecord+Association.swift in Sources */, 569EF0E3200D2D8400A9FA45 /* DatabaseRegion.swift in Sources */, 56A238841B9C75030082EB20 /* DatabaseQueue.swift in Sources */, 563B06AC217EF0CC00B38F35 /* ValueObservation.swift in Sources */, @@ -2831,7 +2870,7 @@ 5613ED3621A95A5C00DC7A68 /* ValueObservation+Map.swift in Sources */, 566475A51D9810A400FF74B8 /* SQLSelectable+QueryInterface.swift in Sources */, 56E9FAD8221053DD00C703A8 /* SQLLiteral.swift in Sources */, - 5653EB0720944C7C00F46237 /* ForeignKeyRequest.swift in Sources */, + 5653EB0720944C7C00F46237 /* SQLForeignKeyRequest.swift in Sources */, 5657AABC1D107001006283EF /* NSData.swift in Sources */, 31A778841C6A4E0600F507F6 /* FetchedRecordsController.swift in Sources */, 5613ED4021A95A8B00DC7A68 /* ValueObservation+Combine.swift in Sources */, @@ -2844,7 +2883,6 @@ 564F9C311F07611600877A00 /* DatabaseFunction.swift in Sources */, 564CE59E21B7A8B500652B19 /* ValueObservation+DistinctUntilChanged.swift in Sources */, 56B964A01DA51B4C0002DA19 /* FTS5.swift in Sources */, - 5607148D227617690091BB10 /* FetchableRecord+QueryInterface.swift in Sources */, 5674A6F01F307F0E0095F066 /* DatabaseValueConvertible+Encodable.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -3252,9 +3290,10 @@ buildActionMask = 2147483647; files = ( 563EF42D2161180D007DAACD /* AssociationAggregate.swift in Sources */, - 56D91AB02205F8AC00770D8D /* SQLSelectQuery.swift in Sources */, + 56D91AB02205F8AC00770D8D /* SQLQuery.swift in Sources */, 5613ED4C21A95C4300DC7A68 /* ValueObservation+FetchableRecord.swift in Sources */, 5616AAF1207CD45E00AC3664 /* RequestProtocols.swift in Sources */, + 5656A8B02295BFD7001FF3FF /* TableRecord+QueryInterfaceRequest.swift in Sources */, 5613ED4421A95B2C00DC7A68 /* ValueReducer.swift in Sources */, 5636E9BC1D22574100B9B05F /* FetchRequest.swift in Sources */, 56BB6EA91D3009B100A1CA52 /* SchedulingWatchdog.swift in Sources */, @@ -3263,12 +3302,13 @@ 566B91231FA4CF810012D5B0 /* Database+Schema.swift in Sources */, 5613ED3F21A95A8B00DC7A68 /* ValueObservation+Combine.swift in Sources */, 563B06AB217EF0CC00B38F35 /* ValueObservation.swift in Sources */, - 56CEB5111EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift in Sources */, + 56CEB5111EAA324B00BFAF62 /* FTS3+QueryInterface.swift in Sources */, 5659F4901EA8D964004A4992 /* ReadWriteBox.swift in Sources */, 566A841A2041146100E50BFD /* DatabaseSnapshot.swift in Sources */, 569EF0E2200D2D8400A9FA45 /* DatabaseRegion.swift in Sources */, 56CEB4F11EAA2EFA00BFAF62 /* FetchableRecord.swift in Sources */, 56D91AA22205E03700770D8D /* SQLRelation.swift in Sources */, + 5656A8B32295BFD7001FF3FF /* Row+QueryInterfaceRequest.swift in Sources */, 56300B781C53F592005A543B /* QueryInterfaceRequest.swift in Sources */, 5605F18D1C6B1A8700235C62 /* SQLCollatedExpression.swift in Sources */, 5613ED5421A95DD000DC7A68 /* ValueObservation+Count.swift in Sources */, @@ -3295,15 +3335,16 @@ 5674A6F41F307F600095F066 /* EncodableRecord+Encodable.swift in Sources */, 56CEB54C1EAA359A00BFAF62 /* SQLExpressible.swift in Sources */, 5664759A1D97D8A000FF74B8 /* SQLCollection.swift in Sources */, + 5656A8B62295BFD7001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift in Sources */, 567404881CEF84C8003ED5CC /* RowAdapter.swift in Sources */, 5653EB0320944C7C00F46237 /* BelongsToAssociation.swift in Sources */, 563363C41C942C37000BE133 /* DatabaseWriter.swift in Sources */, 569BBA4E229170F800478429 /* Inflections+English.swift in Sources */, + 5656A81E2295B12F001FF3FF /* SQLAssociation.swift in Sources */, 5617294E223533F40006E219 /* EncodableRecord.swift in Sources */, 5698AD181DAAD17A0056AF8C /* FTS5Tokenizer.swift in Sources */, 56B964B11DA51D010002DA19 /* FTS5TokenizerDescriptor.swift in Sources */, 560A37A71C8FF6E500949E71 /* SerializedDatabase.swift in Sources */, - 560714962276177C0091BB10 /* Row+QueryInterface.swift in Sources */, 5653EB252094A14400F46237 /* QueryInterfaceRequest+Association.swift in Sources */, 5605F1691C672E4000235C62 /* NSString.swift in Sources */, 560D92401C672C3E00F4F92B /* DatabaseValueConvertible.swift in Sources */, @@ -3333,13 +3374,14 @@ 5613ED3521A95A5C00DC7A68 /* ValueObservation+Map.swift in Sources */, 566B912B1FA4D0CC0012D5B0 /* StatementAuthorizer.swift in Sources */, 56A2388B1B9C75030082EB20 /* Statement.swift in Sources */, + 5656A8AD2295BFD7001FF3FF /* TableRecord+Association.swift in Sources */, 5690C3401D23E82A00E59934 /* Data.swift in Sources */, 5659F4881EA8D94E004A4992 /* Utils.swift in Sources */, 56FC98781D969DEF00E3C842 /* SQLExpression+QueryInterface.swift in Sources */, 56A238931B9C750B0082EB20 /* DatabaseMigrator.swift in Sources */, 5695311F1C907A8C00CF1A2B /* DatabaseSchemaCache.swift in Sources */, 569D6DDE220EF9E100A058A9 /* SQLInterpolation.swift in Sources */, - 568D131F2207213E00674B58 /* SQLSelectQueryGenerator.swift in Sources */, + 568D131F2207213E00674B58 /* SQLQueryGenerator.swift in Sources */, 5605F15D1C672E4000235C62 /* DatabaseDateComponents.swift in Sources */, 567ECE4F2222E431009245CA /* GRDB-4.0.swift in Sources */, 56193E8E1CD8A3E200F95862 /* FetchedRecordsController.swift in Sources */, @@ -3349,9 +3391,8 @@ 564CE43121AA901800652B19 /* ValueObserver.swift in Sources */, 5605F1651C672E4000235C62 /* NSNull.swift in Sources */, 56CEB5191EAA328900BFAF62 /* FTS5+QueryInterface.swift in Sources */, - 5653EB1820944C7C00F46237 /* ForeignKey.swift in Sources */, 5674A6FB1F307F600095F066 /* FetchableRecord+Decodable.swift in Sources */, - 5653EB0620944C7C00F46237 /* ForeignKeyRequest.swift in Sources */, + 5653EB0620944C7C00F46237 /* SQLForeignKeyRequest.swift in Sources */, 56E9FACB221046FD00C703A8 /* SQLInterpolation+QueryInterface.swift in Sources */, 5698AC781DA37DCB0056AF8C /* VirtualTableModule.swift in Sources */, 56A2387D1B9C75030082EB20 /* Database.swift in Sources */, @@ -3373,7 +3414,6 @@ 5657AAB91D107001006283EF /* NSData.swift in Sources */, 560D92421C672C3E00F4F92B /* StatementColumnConvertible.swift in Sources */, 56CEB5531EAA359A00BFAF62 /* SQLExpression.swift in Sources */, - 5607148C227617690091BB10 /* FetchableRecord+QueryInterface.swift in Sources */, 56B9649D1DA51B4C0002DA19 /* FTS5.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/GRDB/QueryInterface/Association/BelongsToAssociation.swift b/GRDB/QueryInterface/Association/BelongsToAssociation.swift deleted file mode 100644 index d62c78da3..000000000 --- a/GRDB/QueryInterface/Association/BelongsToAssociation.swift +++ /dev/null @@ -1,166 +0,0 @@ -/// The BelongsTo association sets up a one-to-one connection from a record -/// type to another record type, such as each instance of the declaring record -/// "belongs to" an instance of the other record. -/// -/// For example, if your application includes authors and books, and each book -/// is assigned its author, you'd declare the association this way: -/// -/// struct Author: TableRecord { ... } -/// struct Book: TableRecord { -/// static let author = belongsTo(Author.self) -/// ... -/// } -/// -/// A BelongsTo associations should be supported by an SQLite foreign key. -/// -/// Foreign keys are the recommended way to declare relationships between -/// database tables because not only will SQLite guarantee the integrity of your -/// data, but GRDB will be able to use those foreign keys to automatically -/// configure your association. -/// -/// You define the foreign key when you create database tables. For example: -/// -/// try db.create(table: "author") { t in -/// t.autoIncrementedPrimaryKey("id") // (1) -/// t.column("name", .text) -/// } -/// try db.create(table: "book") { t in -/// t.autoIncrementedPrimaryKey("id") -/// t.column("authorId", .integer) // (2) -/// .notNull() // (3) -/// .indexed() // (4) -/// .references("author", onDelete: .cascade) // (5) -/// t.column("title", .text) -/// } -/// -/// 1. The author table has a primary key. -/// 2. The book.authorId column is used to link a book to the author it -/// belongs to. -/// 3. Make the book.authorId column not null if you want SQLite to guarantee -/// that all books have an author. -/// 4. Create an index on the book.authorId column in order to ease the -/// selection of an author's books. -/// 5. Create a foreign key from book.authorId column to authors.id, so that -/// SQLite guarantees that no book refers to a missing author. The -/// `onDelete: .cascade` option has SQLite automatically delete all of an -/// author's books when that author is deleted. -/// See https://sqlite.org/foreignkeys.html#fk_actions for more information. -/// -/// The example above uses auto-incremented primary keys. But generally -/// speaking, all primary keys are supported. -/// -/// If the database schema does not define foreign keys between tables, you can -/// still use BelongsTo associations. But your help is needed to define the -/// missing foreign key: -/// -/// struct Book: FetchableRecord, TableRecord { -/// static let author = belongsTo(Author.self, using: ForeignKey(...)) -/// } -/// -/// See ForeignKey for more information. -public struct BelongsToAssociation: AssociationToOne { - /// :nodoc: - public typealias OriginRowDecoder = Origin - - /// :nodoc: - public typealias RowDecoder = Destination - - /// :nodoc: - public var sqlAssociation: SQLAssociation - - /// :nodoc: - public init(sqlAssociation: SQLAssociation) { - self.sqlAssociation = sqlAssociation - } -} - -// Allow BelongsToAssociation(...).filter(key: ...) -extension BelongsToAssociation: TableRequest where Destination: TableRecord { } - -extension TableRecord { - /// Creates a "Belongs To" association between Self and the - /// destination type. - /// - /// struct Author: TableRecord { ... } - /// struct Book: TableRecord { - /// static let author = belongsTo(Author.self) - /// } - /// - /// The association will let you define requests that load both the source - /// and the destination type: - /// - /// // A request for all books with their authors: - /// let request = Book.including(optional: Book.author) - /// - /// To consume those requests, define a type that adopts both the - /// FetchableRecord and Decodable protocols: - /// - /// struct BookInfo: FetchableRecord, Decodable { - /// var book: Book - /// var author: Author? - /// } - /// - /// let bookInfos = try dbQueue.read { db in - /// return try BookInfo.fetchAll(db, request) - /// } - /// for bookInfo in bookInfos { - /// print("\(bookInfo.book.title) by \(bookInfo.author.name)") - /// } - /// - /// It is recommended that you define, alongside the static association, a - /// property with the same name: - /// - /// struct Book: TableRecord, EncodableRecord { - /// static let author = belongsTo(Author.self) - /// var author: QueryInterfaceRequest { - /// return request(for: Book.author) - /// } - /// } - /// - /// This property will let you navigate from the source type to the - /// destination type: - /// - /// try dbQueue.read { db in - /// let book: Book = ... - /// let author = try book.author.fetchOne(db) // Author? - /// } - /// - /// - parameters: - /// - destination: The record type at the other side of the association. - /// - key: An eventual decoding key for the association. By default, it - /// is `destination.databaseTableName`. - /// - foreignKey: An eventual foreign key. You need to provide an - /// explicit foreign key when GRDB can't infer one from the database - /// schema. This happens when the schema does not define any foreign - /// key to the destination table, or when the schema defines several - /// foreign keys to the destination table. - public static func belongsTo( - _ destination: Destination.Type, - key: String? = nil, - using foreignKey: ForeignKey? = nil) - -> BelongsToAssociation - where Destination: TableRecord - { - let foreignKeyRequest = ForeignKeyRequest( - originTable: databaseTableName, - destinationTable: Destination.databaseTableName, - foreignKey: foreignKey) - - let condition = SQLAssociationCondition( - foreignKeyRequest: foreignKeyRequest, - originIsLeft: true) - - let associationKey: SQLAssociationKey - if let key = key { - associationKey = .fixedSingular(key) - } else { - associationKey = .inflected(Destination.databaseTableName) - } - - return BelongsToAssociation(sqlAssociation: SQLAssociation( - key: associationKey, - condition: condition, - relation: Destination.all().relation, - isSingular: true)) - } -} diff --git a/GRDB/QueryInterface/Association/ForeignKey.swift b/GRDB/QueryInterface/Association/ForeignKey.swift deleted file mode 100644 index 5b4312762..000000000 --- a/GRDB/QueryInterface/Association/ForeignKey.swift +++ /dev/null @@ -1,108 +0,0 @@ -/// A ForeignKey helps building associations when GRDB can't infer a foreign -/// key from the database schema. -/// -/// Sometimes the database schema does not define any foreign key between two -/// tables. And sometimes, there are several foreign keys from a table -/// to another: -/// -/// | Table book | | Table person | -/// | ------------ | | ------------ | -/// | id | +-->• id | -/// | authorId •---+ | name | -/// | translatorId •---+ -/// | title | -/// -/// When this happens, associations can't be automatically inferred from the -/// database schema. GRDB will complain with a fatal error such as "Ambiguous -/// foreign key from book to person", or "Could not infer foreign key from book -/// to person". -/// -/// Your help is needed. You have to instruct GRDB which foreign key to use: -/// -/// struct Book: TableRecord { -/// // Define foreign keys -/// static let authorForeignKey = ForeignKey(["authorId"])) -/// static let translatorForeignKey = ForeignKey(["translatorId"])) -/// -/// // Use foreign keys to define associations: -/// static let author = belongsTo(Person.self, using: authorForeignKey) -/// static let translator = belongsTo(Person.self, using: translatorForeignKey) -/// } -/// -/// Foreign keys are always defined from the table that contains the columns at -/// the origin of the foreign key. Person's symmetric HasMany associations reuse -/// Book's foreign keys: -/// -/// struct Person: TableRecord { -/// static let writtenBooks = hasMany(Book.self, using: Book.authorForeignKey) -/// static let translatedBooks = hasMany(Book.self, using: Book.translatorForeignKey) -/// } -/// -/// Foreign keys can also be defined from query interface columns: -/// -/// struct Book: TableRecord { -/// enum Columns: String, ColumnExpression { -/// case id, title, authorId, translatorId -/// } -/// -/// static let authorForeignKey = ForeignKey([Columns.authorId])) -/// static let translatorForeignKey = ForeignKey([Columns.translatorId])) -/// } -/// -/// When the destination table of a foreign key does not define any primary key, -/// you need to provide the full definition of a foreign key: -/// -/// struct Book: TableRecord { -/// static let authorForeignKey = ForeignKey(["authorId"], to: ["id"])) -/// static let author = belongsTo(Person.self, using: authorForeignKey) -/// } -public struct ForeignKey { - var originColumns: [String] - var destinationColumns: [String]? - - /// Creates a ForeignKey intended to define a record association. - /// - /// struct Book: TableRecord { - /// // Define foreign keys - /// static let authorForeignKey = ForeignKey(["authorId"])) - /// static let translatorForeignKey = ForeignKey(["translatorId"])) - /// - /// // Use foreign keys to define associations: - /// static let author = belongsTo(Person.self, using: authorForeignKey) - /// static let translator = belongsTo(Person.self, using: translatorForeignKey) - /// } - /// - /// - parameter originColumns: The columns at the origin of the foreign key. - /// - parameter destinationColumns: The columns at the destination of the - /// foreign key. When nil (the default), GRDB automatically uses the - /// primary key. - public init(_ originColumns: [String], to destinationColumns: [String]? = nil) { - self.originColumns = originColumns - self.destinationColumns = destinationColumns - } - - /// Creates a ForeignKey intended to define a record association. - /// - /// struct Book: TableRecord { - /// // Define columns - /// enum Columns: String, ColumnExpression { - /// case id, title, authorId, translatorId - /// } - /// - /// // Define foreign keys - /// static let authorForeignKey = ForeignKey([Columns.authorId])) - /// static let translatorForeignKey = ForeignKey([Columns.translatorId])) - /// - /// // Use foreign keys to define associations: - /// static let author = belongsTo(Person.self, using: authorForeignKey) - /// static let translator = belongsTo(Person.self, using: translatorForeignKey) - /// } - /// - /// - parameter originColumns: The columns at the origin of the foreign key. - /// - parameter destinationColumns: The columns at the destination of the - /// foreign key. When nil (the default), GRDB automatically uses the - /// primary key. - public init(_ originColumns: [ColumnExpression], to destinationColumns: [ColumnExpression]? = nil) { - self.init(originColumns.map { $0.name }, to: destinationColumns?.map { $0.name }) - } -} diff --git a/GRDB/QueryInterface/Association/HasManyAssociation.swift b/GRDB/QueryInterface/Association/HasManyAssociation.swift deleted file mode 100644 index 5b29099e0..000000000 --- a/GRDB/QueryInterface/Association/HasManyAssociation.swift +++ /dev/null @@ -1,166 +0,0 @@ -/// The HasMany association indicates a one-to-many connection between two -/// record types, such as each instance of the declaring record "has many" -/// instances of the other record. -/// -/// For example, if your application includes authors and books, and each author -/// is assigned zero or more books, you'd declare the association this way: -/// -/// struct Book: TableRecord { ... } -/// struct Author: TableRecord { -/// static let books = hasMany(Book.self) -/// ... -/// } -/// -/// HasMany associations should be supported by an SQLite foreign key. -/// -/// Foreign keys are the recommended way to declare relationships between -/// database tables because not only will SQLite guarantee the integrity of your -/// data, but GRDB will be able to use those foreign keys to automatically -/// configure your association. -/// -/// You define the foreign key when you create database tables. For example: -/// -/// try db.create(table: "author") { t in -/// t.autoIncrementedPrimaryKey("id") // (1) -/// t.column("name", .text) -/// } -/// try db.create(table: "book") { t in -/// t.autoIncrementedPrimaryKey("id") -/// t.column("authorId", .integer) // (2) -/// .notNull() // (3) -/// .indexed() // (4) -/// .references("author", onDelete: .cascade) // (5) -/// t.column("title", .text) -/// } -/// -/// 1. The author table has a primary key. -/// 2. The book.authorId column is used to link a book to the author it -/// belongs to. -/// 3. Make the book.authorId column not null if you want SQLite to guarantee -/// that all books have an author. -/// 4. Create an index on the book.authorId column in order to ease the -/// selection of an author's books. -/// 5. Create a foreign key from book.authorId column to authors.id, so that -/// SQLite guarantees that no book refers to a missing author. The -/// `onDelete: .cascade` option has SQLite automatically delete all of an -/// author's books when that author is deleted. -/// See https://sqlite.org/foreignkeys.html#fk_actions for more information. -/// -/// The example above uses auto-incremented primary keys. But generally -/// speaking, all primary keys are supported. -/// -/// If the database schema does not define foreign keys between tables, you can -/// still use HasMany associations. But your help is needed to define the -/// missing foreign key: -/// -/// struct Author: TableRecord { -/// static let books = hasMany(Book.self, using: ForeignKey(...)) -/// } -/// -/// See ForeignKey for more information. -public struct HasManyAssociation: AssociationToMany { - /// :nodoc: - public typealias OriginRowDecoder = Origin - - /// :nodoc: - public typealias RowDecoder = Destination - - /// :nodoc: - public var sqlAssociation: SQLAssociation - - /// :nodoc: - public init(sqlAssociation: SQLAssociation) { - self.sqlAssociation = sqlAssociation - } -} - -// Allow HasManyAssociation(...).filter(key: ...) -extension HasManyAssociation: TableRequest where Destination: TableRecord { } - -extension TableRecord { - /// Creates a "Has many" association between Self and the - /// destination type. - /// - /// struct Book: TableRecord { ... } - /// struct Author: TableRecord { - /// static let books = hasMany(Book.self) - /// } - /// - /// The association will let you define requests that load both the source - /// and the destination type: - /// - /// // A request for all (author, book) pairs: - /// let request = Author.including(required: Author.books) - /// - /// To consume those requests, define a type that adopts both the - /// FetchableRecord and Decodable protocols: - /// - /// struct Authorship: FetchableRecord, Decodable { - /// var author: Author - /// var book: Book - /// } - /// - /// let authorships = try dbQueue.read { db in - /// return try Authorship.fetchAll(db, request) - /// } - /// for authorship in authorships { - /// print("\(authorship.author.name) wrote \(authorship.book.title)") - /// } - /// - /// It is recommended that you define, alongside the static association, a - /// property with the same name: - /// - /// struct Author: TableRecord, EncodableRecord { - /// static let books = hasMany(Book.self) - /// var books: QueryInterfaceRequest { - /// return request(for: Author.books) - /// } - /// } - /// - /// This property will let you navigate from the source type to the - /// destination type: - /// - /// try dbQueue.read { db in - /// let author: Author = ... - /// let books = try author.books.fetchAll(db) // [Book] - /// } - /// - /// - parameters: - /// - destination: The record type at the other side of the association. - /// - key: An eventual decoding key for the association. By default, it - /// is `destination.databaseTableName`. - /// - foreignKey: An eventual foreign key. You need to provide an - /// explicit foreign key when GRDB can't infer one from the database - /// schema. This happens when the schema does not define any foreign - /// key from the destination table, or when the schema defines several - /// foreign keys from the destination table. - public static func hasMany( - _ destination: Destination.Type, - key: String? = nil, - using foreignKey: ForeignKey? = nil) - -> HasManyAssociation - where Destination: TableRecord - { - let foreignKeyRequest = ForeignKeyRequest( - originTable: Destination.databaseTableName, - destinationTable: databaseTableName, - foreignKey: foreignKey) - - let condition = SQLAssociationCondition( - foreignKeyRequest: foreignKeyRequest, - originIsLeft: false) - - let associationKey: SQLAssociationKey - if let key = key { - associationKey = .fixedPlural(key) - } else { - associationKey = .inflected(Destination.databaseTableName) - } - - return HasManyAssociation(sqlAssociation: SQLAssociation( - key: associationKey, - condition: condition, - relation: Destination.all().relation, - isSingular: false)) - } -} diff --git a/GRDB/QueryInterface/Association/HasManyThroughAssociation.swift b/GRDB/QueryInterface/Association/HasManyThroughAssociation.swift deleted file mode 100644 index 21eb78bb4..000000000 --- a/GRDB/QueryInterface/Association/HasManyThroughAssociation.swift +++ /dev/null @@ -1,145 +0,0 @@ -/// The **HasManyThrough** association is often used to set up a many-to-many -/// connection with another record. This association indicates that the -/// declaring record can be matched with zero or more instances of another -/// record by proceeding through a third record. -/// -/// For example, consider the practice of passport delivery. One coutry -/// "has many" citizens "through" its passports: -/// -/// struct Country: TableRecord { -/// static let passports = hasMany(Passport.self) -/// static let citizens = hasMany(Citizen.self, through: passports, using: Passport.citizen) -/// ... -/// } -/// -/// struct Passport: TableRecord { -/// static let citizen = belongsTo(Citizen.self) -/// ... -/// } -/// -/// struct Citizen: TableRecord { ... } -/// -/// The **HasManyThrough** association is also useful for setting up -/// "shortcuts" through nested HasMany associations. For example, if a document -/// has many sections, and a section has many paragraphs, you may sometimes want -/// to get a simple collection of all paragraphs in the document. You could set -/// that up this way: -/// -/// struct Document: TableRecord { -/// static let sections = hasMany(Section.self) -/// static let paragraphs = hasMany(Paragraph.self, through: sections, using: Section.paragraphs) -/// } -/// -/// struct Section: TableRecord { -/// static let paragraphs = hasMany(Paragraph.self) -/// } -/// -/// struct Paragraph: TableRecord { -/// } -/// -/// As in the examples above, **HasManyThrough** association is always built from -/// two other associations: the `through:` and `using:` arguments. Those -/// associations can be any other association (BelongsTo, HasMany, -/// HasManyThrough, etc). -public struct HasManyThroughAssociation: AssociationToMany { - /// :nodoc: - public typealias OriginRowDecoder = Origin - - /// :nodoc: - public typealias RowDecoder = Destination - - /// :nodoc: - public var sqlAssociation: SQLAssociation - - /// :nodoc: - public init(sqlAssociation: SQLAssociation) { - self.sqlAssociation = sqlAssociation - } -} - -// Allow HasManyThroughAssociation(...).filter(key: ...) -extension HasManyThroughAssociation: TableRequest where Destination: TableRecord { } - -extension TableRecord { - /// Creates a "Has Many Through" association between Self and the - /// destination type. - /// - /// struct Country: TableRecord { - /// static let passports = hasMany(Passport.self) - /// static let citizens = hasMany(Citizen.self, through: passports, using: Passport.citizen) - /// } - /// - /// struct Passport: TableRecord { - /// static let citizen = belongsTo(Citizen.self) - /// } - /// - /// struct Citizen: TableRecord { } - /// - /// The association will let you define requests that load both the source - /// and the destination type: - /// - /// // A request for all (country, citizen) pairs: - /// let request = Country.including(required: Coutry.citizens) - /// - /// To consume those requests, define a type that adopts both the - /// FetchableRecord and Decodable protocols: - /// - /// struct Citizenship: FetchableRecord, Decodable { - /// var country: Country - /// var citizen: Citizen - /// } - /// - /// let citizenships = try dbQueue.read { db in - /// return try Citizenship.fetchAll(db, request) - /// } - /// for citizenship in citizenships { - /// print("\(citizenship.citizen.name) is a citizen of \(citizenship.country.name)") - /// } - /// - /// It is recommended that you define, alongside the static association, a - /// property with the same name: - /// - /// struct Country: TableRecord, EncodableRecord { - /// static let passports = hasMany(Passport.self) - /// static let citizens = hasMany(Citizen.self, through: passports, using: Passport.citizen) - /// var citizens: QueryInterfaceRequest { - /// return request(for: Country.citizens) - /// } - /// } - /// - /// This property will let you navigate from the source type to the - /// destination type: - /// - /// try dbQueue.read { db in - /// let country: Country = ... - /// let citizens = try country.citizens.fetchAll(db) // [Country] - /// } - /// - /// - parameters: - /// - destination: The record type at the other side of the association. - /// - pivot: An association from Self to the intermediate type. - /// - target: A target association from the intermediate type to the - /// destination type. - /// - key: An eventual decoding key for the association. By default, it - /// is the same key as the target. - public static func hasMany( - _ destination: Target.RowDecoder.Type, - through pivot: Pivot, - using target: Target, - key: String? = nil) - -> HasManyThroughAssociation - where Pivot: Association, - Target: Association, - Pivot.OriginRowDecoder == Self, - Pivot.RowDecoder == Target.OriginRowDecoder - { - let association = HasManyThroughAssociation( - sqlAssociation: target.sqlAssociation.through(pivot.sqlAssociation)) - - if let key = key { - return association.forKey(key) - } else { - return association - } - } -} diff --git a/GRDB/QueryInterface/Association/HasOneAssociation.swift b/GRDB/QueryInterface/Association/HasOneAssociation.swift deleted file mode 100644 index efaaba8e6..000000000 --- a/GRDB/QueryInterface/Association/HasOneAssociation.swift +++ /dev/null @@ -1,168 +0,0 @@ -/// The HasOne association indicates a one-to-one connection between two -/// record types, such as each instance of the declaring record "has one" -/// instances of the other record. -/// -/// For example, if your application has one database table for countries, and -/// another for their demographic profiles, you'd declare the association -/// this way: -/// -/// struct Demographics: TableRecord { ... } -/// struct Country: TableRecord { -/// static let demographics = hasOne(Demographics.self) -/// ... -/// } -/// -/// HasOne associations should be supported by an SQLite foreign key. -/// -/// Foreign keys are the recommended way to declare relationships between -/// database tables because not only will SQLite guarantee the integrity of your -/// data, but GRDB will be able to use those foreign keys to automatically -/// configure your association. -/// -/// You define the foreign key when you create database tables. For example: -/// -/// try db.create(table: "country") { t in -/// t.column("code", .text).primaryKey() // (1) -/// t.column("name", .text) -/// } -/// try db.create(table: "demographics") { t in -/// t.autoIncrementedPrimaryKey("id") -/// t.column("countryCode", .text) // (2) -/// .notNull() // (3) -/// .unique() // (4) -/// .references("country", onDelete: .cascade) // (5) -/// t.column("population", .integer) -/// t.column("density", .double) -/// } -/// -/// 1. The country table has a primary key. -/// 2. The demographics.countryCode column is used to link a demographic -/// profile to the country it belongs to. -/// 3. Make the demographics.countryCode column not null if you want SQLite to -/// guarantee that all profiles are linked to a country. -/// 4. Create a unique index on the demographics.countryCode column in order to -/// guarantee the unicity of any country's profile. -/// 5. Create a foreign key from demographics.countryCode column to -/// country.code, so that SQLite guarantees that no profile refers to a -/// missing country. The `onDelete: .cascade` option has SQLite automatically -/// delete a profile when its country is deleted. -/// See https://sqlite.org/foreignkeys.html#fk_actions for more information. -/// -/// The example above uses a string primary for the country table. But generally -/// speaking, all primary keys are supported. -/// -/// If the database schema does not follow this convention, and does not define -/// foreign keys between tables, you can still use HasOne associations. But -/// your help is needed to define the missing foreign key: -/// -/// struct Country: FetchableRecord, TableRecord { -/// static let demographics = hasOne(Demographics.self, using: ForeignKey(...)) -/// } -/// -/// See ForeignKey for more information. -public struct HasOneAssociation: AssociationToOne { - /// :nodoc: - public typealias OriginRowDecoder = Origin - - /// :nodoc: - public typealias RowDecoder = Destination - - /// :nodoc: - public var sqlAssociation: SQLAssociation - - /// :nodoc: - public init(sqlAssociation: SQLAssociation) { - self.sqlAssociation = sqlAssociation - } -} - -// Allow HasOneAssociation(...).filter(key: ...) -extension HasOneAssociation: TableRequest where Destination: TableRecord { } - -extension TableRecord { - /// Creates a "Has one" association between Self and the - /// destination type. - /// - /// struct Demographics: TableRecord { ... } - /// struct Country: TableRecord { - /// static let demographics = hasOne(Demographics.self) - /// } - /// - /// The association will let you define requests that load both the source - /// and the destination type: - /// - /// // A request for all countries with their demographic profile: - /// let request = Country.including(optional: Country.demographics) - /// - /// To consume those requests, define a type that adopts both the - /// FetchableRecord and Decodable protocols: - /// - /// struct CountryInfo: FetchableRecord, Decodable { - /// var country: Country - /// var demographics: Demographics? - /// } - /// - /// let countryInfos = try dbQueue.read { db in - /// return try CountryInfo.fetchAll(db, request) - /// } - /// for countryInfo in countryInfos { - /// print("\(countryInfo.country.name) has \(countryInfo.demographics.population) citizens") - /// } - /// - /// It is recommended that you define, alongside the static association, a - /// property with the same name: - /// - /// struct Country: TableRecord, EncodableRecord { - /// static let demographics = hasOne(Demographics.self) - /// var demographics: QueryInterfaceRequest { - /// return request(for: Country.demographics) - /// } - /// } - /// - /// This property will let you navigate from the source type to the - /// destination type: - /// - /// try dbQueue.read { db in - /// let country: Country = ... - /// let demographics = try country.demographics.fetchOne(db) // Demographics? - /// } - /// - /// - parameters: - /// - destination: The record type at the other side of the association. - /// - key: An eventual decoding key for the association. By default, it - /// is `destination.databaseTableName`. - /// - foreignKey: An eventual foreign key. You need to provide an - /// explicit foreign key when GRDB can't infer one from the database - /// schema. This happens when the schema does not define any foreign - /// key from the destination table, or when the schema defines several - /// foreign keys from the destination table. - public static func hasOne( - _ destination: Destination.Type, - key: String? = nil, - using foreignKey: ForeignKey? = nil) - -> HasOneAssociation - where Destination: TableRecord - { - let foreignKeyRequest = ForeignKeyRequest( - originTable: Destination.databaseTableName, - destinationTable: databaseTableName, - foreignKey: foreignKey) - - let condition = SQLAssociationCondition( - foreignKeyRequest: foreignKeyRequest, - originIsLeft: false) - - let associationKey: SQLAssociationKey - if let key = key { - associationKey = .fixedSingular(key) - } else { - associationKey = .inflected(Destination.databaseTableName) - } - - return HasOneAssociation(sqlAssociation: SQLAssociation( - key: associationKey, - condition: condition, - relation: Destination.all().relation, - isSingular: true)) - } -} diff --git a/GRDB/QueryInterface/Association/HasOneThroughAssociation.swift b/GRDB/QueryInterface/Association/HasOneThroughAssociation.swift deleted file mode 100644 index 10f1cf680..000000000 --- a/GRDB/QueryInterface/Association/HasOneThroughAssociation.swift +++ /dev/null @@ -1,125 +0,0 @@ -/// A **HasOneThrough** association sets up a one-to-one connection with -/// another record. This association indicates that the declaring record can be -/// matched with one instance of another record by proceeding through a third -/// record. For example, if each book belongs to a library, and each library has -/// one address, then one knows where the book should be returned to: -/// -/// struct Book: TableRecord { -/// static let library = belongsTo(Library.self) -/// static let returnAddress = hasOne(Address.self, through: library, using: library.address) -/// ... -/// } -/// -/// struct Library: TableRecord { -/// static let address = hasOne(Address.self) -/// ... -/// } -/// -/// struct Address: TableRecord { ... } -/// -/// As in the example above, **HasOneThrough** association is always built from -/// two other associations: the `through:` and `using:` arguments. Those -/// associations can be any other association to one (BelongsTo, HasOne, -/// HasOneThrough). -public struct HasOneThroughAssociation: AssociationToOne { - /// :nodoc: - public typealias OriginRowDecoder = Origin - - /// :nodoc: - public typealias RowDecoder = Destination - - /// :nodoc: - public var sqlAssociation: SQLAssociation - - /// :nodoc: - public init(sqlAssociation: SQLAssociation) { - self.sqlAssociation = sqlAssociation - } -} - -// Allow HasOneThroughAssociation(...).filter(key: ...) -extension HasOneThroughAssociation: TableRequest where Destination: TableRecord { } - -extension TableRecord { - /// Creates a "Has One Through" association between Self and the - /// destination type. - /// - /// struct Book: TableRecord { - /// static let library = belongsTo(Library.self) - /// static let returnAddress = hasOne(Address.self, through: library, using: library.address) - /// } - /// - /// struct Library: TableRecord { - /// static let address = hasOne(Address.self) - /// } - /// - /// struct Address: TableRecord { ... } - /// - /// The association will let you define requests that load both the source - /// and the destination type: - /// - /// // A request for all (book, returnAddress) pairs: - /// let request = Book.including(required: Book.returnAddress) - /// - /// To consume those requests, define a type that adopts both the - /// FetchableRecord and Decodable protocols: - /// - /// struct Todo: FetchableRecord, Decodable { - /// var book: Book - /// var address: Address - /// } - /// - /// let todos = try dbQueue.read { db in - /// return try Todo.fetchAll(db, request) - /// } - /// for todo in todos { - /// print("Please return \(todo.book) to \(todo.address)") - /// } - /// - /// It is recommended that you define, alongside the static association, a - /// property with the same name: - /// - /// struct Book: TableRecord, EncodableRecord { - /// static let library = belongsTo(Library.self) - /// static let returnAddress = hasOne(Address.self, through: library, using: library.address) - /// var returnAddress: QueryInterfaceRequest
{ - /// return request(for: Book.returnAddress) - /// } - /// } - /// - /// This property will let you navigate from the source type to the - /// destination type: - /// - /// try dbQueue.read { db in - /// let book: Book = ... - /// let address = try book.returnAddress.fetchOne(db) // Address? - /// } - /// - /// - parameters: - /// - destination: The record type at the other side of the association. - /// - pivot: An association from Self to the intermediate type. - /// - target: A target association from the intermediate type to the - /// destination type. - /// - key: An eventual decoding key for the association. By default, it - /// is the same key as the target. - public static func hasOne( - _ destination: Target.RowDecoder.Type, - through pivot: Pivot, - using target: Target, - key: String? = nil) - -> HasOneThroughAssociation - where Pivot: AssociationToOne, - Target: AssociationToOne, - Pivot.OriginRowDecoder == Self, - Pivot.RowDecoder == Target.OriginRowDecoder - { - let association = HasOneThroughAssociation( - sqlAssociation: target.sqlAssociation.through(pivot.sqlAssociation)) - - if let key = key { - return association.forKey(key) - } else { - return association - } - } -} diff --git a/GRDB/QueryInterface/FTS3+QueryInterfaceRequest.swift b/GRDB/QueryInterface/FTS3+QueryInterface.swift similarity index 100% rename from GRDB/QueryInterface/FTS3+QueryInterfaceRequest.swift rename to GRDB/QueryInterface/FTS3+QueryInterface.swift diff --git a/GRDB/QueryInterface/FetchableRecord+QueryInterface.swift b/GRDB/QueryInterface/FetchableRecord+QueryInterfaceRequest.swift similarity index 100% rename from GRDB/QueryInterface/FetchableRecord+QueryInterface.swift rename to GRDB/QueryInterface/FetchableRecord+QueryInterfaceRequest.swift diff --git a/GRDB/QueryInterface/QueryInterfaceRequest+Association.swift b/GRDB/QueryInterface/QueryInterfaceRequest+Association.swift deleted file mode 100644 index 8378516ce..000000000 --- a/GRDB/QueryInterface/QueryInterfaceRequest+Association.swift +++ /dev/null @@ -1,197 +0,0 @@ -extension QueryInterfaceRequest where RowDecoder: TableRecord { - // MARK: - Associations - - /// Creates a request that prefetches an association. - public func including(all association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == RowDecoder { - return mapQuery { - $0.mapRelation { - $0.including(all: association.sqlAssociation) - } - } - } - - /// Creates a request that includes an association. The columns of the - /// associated record are selected. The returned request does not - /// require that the associated database table contains a matching row. - public func including(optional association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == RowDecoder { - return mapQuery { - $0.mapRelation { - $0.including(optional: association.sqlAssociation) - } - } - } - - /// Creates a request that includes an association. The columns of the - /// associated record are selected. The returned request requires - /// that the associated database table contains a matching row. - public func including(required association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == RowDecoder { - return mapQuery { - $0.mapRelation { - $0.including(required: association.sqlAssociation) - } - } - } - - /// Creates a request that joins an association. The columns of the - /// associated record are not selected. The returned request does not - /// require that the associated database table contains a matching row. - public func joining(optional association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == RowDecoder { - return mapQuery { - $0.mapRelation { - $0.joining(optional: association.sqlAssociation) - } - } - } - - /// Creates a request that joins an association. The columns of the - /// associated record are not selected. The returned request requires - /// that the associated database table contains a matching row. - public func joining(required association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == RowDecoder { - return mapQuery { - $0.mapRelation { - $0.joining(required: association.sqlAssociation) - } - } - } - - // MARK: - Association Aggregates - - private func annotated(with aggregate: AssociationAggregate) -> QueryInterfaceRequest { - let (request, expression) = aggregate.prepare(self) - if let alias = aggregate.alias { - return request.annotated(with: [expression.aliased(alias)]) - } else { - return request.annotated(with: [expression]) - } - } - - /// Creates a request which appends *aggregates* to the current selection. - /// - /// // SELECT player.*, COUNT(DISTINCT book.rowid) AS bookCount - /// // FROM player LEFT JOIN book ... - /// var request = Player.all() - /// request = request.annotated(with: Player.books.count) - public func annotated(with aggregates: AssociationAggregate...) -> QueryInterfaceRequest { - return annotated(with: aggregates) - } - - /// Creates a request which appends *aggregates* to the current selection. - /// - /// // SELECT player.*, COUNT(DISTINCT book.rowid) AS bookCount - /// // FROM player LEFT JOIN book ... - /// var request = Player.all() - /// request = request.annotated(with: [Player.books.count]) - public func annotated(with aggregates: [AssociationAggregate]) -> QueryInterfaceRequest { - return aggregates.reduce(self) { request, aggregate in - request.annotated(with: aggregate) - } - } - - /// Creates a request which appends the provided aggregate *predicate* to - /// the eventual set of already applied predicates. - /// - /// // SELECT player.* - /// // FROM player LEFT JOIN book ... - /// // HAVING COUNT(DISTINCT book.rowid) = 0 - /// var request = Player.all() - /// request = request.having(Player.books.isEmpty) - public func having(_ predicate: AssociationAggregate) -> QueryInterfaceRequest { - let (request, expression) = predicate.prepare(self) - return request.having(expression) - } -} - -extension TableRecord where Self: EncodableRecord { - /// Creates a request that fetches the associated record(s). - /// - /// For example: - /// - /// struct Team: TableRecord, EncodableRecord { - /// static let players = hasMany(Player.self) - /// var players: QueryInterfaceRequest { - /// return request(for: Team.players) - /// } - /// } - /// - /// let team: Team = ... - /// let players = try team.players.fetchAll(db) // [Player] - public func request(for association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == Self { - let destinationRelation = association.sqlAssociation.destinationRelation(fromOriginRows: { db in - try [Row(PersistenceContainer(db, self))] - }) - return QueryInterfaceRequest(relation: destinationRelation) - } -} - -extension TableRecord { - - // MARK: - Associations - - /// Creates a request that prefetches an association. - public static func including(all association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == Self { - return all().including(all: association) - } - - /// Creates a request that includes an association. The columns of the - /// associated record are selected. The returned association does not - /// require that the associated database table contains a matching row. - public static func including(optional association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == Self { - return all().including(optional: association) - } - - /// Creates a request that includes an association. The columns of the - /// associated record are selected. The returned association requires - /// that the associated database table contains a matching row. - public static func including(required association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == Self { - return all().including(required: association) - } - - /// Creates a request that includes an association. The columns of the - /// associated record are not selected. The returned association does not - /// require that the associated database table contains a matching row. - public static func joining(optional association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == Self { - return all().joining(optional: association) - } - - /// Creates a request that includes an association. The columns of the - /// associated record are not selected. The returned association requires - /// that the associated database table contains a matching row. - public static func joining(required association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == Self { - return all().joining(required: association) - } - - // MARK: - Association Aggregates - - /// Creates a request with *aggregates* appended to the selection. - /// - /// // SELECT player.*, COUNT(DISTINCT book.rowid) AS bookCount - /// // FROM player LEFT JOIN book ... - /// var request = Player.annotated(with: Player.books.count) - public static func annotated(with aggregates: AssociationAggregate...) -> QueryInterfaceRequest { - return all().annotated(with: aggregates) - } - - /// Creates a request with *aggregates* appended to the selection. - /// - /// // SELECT player.*, COUNT(DISTINCT book.rowid) AS bookCount - /// // FROM player LEFT JOIN book ... - /// var request = Player.annotated(with: [Player.books.count]) - public static func annotated(with aggregates: [AssociationAggregate]) -> QueryInterfaceRequest { - return all().annotated(with: aggregates) - } - - /// Creates a request with the provided aggregate *predicate*. - /// - /// // SELECT player.* - /// // FROM player LEFT JOIN book ... - /// // HAVING COUNT(DISTINCT book.rowid) = 0 - /// var request = Player.all() - /// request = request.having(Player.books.isEmpty) - /// - /// The selection defaults to all columns. This default can be changed for - /// all requests by the `TableRecord.databaseSelection` property, or - /// for individual requests with the `TableRecord.select` method. - public static func having(_ predicate: AssociationAggregate) -> QueryInterfaceRequest { - return all().having(predicate) - } -} diff --git a/GRDB/QueryInterface/Association/Association.swift b/GRDB/QueryInterface/Request/Association/Association.swift similarity index 52% rename from GRDB/QueryInterface/Association/Association.swift rename to GRDB/QueryInterface/Request/Association/Association.swift index ad26599c0..2ff915f14 100644 --- a/GRDB/QueryInterface/Association/Association.swift +++ b/GRDB/QueryInterface/Request/Association/Association.swift @@ -86,7 +86,7 @@ extension Association { /// let team: Team = row["custom"] /// } var key: SQLAssociationKey { - return sqlAssociation.destinationKey + return sqlAssociation.destination.key } /// Creates an association which selects *selection*. @@ -273,45 +273,6 @@ extension Association { } } -extension SQLRelation { - /// Creates a relation that prefetches another one. - func including(all sqlAssociation: SQLAssociation) -> SQLRelation { - return sqlAssociation.extendedRelation(self, kind: .allPrefetched) - } - - /// Creates a relation that includes another one. The columns of the - /// associated record are selected. The returned relation does not - /// require that the associated database table contains a matching row. - func including(optional sqlAssociation: SQLAssociation) -> SQLRelation { - return sqlAssociation.extendedRelation(self, kind: .oneOptional) - } - - /// Creates a relation that includes another one. The columns of the - /// associated record are selected. The returned relation requires - /// that the associated database table contains a matching row. - func including(required sqlAssociation: SQLAssociation) -> SQLRelation { - return sqlAssociation.extendedRelation(self, kind: .oneRequired) - } - - /// Creates a relation that joins another one. The columns of the - /// associated record are not selected. The returned relation does not - /// require that the associated database table contains a matching row. - func joining(optional sqlAssociation: SQLAssociation) -> SQLRelation { - return sqlAssociation - .mapDestinationRelation { $0.select([]) } - .extendedRelation(self, kind: .oneOptional) - } - - /// Creates a relation that joins another one. The columns of the - /// associated record are not selected. The returned relation requires - /// that the associated database table contains a matching row. - func joining(required sqlAssociation: SQLAssociation) -> SQLRelation { - return sqlAssociation - .mapDestinationRelation { $0.select([]) } - .extendedRelation(self, kind: .oneRequired) - } -} - extension Association { /// Creates an association that prefetches another one. public func including(all association: A) -> Self where A.OriginRowDecoder == RowDecoder { @@ -363,6 +324,20 @@ extension Association where Self: TableRequest, RowDecoder: TableRecord { public var databaseTableName: String { return RowDecoder.databaseTableName } } +// MARK: - AssociationToOne + +/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) +/// +/// The base protocol for all associations that define a one-to-one connection. +public protocol AssociationToOne: Association { } + +extension AssociationToOne { + public func forKey(_ key: String) -> Self { + let associationKey = SQLAssociationKey.fixedSingular(key) + return Self.init(sqlAssociation: sqlAssociation.forDestinationKey(associationKey)) + } +} + // MARK: - AssociationToMany /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) @@ -537,453 +512,3 @@ extension AssociationToMany where OriginRowDecoder: TableRecord { } } } - -// MARK: - AssociationToOne - -/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) -/// -/// The base protocol for all associations that define a one-to-one connection. -public protocol AssociationToOne: Association { } - -extension AssociationToOne { - public func forKey(_ key: String) -> Self { - let associationKey = SQLAssociationKey.fixedSingular(key) - return Self.init(sqlAssociation: sqlAssociation.forDestinationKey(associationKey)) - } -} - -// MARK: - SQLAssociationKey - -/// Associations are meant to be consumed, most often into Decodable records. -/// -/// Those records have singular or plural property names, and we want -/// associations to be able to fill those singular or plural names -/// automatically, so that the user does not have to perform explicit -/// decoding configuration. -/// -/// Those plural or singular names are not decided when the association is -/// defined. For example, the Author.books association, which looks plural, may -/// actually generate "book" or "books" depending on the context: -/// -/// struct Author: TableRecord { -/// static let books = hasMany(Book.self) -/// } -/// struct Book: TableRecord { -/// } -/// -/// // "books" -/// struct AuthorInfo: FetchableRecord, Decodable { -/// var author: Author -/// var books: [Book] -/// } -/// let request = Author.including(all: Author.books) -/// let authorInfos = try AuthorInfo.fetchAll(db, request) -/// -/// "book" -/// struct AuthorInfo: FetchableRecord, Decodable { -/// var author: Author -/// var book: Book -/// } -/// let request = Author.including(required: Author.books) -/// let authorInfos = try AuthorInfo.fetchAll(db, request) -/// -/// "bookCount" -/// struct AuthorInfo: FetchableRecord, Decodable { -/// var author: Author -/// var bookCount: Int -/// } -/// let request = Author.annotated(with: Author.books.count) -/// let authorInfos = try AuthorInfo.fetchAll(db, request) -/// -/// The SQLAssociationKey type aims at providing the necessary support for -/// those various inflections. -enum SQLAssociationKey { - /// A key that is inflected in singular and plural contexts. - /// - /// For example: - /// - /// struct Author: TableRecord { - /// static let databaseTableName = "authors" - /// } - /// struct Book: TableRecord { - /// let author = belongsTo(Author.self) - /// } - /// - /// let request = Book.including(required: Book.author) - /// let row = try Row.fetchOne(db, request)! - /// row.scopes["author"] // singularized "authors" table name - case inflected(String) - - /// A key that is inflected in plural contexts, but stricly honors - /// user-provided name in singular contexts. - /// - /// For example: - /// - /// struct Country: TableRecord { - /// let demographics = hasOne(Demographics.self, key: "demographics") - /// } - /// - /// let request = Country.including(required: Country.demographics) - /// let row = try Row.fetchOne(db, request)! - /// row.scopes["demographics"] // not singularized - case fixedSingular(String) - - /// A key that is inflected in singular contexts, but stricly honors - /// user-provided name in plural contexts. - /// See .inflected and .fixedSingular for some context. - case fixedPlural(String) - - /// A key that is never inflected. - case fixed(String) - - var pluralizedName: String { - switch self { - case .inflected(let name): - return name.pluralized - case .fixedSingular(let name): - return name.pluralized - case .fixedPlural(let name): - return name - case .fixed(let name): - return name - } - } - - var singularizedName: String { - switch self { - case .inflected(let name): - return name.singularized - case .fixedSingular(let name): - return name - case .fixedPlural(let name): - return name.singularized - case .fixed(let name): - return name - } - } -} - -// MARK: - SQLAssociation - -/// An SQL association is a non-empty chain of steps which starts at the -/// "pivot" and ends on the "destination": -/// -/// // SELECT origin.*, destination.* -/// // FROM origin -/// // JOIN pivot ON ... -/// // JOIN ... -/// // JOIN ... -/// // JOIN destination ON ... -/// Origin.including(required: association) -/// -/// For direct associations such as BelongTo or HasMany, the chain contains a -/// single element, the "destination", without intermediate step: -/// -/// // "Origin" belongsTo "destination": -/// // SELECT origin.*, destination.* -/// // FROM origin -/// // JOIN destination ON destination.originId = origin.id -/// let association = Origin.belongsTo(Destination.self) -/// Origin.including(required: association) -/// -/// Indirect associations such as HasManyThrough have one or several -/// intermediate steps: -/// -/// // "Origin" has many "destination" through "pivot": -/// // SELECT origin.*, destination.* -/// // FROM origin -/// // JOIN pivot ON pivot.originId = origin.id -/// // JOIN destination ON destination.id = pivot.destinationId -/// let association = Origin.hasMany( -/// Destination.self, -/// through: Origin.hasMany(Pivot.self), -/// via: Pivot.belongsTo(Destination.self)) -/// Origin.including(required: association) -/// -/// // "Origin" has many "destination" through "pivot1" and "pivot2": -/// // SELECT origin.*, destination.* -/// // FROM origin -/// // JOIN pivot1 ON pivot1.originId = origin.id -/// // JOIN pivot2 ON pivot2.pivot1Id = pivot1.id -/// // JOIN destination ON destination.id = pivot.destinationId -/// let association = Origin.hasMany( -/// Destination.self, -/// through: Origin.hasMany(Pivot1.self), -/// via: Pivot1.hasMany( -/// Destination.self, -/// through: Pivot1.hasMany(Pivot2.self), -/// via: Pivot2.belongsTo(Destination.self))) -/// Origin.including(required: association) -/// -/// :nodoc: -public /* TODO: internal */ struct SQLAssociation { - private struct AssociationStep { - var key: SQLAssociationKey - var condition: SQLAssociationCondition - var relation: SQLRelation - var isSingular: Bool - - func mapRelation(_ transform: (SQLRelation) -> SQLRelation) -> AssociationStep { - return AssociationStep(key: key, condition: condition, relation: transform(relation), isSingular: isSingular) - } - } - - // All steps, from pivot to destination. Never empty. - private var steps: [AssociationStep] - var keyPath: [String] { - return steps.map { - $0.isSingular - ? $0.key.singularizedName - : $0.key.pluralizedName - } - } - - private var destination: AssociationStep { - get { return steps[steps.count - 1] } - set { steps[steps.count - 1] = newValue } - } - var destinationKey: SQLAssociationKey { return destination.key } - - private var pivot: AssociationStep { - get { return steps[0] } - set { steps[0] = newValue } - } - var pivotCondition: SQLAssociationCondition { - return pivot.condition - } - - private init(steps: [AssociationStep]) { - assert(!steps.isEmpty) - self.steps = steps - } - - init( - key: SQLAssociationKey, - condition: SQLAssociationCondition, - relation: SQLRelation, - isSingular: Bool) - { - self.init(steps: [AssociationStep(key: key, condition: condition, relation: relation, isSingular: isSingular)]) - } - - /// Changes the destination key - func forDestinationKey(_ key: SQLAssociationKey) -> SQLAssociation { - var result = self - result.destination.key = key - return result - } - - /// Transforms the destination relation - func mapDestinationRelation(_ transform: (SQLRelation) -> SQLRelation) -> SQLAssociation { - var result = self - result.destination = result.destination.mapRelation(transform) - return result - } - - /// Transforms the pivot relation - func mapPivotRelation(_ transform: (SQLRelation) -> SQLRelation) -> SQLAssociation { - var result = self - result.pivot = result.pivot.mapRelation(transform) - return result - } - - /// Returns a new association - func through(_ other: SQLAssociation) -> SQLAssociation { - return SQLAssociation(steps: other.steps + steps) - } - - /// Given a relation, returns a relation extended with this association. - /// - /// This method provides support for public joining methods such - /// as `including(required:)`: - /// - /// struct Destination: TableRecord { } - /// struct Origin: TableRecord { - /// static let destination = belongsTo(Destination.self) - /// } - /// - /// // SELECT origin.*, destination.* - /// // FROM origin - /// // JOIN destination ON destination.id = origin.destinationId - /// let request = Origin.including(required: Origin.destination) - /// - /// At low-level, this gives: - /// - /// let sqlAssociation = Origin.destination.sqlAssociation - /// let origin = Origin.all().query.relation - /// let extendedRelation = sqlAssociation.extendedRelation(origin, required: true) - /// let query = SQLSelectQuery(relation: extendedRelation) - /// let generator = SQLSelectQueryGenerator(query) - /// let statement, _ = try generator.prepare(db) - /// print(statement.sql) - /// // SELECT origin.*, destination.* - /// // FROM origin - /// // JOIN destination ON destination.originId = origin.id - /// - /// This method works for simple direct associations such as BelongsTo or - /// HasMany in the above examples, but also for indirect associations such - /// as HasManyThrough, which have any number of pivot relations between the - /// origin and the destination. - func extendedRelation(_ origin: SQLRelation, kind: SQLRelation.Child.Kind) -> SQLRelation { - let destinationChild = SQLRelation.Child( - kind: kind, - condition: destination.condition, - relation: destination.relation) - - let initialSteps = steps.dropLast() - if initialSteps.isEmpty { - // This is a direct join from origin to destination, without - // intermediate step. - // - // SELECT origin.*, destination.* - // FROM origin - // JOIN destination ON destination.id = origin.destinationId - // - // let association = Origin.belongsTo(Destination.self) - // Origin.including(required: association) - let key = kind.isSingular - ? destination.key.singularizedName - : destination.key.pluralizedName - return origin.appendingChild(destinationChild, forKey: key) - } - - // This is an indirect join from origin to destination, through - // some pivot(s): - // - // SELECT origin.*, destination.* - // FROM origin - // JOIN pivot ON pivot.originId = origin.id - // JOIN destination ON destination.id = pivot.destinationId - // - // let association = Origin.hasMany( - // Destination.self, - // through: Origin.hasMany(Pivot.self), - // via: Pivot.belongsTo(Destination.self)) - // Origin.including(required: association) - // - // Let's recurse toward a direct join, by making a new association which - // ends on the last pivot, to which we join our destination: - var reducedAssociation = SQLAssociation(steps: Array(initialSteps)) - let key = kind.isSingular - ? destination.key.singularizedName - : destination.key.pluralizedName - reducedAssociation.destination.relation = reducedAssociation.destination.relation - .select([]) // Intermediate steps are not prefetched - .appendingChild(destinationChild, forKey: key) - - switch kind { - case .oneRequired, .oneOptional, .allNotPrefetched: - return reducedAssociation.extendedRelation(origin, kind: kind) - case .allPrefetched: - // Intermediate steps of indirect associations are not prefetched. - // - // For example, the request below prefetches citizens, not - // intermediate passports: - // - // extension Country { - // static let passports = hasMany(Passport.self) - // static let citizens = hasMany(Citizens.self, through: passports, using: Passport.citizen) - // } - // let request = Country.including(all: Country.citizens) - return reducedAssociation.extendedRelation(origin, kind: .allNotPrefetched) - } - } - - /// Given an origin alias and rows, returns the destination of the - /// association as a relation. - /// - /// This method provides support for association methods such - /// as `request(for:)`: - /// - /// struct Destination: TableRecord { } - /// struct Origin: TableRecord, EncodableRecord { - /// static let destinations = hasMany(Destination.self) - /// var destinations: QueryInterface { - /// return request(for: Origin.destinations) - /// } - /// } - /// - /// // SELECT destination.* - /// // FROM destination - /// // WHERE destination.originId = 1 - /// let origin = Origin(id: 1) - /// let destinations = origin.destinations.fetchAll(db) - /// - /// At low-level, this gives: - /// - /// let origin = Origin(id: 1) - /// let originAlias = TableAlias(tableName: Origin.databaseTableName) - /// let sqlAssociation = Origin.destination.sqlAssociation - /// let destinationRelation = sqlAssociation.destinationRelation( - /// from: originAlias, - /// rows: { db in try [Row(PersistenceContainer(db, origin))] }) - /// let query = SQLSelectQuery(relation: destinationRelation) - /// let generator = SQLSelectQueryGenerator(query) - /// let statement, _ = try generator.prepare(db) - /// print(statement.sql) - /// // SELECT destination.* - /// // FROM destination - /// // WHERE destination.originId = 1 - /// - /// This method works for simple direct associations such as BelongsTo or - /// HasMany in the above examples, but also for indirect associations such - /// as HasManyThrough, which have any number of pivot relations between the - /// origin and the destination. - func destinationRelation(fromOriginRows originRows: @escaping (Database) throws -> [Row]) -> SQLRelation { - // Filter the pivot - let pivot = self.pivot - let pivotAlias = TableAlias() - let filteredPivotRelation = pivot.relation - .qualified(with: pivotAlias) - .filter({ db in - // `pivot.originId = 123` or `pivot.originId IN (1, 2, 3)` - try pivot.condition.filteringExpression(db, leftRows: originRows(db), rightAlias: pivotAlias) - }) - - if steps.count == 1 { - // This is a direct join from origin to destination, without - // intermediate step. - // - // SELECT destination.* - // FROM destination - // WHERE destination.originId = 1 - // - // let association = Origin.hasMany(Destination.self) - // Origin(id: 1).request(for: association) - return filteredPivotRelation - } - - // This is an indirect join from origin to destination, through - // some intermediate steps: - // - // SELECT destination.* - // FROM destination - // JOIN pivot ON (pivot.destinationId = destination.id) AND (pivot.originId = 1) - // - // let association = Origin.hasMany( - // Destination.self, - // through: Origin.hasMany(Pivot.self), - // via: Pivot.belongsTo(Destination.self)) - // Origin(id: 1).request(for: association) - let reversedSteps = zip(steps, steps.dropFirst()) - .map { (step, nextStep) -> AssociationStep in - // Intermediate steps are not included in the selection, and - // don't have any child. - let relation = step.relation.select([]).deletingChildren() - return AssociationStep( - key: step.key, - condition: nextStep.condition.reversed, - relation: relation, - isSingular: step.isSingular) - } - .reversed() - - var reversedAssociation = SQLAssociation(steps: Array(reversedSteps)) - // Replace pivot with the filtered one (not included in the selection, - // without children). - reversedAssociation = reversedAssociation.mapDestinationRelation { _ in - filteredPivotRelation.select([]).deletingChildren() - } - return reversedAssociation.extendedRelation(destination.relation, kind: .oneRequired) - } -} diff --git a/GRDB/QueryInterface/Association/AssociationAggregate.swift b/GRDB/QueryInterface/Request/Association/AssociationAggregate.swift similarity index 100% rename from GRDB/QueryInterface/Association/AssociationAggregate.swift rename to GRDB/QueryInterface/Request/Association/AssociationAggregate.swift diff --git a/GRDB/QueryInterface/Request/Association/BelongsToAssociation.swift b/GRDB/QueryInterface/Request/Association/BelongsToAssociation.swift new file mode 100644 index 000000000..1f459622f --- /dev/null +++ b/GRDB/QueryInterface/Request/Association/BelongsToAssociation.swift @@ -0,0 +1,78 @@ +/// The BelongsTo association sets up a one-to-one connection from a record +/// type to another record type, such as each instance of the declaring record +/// "belongs to" an instance of the other record. +/// +/// For example, if your application includes authors and books, and each book +/// is assigned its author, you'd declare the association this way: +/// +/// struct Author: TableRecord { ... } +/// struct Book: TableRecord { +/// static let author = belongsTo(Author.self) +/// ... +/// } +/// +/// A BelongsTo associations should be supported by an SQLite foreign key. +/// +/// Foreign keys are the recommended way to declare relationships between +/// database tables because not only will SQLite guarantee the integrity of your +/// data, but GRDB will be able to use those foreign keys to automatically +/// configure your association. +/// +/// You define the foreign key when you create database tables. For example: +/// +/// try db.create(table: "author") { t in +/// t.autoIncrementedPrimaryKey("id") // (1) +/// t.column("name", .text) +/// } +/// try db.create(table: "book") { t in +/// t.autoIncrementedPrimaryKey("id") +/// t.column("authorId", .integer) // (2) +/// .notNull() // (3) +/// .indexed() // (4) +/// .references("author", onDelete: .cascade) // (5) +/// t.column("title", .text) +/// } +/// +/// 1. The author table has a primary key. +/// 2. The book.authorId column is used to link a book to the author it +/// belongs to. +/// 3. Make the book.authorId column not null if you want SQLite to guarantee +/// that all books have an author. +/// 4. Create an index on the book.authorId column in order to ease the +/// selection of an author's books. +/// 5. Create a foreign key from book.authorId column to authors.id, so that +/// SQLite guarantees that no book refers to a missing author. The +/// `onDelete: .cascade` option has SQLite automatically delete all of an +/// author's books when that author is deleted. +/// See https://sqlite.org/foreignkeys.html#fk_actions for more information. +/// +/// The example above uses auto-incremented primary keys. But generally +/// speaking, all primary keys are supported. +/// +/// If the database schema does not define foreign keys between tables, you can +/// still use BelongsTo associations. But your help is needed to define the +/// missing foreign key: +/// +/// struct Book: FetchableRecord, TableRecord { +/// static let author = belongsTo(Author.self, using: ForeignKey(...)) +/// } +/// +/// See ForeignKey for more information. +public struct BelongsToAssociation: AssociationToOne { + /// :nodoc: + public typealias OriginRowDecoder = Origin + + /// :nodoc: + public typealias RowDecoder = Destination + + /// :nodoc: + public var sqlAssociation: SQLAssociation + + /// :nodoc: + public init(sqlAssociation: SQLAssociation) { + self.sqlAssociation = sqlAssociation + } +} + +// Allow BelongsToAssociation(...).filter(key: ...) +extension BelongsToAssociation: TableRequest where Destination: TableRecord { } diff --git a/GRDB/QueryInterface/Request/Association/HasManyAssociation.swift b/GRDB/QueryInterface/Request/Association/HasManyAssociation.swift new file mode 100644 index 000000000..d02586fde --- /dev/null +++ b/GRDB/QueryInterface/Request/Association/HasManyAssociation.swift @@ -0,0 +1,78 @@ +/// The HasMany association indicates a one-to-many connection between two +/// record types, such as each instance of the declaring record "has many" +/// instances of the other record. +/// +/// For example, if your application includes authors and books, and each author +/// is assigned zero or more books, you'd declare the association this way: +/// +/// struct Book: TableRecord { ... } +/// struct Author: TableRecord { +/// static let books = hasMany(Book.self) +/// ... +/// } +/// +/// HasMany associations should be supported by an SQLite foreign key. +/// +/// Foreign keys are the recommended way to declare relationships between +/// database tables because not only will SQLite guarantee the integrity of your +/// data, but GRDB will be able to use those foreign keys to automatically +/// configure your association. +/// +/// You define the foreign key when you create database tables. For example: +/// +/// try db.create(table: "author") { t in +/// t.autoIncrementedPrimaryKey("id") // (1) +/// t.column("name", .text) +/// } +/// try db.create(table: "book") { t in +/// t.autoIncrementedPrimaryKey("id") +/// t.column("authorId", .integer) // (2) +/// .notNull() // (3) +/// .indexed() // (4) +/// .references("author", onDelete: .cascade) // (5) +/// t.column("title", .text) +/// } +/// +/// 1. The author table has a primary key. +/// 2. The book.authorId column is used to link a book to the author it +/// belongs to. +/// 3. Make the book.authorId column not null if you want SQLite to guarantee +/// that all books have an author. +/// 4. Create an index on the book.authorId column in order to ease the +/// selection of an author's books. +/// 5. Create a foreign key from book.authorId column to authors.id, so that +/// SQLite guarantees that no book refers to a missing author. The +/// `onDelete: .cascade` option has SQLite automatically delete all of an +/// author's books when that author is deleted. +/// See https://sqlite.org/foreignkeys.html#fk_actions for more information. +/// +/// The example above uses auto-incremented primary keys. But generally +/// speaking, all primary keys are supported. +/// +/// If the database schema does not define foreign keys between tables, you can +/// still use HasMany associations. But your help is needed to define the +/// missing foreign key: +/// +/// struct Author: TableRecord { +/// static let books = hasMany(Book.self, using: ForeignKey(...)) +/// } +/// +/// See ForeignKey for more information. +public struct HasManyAssociation: AssociationToMany { + /// :nodoc: + public typealias OriginRowDecoder = Origin + + /// :nodoc: + public typealias RowDecoder = Destination + + /// :nodoc: + public var sqlAssociation: SQLAssociation + + /// :nodoc: + public init(sqlAssociation: SQLAssociation) { + self.sqlAssociation = sqlAssociation + } +} + +// Allow HasManyAssociation(...).filter(key: ...) +extension HasManyAssociation: TableRequest where Destination: TableRecord { } diff --git a/GRDB/QueryInterface/Request/Association/HasManyThroughAssociation.swift b/GRDB/QueryInterface/Request/Association/HasManyThroughAssociation.swift new file mode 100644 index 000000000..e4e5cb3cc --- /dev/null +++ b/GRDB/QueryInterface/Request/Association/HasManyThroughAssociation.swift @@ -0,0 +1,61 @@ +/// The **HasManyThrough** association is often used to set up a many-to-many +/// connection with another record. This association indicates that the +/// declaring record can be matched with zero or more instances of another +/// record by proceeding through a third record. +/// +/// For example, consider the practice of passport delivery. One coutry +/// "has many" citizens "through" its passports: +/// +/// struct Country: TableRecord { +/// static let passports = hasMany(Passport.self) +/// static let citizens = hasMany(Citizen.self, through: passports, using: Passport.citizen) +/// ... +/// } +/// +/// struct Passport: TableRecord { +/// static let citizen = belongsTo(Citizen.self) +/// ... +/// } +/// +/// struct Citizen: TableRecord { ... } +/// +/// The **HasManyThrough** association is also useful for setting up +/// "shortcuts" through nested HasMany associations. For example, if a document +/// has many sections, and a section has many paragraphs, you may sometimes want +/// to get a simple collection of all paragraphs in the document. You could set +/// that up this way: +/// +/// struct Document: TableRecord { +/// static let sections = hasMany(Section.self) +/// static let paragraphs = hasMany(Paragraph.self, through: sections, using: Section.paragraphs) +/// } +/// +/// struct Section: TableRecord { +/// static let paragraphs = hasMany(Paragraph.self) +/// } +/// +/// struct Paragraph: TableRecord { +/// } +/// +/// As in the examples above, **HasManyThrough** association is always built from +/// two other associations: the `through:` and `using:` arguments. Those +/// associations can be any other association (BelongsTo, HasMany, +/// HasManyThrough, etc). +public struct HasManyThroughAssociation: AssociationToMany { + /// :nodoc: + public typealias OriginRowDecoder = Origin + + /// :nodoc: + public typealias RowDecoder = Destination + + /// :nodoc: + public var sqlAssociation: SQLAssociation + + /// :nodoc: + public init(sqlAssociation: SQLAssociation) { + self.sqlAssociation = sqlAssociation + } +} + +// Allow HasManyThroughAssociation(...).filter(key: ...) +extension HasManyThroughAssociation: TableRequest where Destination: TableRecord { } diff --git a/GRDB/QueryInterface/Request/Association/HasOneAssociation.swift b/GRDB/QueryInterface/Request/Association/HasOneAssociation.swift new file mode 100644 index 000000000..6b1f49f7c --- /dev/null +++ b/GRDB/QueryInterface/Request/Association/HasOneAssociation.swift @@ -0,0 +1,80 @@ +/// The HasOne association indicates a one-to-one connection between two +/// record types, such as each instance of the declaring record "has one" +/// instances of the other record. +/// +/// For example, if your application has one database table for countries, and +/// another for their demographic profiles, you'd declare the association +/// this way: +/// +/// struct Demographics: TableRecord { ... } +/// struct Country: TableRecord { +/// static let demographics = hasOne(Demographics.self) +/// ... +/// } +/// +/// HasOne associations should be supported by an SQLite foreign key. +/// +/// Foreign keys are the recommended way to declare relationships between +/// database tables because not only will SQLite guarantee the integrity of your +/// data, but GRDB will be able to use those foreign keys to automatically +/// configure your association. +/// +/// You define the foreign key when you create database tables. For example: +/// +/// try db.create(table: "country") { t in +/// t.column("code", .text).primaryKey() // (1) +/// t.column("name", .text) +/// } +/// try db.create(table: "demographics") { t in +/// t.autoIncrementedPrimaryKey("id") +/// t.column("countryCode", .text) // (2) +/// .notNull() // (3) +/// .unique() // (4) +/// .references("country", onDelete: .cascade) // (5) +/// t.column("population", .integer) +/// t.column("density", .double) +/// } +/// +/// 1. The country table has a primary key. +/// 2. The demographics.countryCode column is used to link a demographic +/// profile to the country it belongs to. +/// 3. Make the demographics.countryCode column not null if you want SQLite to +/// guarantee that all profiles are linked to a country. +/// 4. Create a unique index on the demographics.countryCode column in order to +/// guarantee the unicity of any country's profile. +/// 5. Create a foreign key from demographics.countryCode column to +/// country.code, so that SQLite guarantees that no profile refers to a +/// missing country. The `onDelete: .cascade` option has SQLite automatically +/// delete a profile when its country is deleted. +/// See https://sqlite.org/foreignkeys.html#fk_actions for more information. +/// +/// The example above uses a string primary for the country table. But generally +/// speaking, all primary keys are supported. +/// +/// If the database schema does not follow this convention, and does not define +/// foreign keys between tables, you can still use HasOne associations. But +/// your help is needed to define the missing foreign key: +/// +/// struct Country: FetchableRecord, TableRecord { +/// static let demographics = hasOne(Demographics.self, using: ForeignKey(...)) +/// } +/// +/// See ForeignKey for more information. +public struct HasOneAssociation: AssociationToOne { + /// :nodoc: + public typealias OriginRowDecoder = Origin + + /// :nodoc: + public typealias RowDecoder = Destination + + /// :nodoc: + public var sqlAssociation: SQLAssociation + + /// :nodoc: + public init(sqlAssociation: SQLAssociation) { + self.sqlAssociation = sqlAssociation + } +} + +// Allow HasOneAssociation(...).filter(key: ...) +extension HasOneAssociation: TableRequest where Destination: TableRecord { } diff --git a/GRDB/QueryInterface/Request/Association/HasOneThroughAssociation.swift b/GRDB/QueryInterface/Request/Association/HasOneThroughAssociation.swift new file mode 100644 index 000000000..be25e3173 --- /dev/null +++ b/GRDB/QueryInterface/Request/Association/HasOneThroughAssociation.swift @@ -0,0 +1,41 @@ +/// A **HasOneThrough** association sets up a one-to-one connection with +/// another record. This association indicates that the declaring record can be +/// matched with one instance of another record by proceeding through a third +/// record. For example, if each book belongs to a library, and each library has +/// one address, then one knows where the book should be returned to: +/// +/// struct Book: TableRecord { +/// static let library = belongsTo(Library.self) +/// static let returnAddress = hasOne(Address.self, through: library, using: library.address) +/// ... +/// } +/// +/// struct Library: TableRecord { +/// static let address = hasOne(Address.self) +/// ... +/// } +/// +/// struct Address: TableRecord { ... } +/// +/// As in the example above, **HasOneThrough** association is always built from +/// two other associations: the `through:` and `using:` arguments. Those +/// associations can be any other association to one (BelongsTo, HasOne, +/// HasOneThrough). +public struct HasOneThroughAssociation: AssociationToOne { + /// :nodoc: + public typealias OriginRowDecoder = Origin + + /// :nodoc: + public typealias RowDecoder = Destination + + /// :nodoc: + public var sqlAssociation: SQLAssociation + + /// :nodoc: + public init(sqlAssociation: SQLAssociation) { + self.sqlAssociation = sqlAssociation + } +} + +// Allow HasOneThroughAssociation(...).filter(key: ...) +extension HasOneThroughAssociation: TableRequest where Destination: TableRecord { } diff --git a/GRDB/QueryInterface/Request/QueryInterfaceRequest+Association.swift b/GRDB/QueryInterface/Request/QueryInterfaceRequest+Association.swift new file mode 100644 index 000000000..8ef57e1d9 --- /dev/null +++ b/GRDB/QueryInterface/Request/QueryInterfaceRequest+Association.swift @@ -0,0 +1,102 @@ +extension QueryInterfaceRequest where RowDecoder: TableRecord { + // MARK: - Associations + + /// Creates a request that prefetches an association. + public func including(all association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == RowDecoder { + return mapQuery { + $0.mapRelation { + $0.including(all: association.sqlAssociation) + } + } + } + + /// Creates a request that includes an association. The columns of the + /// associated record are selected. The returned request does not + /// require that the associated database table contains a matching row. + public func including(optional association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == RowDecoder { + return mapQuery { + $0.mapRelation { + $0.including(optional: association.sqlAssociation) + } + } + } + + /// Creates a request that includes an association. The columns of the + /// associated record are selected. The returned request requires + /// that the associated database table contains a matching row. + public func including(required association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == RowDecoder { + return mapQuery { + $0.mapRelation { + $0.including(required: association.sqlAssociation) + } + } + } + + /// Creates a request that joins an association. The columns of the + /// associated record are not selected. The returned request does not + /// require that the associated database table contains a matching row. + public func joining(optional association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == RowDecoder { + return mapQuery { + $0.mapRelation { + $0.joining(optional: association.sqlAssociation) + } + } + } + + /// Creates a request that joins an association. The columns of the + /// associated record are not selected. The returned request requires + /// that the associated database table contains a matching row. + public func joining(required association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == RowDecoder { + return mapQuery { + $0.mapRelation { + $0.joining(required: association.sqlAssociation) + } + } + } + + // MARK: - Association Aggregates + + private func annotated(with aggregate: AssociationAggregate) -> QueryInterfaceRequest { + let (request, expression) = aggregate.prepare(self) + if let alias = aggregate.alias { + return request.annotated(with: [expression.aliased(alias)]) + } else { + return request.annotated(with: [expression]) + } + } + + /// Creates a request which appends *aggregates* to the current selection. + /// + /// // SELECT player.*, COUNT(DISTINCT book.rowid) AS bookCount + /// // FROM player LEFT JOIN book ... + /// var request = Player.all() + /// request = request.annotated(with: Player.books.count) + public func annotated(with aggregates: AssociationAggregate...) -> QueryInterfaceRequest { + return annotated(with: aggregates) + } + + /// Creates a request which appends *aggregates* to the current selection. + /// + /// // SELECT player.*, COUNT(DISTINCT book.rowid) AS bookCount + /// // FROM player LEFT JOIN book ... + /// var request = Player.all() + /// request = request.annotated(with: [Player.books.count]) + public func annotated(with aggregates: [AssociationAggregate]) -> QueryInterfaceRequest { + return aggregates.reduce(self) { request, aggregate in + request.annotated(with: aggregate) + } + } + + /// Creates a request which appends the provided aggregate *predicate* to + /// the eventual set of already applied predicates. + /// + /// // SELECT player.* + /// // FROM player LEFT JOIN book ... + /// // HAVING COUNT(DISTINCT book.rowid) = 0 + /// var request = Player.all() + /// request = request.having(Player.books.isEmpty) + public func having(_ predicate: AssociationAggregate) -> QueryInterfaceRequest { + let (request, expression) = predicate.prepare(self) + return request.having(expression) + } +} diff --git a/GRDB/QueryInterface/QueryInterfaceRequest.swift b/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift similarity index 50% rename from GRDB/QueryInterface/QueryInterfaceRequest.swift rename to GRDB/QueryInterface/Request/QueryInterfaceRequest.swift index 9b50d2451..39f4a2679 100644 --- a/GRDB/QueryInterface/QueryInterfaceRequest.swift +++ b/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift @@ -3,7 +3,7 @@ // struct Player: TableRecord { ... } // let playerRequest = Player.all() // QueryInterfaceRequest // -// It wraps an SQLSelectQuery, and has an attached type. +// It wraps an SQLQuery, and has an attached type. // // The attached type helps decoding raw database values: // @@ -29,14 +29,14 @@ /// /// See https://github.com/groue/GRDB.swift#the-query-interface public struct QueryInterfaceRequest { - var query: SQLSelectQuery + var query: SQLQuery - init(query: SQLSelectQuery) { + init(query: SQLQuery) { self.query = query } init(relation: SQLRelation) { - self.init(query: SQLSelectQuery(relation: relation)) + self.init(query: SQLQuery(relation: relation)) } var prefetchedAssociations: [SQLAssociation] { @@ -62,7 +62,7 @@ extension QueryInterfaceRequest : FetchRequest { query.limit = SQLLimit(limit: 1, offset: query.limit?.offset) } - return try SQLSelectQueryGenerator(query).prepare(db) + return try SQLQueryGenerator(query).prepare(db) } /// Returns the number of rows fetched by the request. @@ -78,7 +78,7 @@ extension QueryInterfaceRequest : FetchRequest { /// - parameter db: A database connection. /// :nodoc: public func databaseRegion(_ db: Database) throws -> DatabaseRegion { - var region = try SQLSelectQueryGenerator(query).databaseRegion(db) + var region = try SQLQueryGenerator(query).databaseRegion(db) // Iterate all prefetched associations var fifo = query.relation.prefetchedAssociations @@ -87,17 +87,17 @@ extension QueryInterfaceRequest : FetchRequest { // Build the query for prefetched rows. // CAUTION: Keep this code in sync with Row.prefetch(_:associations:in:) - let pivotMapping = try association.pivotCondition.columnMapping(db) - let pivotColumns = pivotMapping.map { $0.right } + let pivotMappings = try association.pivot.condition.columnMappings(db) + let pivotColumns = pivotMappings.map { $0.right } let pivotAlias = TableAlias() let prefetchedRelation = association .mapPivotRelation { $0.qualified(with: pivotAlias) } .destinationRelation(fromOriginRows: { _ in [] /* no origin row */ }) .annotated(with: pivotColumns.map { pivotAlias[Column($0)].aliased("grdb_\($0)") }) - let prefetchedQuery = SQLSelectQuery(relation: prefetchedRelation) + let prefetchedQuery = SQLQuery(relation: prefetchedRelation) // Union region - try region.formUnion(SQLSelectQueryGenerator(prefetchedQuery).databaseRegion(db)) + try region.formUnion(SQLQueryGenerator(prefetchedQuery).databaseRegion(db)) // Append nested prefetched associations (support for // A.including(all: A.bs.including(all: B.cs)) @@ -351,7 +351,7 @@ extension QueryInterfaceRequest : DerivableRequest, AggregatingRequest { } /// Returns a request whose query is transformed by the given closure. - func mapQuery(_ transform: (SQLSelectQuery) -> SQLSelectQuery) -> QueryInterfaceRequest { + func mapQuery(_ transform: (SQLQuery) -> SQLQuery) -> QueryInterfaceRequest { var request = self request.query = transform(query) return request @@ -394,7 +394,7 @@ extension QueryInterfaceRequest: TableRequest { return tableName case .query: // The only current use case for SQLSource.query is the - // "trivial count query" (see SQLSelectQuery.countQuery): + // "trivial count query" (see SQLQuery.countQuery): // // // SELECT COUNT(*) FROM (SELECT * FROM player LIMIT 10) // let request = Player.limit(10) @@ -418,332 +418,7 @@ extension QueryInterfaceRequest where T: MutablePersistableRecord { /// - throws: A DatabaseError is thrown whenever an SQLite error occurs. @discardableResult public func deleteAll(_ db: Database) throws -> Int { - try SQLSelectQueryGenerator(query).makeDeleteStatement(db).execute() + try SQLQueryGenerator(query).makeDeleteStatement(db).execute() return db.changesCount } } - -extension TableRecord { - - // MARK: Request Derivation - - /// Creates a request which fetches all records. - /// - /// // SELECT * FROM player - /// let request = Player.all() - /// - /// The selection defaults to all columns. This default can be changed for - /// all requests by the `TableRecord.databaseSelection` property, or - /// for individual requests with the `TableRecord.select` method. - public static func all() -> QueryInterfaceRequest { - let relation = SQLRelation( - source: .table(tableName: databaseTableName, alias: nil), - selection: databaseSelection) - return QueryInterfaceRequest(relation: relation) - } - - /// Creates a request which fetches no record. - public static func none() -> QueryInterfaceRequest { - return all().none() // don't laugh - } - - /// Creates a request which selects *selection*. - /// - /// // SELECT id, email FROM player - /// let request = Player.select(Column("id"), Column("email")) - public static func select(_ selection: SQLSelectable...) -> QueryInterfaceRequest { - return all().select(selection) - } - - /// Creates a request which selects *selection*. - /// - /// // SELECT id, email FROM player - /// let request = Player.select([Column("id"), Column("email")]) - public static func select(_ selection: [SQLSelectable]) -> QueryInterfaceRequest { - return all().select(selection) - } - - /// Creates a request which selects *sql*. - /// - /// // SELECT id, email FROM player - /// let request = Player.select(sql: "id, email") - public static func select(sql: String, arguments: StatementArguments = StatementArguments()) -> QueryInterfaceRequest { - return select(literal: SQLLiteral(sql: sql, arguments: arguments)) - } - - /// Creates a request which selects an SQL *literal*. - /// - /// // SELECT id, email FROM player - /// let request = Player.select(literal: SQLLiteral(sql: "id, email")) - public static func select(literal sqlLiteral: SQLLiteral) -> QueryInterfaceRequest { - return all().select(literal: sqlLiteral) - } - - /// Creates a request which selects *selection*, and fetches values of - /// type *type*. - /// - /// try dbQueue.read { db in - /// // SELECT max(score) FROM player - /// let request = Player.select([max(Column("score"))], as: Int.self) - /// let maxScore: Int? = try request.fetchOne(db) - /// } - public static func select(_ selection: [SQLSelectable], as type: RowDecoder.Type) -> QueryInterfaceRequest { - return all().select(selection, as: type) - } - - /// Creates a request which selects *selection*, and fetches values of - /// type *type*. - /// - /// try dbQueue.read { db in - /// // SELECT max(score) FROM player - /// let request = Player.select(max(Column("score")), as: Int.self) - /// let maxScore: Int? = try request.fetchOne(db) - /// } - public static func select(_ selection: SQLSelectable..., as type: RowDecoder.Type) -> QueryInterfaceRequest { - return all().select(selection, as: type) - } - - /// Creates a request which selects *sql*, and fetches values of - /// type *type*. - /// - /// try dbQueue.read { db in - /// // SELECT max(score) FROM player - /// let request = Player.select(sql: "max(score)", as: Int.self) - /// let maxScore: Int? = try request.fetchOne(db) - /// } - public static func select(sql: String, arguments: StatementArguments = StatementArguments(), as type: RowDecoder.Type) -> QueryInterfaceRequest { - return all().select(literal: SQLLiteral(sql: sql, arguments: arguments), as: type) - } - - /// Creates a request which selects an SQL *literal*, and fetches values of - /// type *type*. - /// - /// try dbQueue.read { db in - /// // SELECT max(score) FROM player - /// let request = Player.select(literal: SQLLiteral(sql: "max(score)"), as: Int.self) - /// let maxScore: Int? = try request.fetchOne(db) - /// } - public static func select(literal sqlLiteral: SQLLiteral, as type: RowDecoder.Type) -> QueryInterfaceRequest { - return all().select(literal: sqlLiteral, as: type) - } - - /// Creates a request which appends *selection*. - /// - /// // SELECT id, email, name FROM player - /// le request = Player - /// .select([Column("id"), Column("email")]) - /// .annotated(with: [Column("name")]) - public static func annotated(with selection: [SQLSelectable]) -> QueryInterfaceRequest { - return all().annotated(with: selection) - } - - /// Creates a request which appends *selection*. - /// - /// // SELECT id, email, name FROM player - /// le request = Player - /// .select([Column("id"), Column("email")]) - /// .annotated(with: Column("name")) - public static func annotated(with selection: SQLSelectable...) -> QueryInterfaceRequest { - return all().annotated(with: selection) - } - - /// Creates a request with the provided *predicate*. - /// - /// // SELECT * FROM player WHERE email = 'arthur@example.com' - /// let request = Player.filter(Column("email") == "arthur@example.com") - /// - /// The selection defaults to all columns. This default can be changed for - /// all requests by the `TableRecord.databaseSelection` property, or - /// for individual requests with the `TableRecord.select` method. - public static func filter(_ predicate: SQLExpressible) -> QueryInterfaceRequest { - return all().filter(predicate) - } - - /// Creates a request with the provided primary key *predicate*. - /// - /// // SELECT * FROM player WHERE id = 1 - /// let request = Player.filter(key: 1) - /// - /// The selection defaults to all columns. This default can be changed for - /// all requests by the `TableRecord.databaseSelection` property, or - /// for individual requests with the `TableRecord.select` method. - public static func filter(key: PrimaryKeyType?) -> QueryInterfaceRequest { - return all().filter(key: key) - } - - /// Creates a request with the provided primary key *predicate*. - /// - /// // SELECT * FROM player WHERE id IN (1, 2, 3) - /// let request = Player.filter(keys: [1, 2, 3]) - /// - /// The selection defaults to all columns. This default can be changed for - /// all requests by the `TableRecord.databaseSelection` property, or - /// for individual requests with the `TableRecord.select` method. - public static func filter(keys: Sequence) -> QueryInterfaceRequest where Sequence.Element: DatabaseValueConvertible { - return all().filter(keys: keys) - } - - /// Creates a request with the provided primary key *predicate*. - /// - /// // SELECT * FROM passport WHERE personId = 1 AND countryCode = 'FR' - /// let request = Passport.filter(key: ["personId": 1, "countryCode": "FR"]) - /// - /// When executed, this request raises a fatal error if there is no unique - /// index on the key columns. - /// - /// The selection defaults to all columns. This default can be changed for - /// all requests by the `TableRecord.databaseSelection` property, or - /// for individual requests with the `TableRecord.select` method. - public static func filter(key: [String: DatabaseValueConvertible?]?) -> QueryInterfaceRequest { - return all().filter(key: key) - } - - /// Creates a request with the provided primary key *predicate*. - /// - /// // SELECT * FROM passport WHERE (personId = 1 AND countryCode = 'FR') OR ... - /// let request = Passport.filter(keys: [["personId": 1, "countryCode": "FR"], ...]) - /// - /// When executed, this request raises a fatal error if there is no unique - /// index on the key columns. - /// - /// The selection defaults to all columns. This default can be changed for - /// all requests by the `TableRecord.databaseSelection` property, or - /// for individual requests with the `TableRecord.select` method. - public static func filter(keys: [[String: DatabaseValueConvertible?]]) -> QueryInterfaceRequest { - return all().filter(keys: keys) - } - - /// Creates a request with the provided *predicate*. - /// - /// // SELECT * FROM player WHERE email = 'arthur@example.com' - /// let request = Player.filter(sql: "email = ?", arguments: ["arthur@example.com"]) - /// - /// The selection defaults to all columns. This default can be changed for - /// all requests by the `TableRecord.databaseSelection` property, or - /// for individual requests with the `TableRecord.select` method. - public static func filter(sql: String, arguments: StatementArguments = StatementArguments()) -> QueryInterfaceRequest { - return filter(literal: SQLLiteral(sql: sql, arguments: arguments)) - } - - /// Creates a request with the provided *predicate*. - /// - /// // SELECT * FROM player WHERE email = 'arthur@example.com' - /// let request = Player.filter(literal: SQLLiteral(sql: "email = ?", arguments: ["arthur@example.com"])) - /// - /// With Swift 5, you can safely embed raw values in your SQL queries, - /// without any risk of syntax errors or SQL injection: - /// - /// let request = Player.filter(literal: "name = \("O'Brien")) - /// - /// The selection defaults to all columns. This default can be changed for - /// all requests by the `TableRecord.databaseSelection` property, or - /// for individual requests with the `TableRecord.select` method. - public static func filter(literal sqlLiteral: SQLLiteral) -> QueryInterfaceRequest { - // NOT TESTED - return all().filter(literal: sqlLiteral) - } - - /// Creates a request sorted according to the - /// provided *orderings*. - /// - /// // SELECT * FROM player ORDER BY name - /// let request = Player.order(Column("name")) - /// - /// The selection defaults to all columns. This default can be changed for - /// all requests by the `TableRecord.databaseSelection` property, or - /// for individual requests with the `TableRecord.select` method. - public static func order(_ orderings: SQLOrderingTerm...) -> QueryInterfaceRequest { - return all().order(orderings) - } - - /// Creates a request sorted according to the - /// provided *orderings*. - /// - /// // SELECT * FROM player ORDER BY name - /// let request = Player.order([Column("name")]) - /// - /// The selection defaults to all columns. This default can be changed for - /// all requests by the `TableRecord.databaseSelection` property, or - /// for individual requests with the `TableRecord.select` method. - public static func order(_ orderings: [SQLOrderingTerm]) -> QueryInterfaceRequest { - return all().order(orderings) - } - - /// Creates a request sorted by primary key. - /// - /// // SELECT * FROM player ORDER BY id - /// let request = Player.orderByPrimaryKey() - /// - /// // SELECT * FROM country ORDER BY code - /// let request = Country.orderByPrimaryKey() - /// - /// The selection defaults to all columns. This default can be changed for - /// all requests by the `TableRecord.databaseSelection` property, or - /// for individual requests with the `TableRecord.select` method. - public static func orderByPrimaryKey() -> QueryInterfaceRequest { - return all().orderByPrimaryKey() - } - - /// Creates a request sorted according to *sql*. - /// - /// // SELECT * FROM player ORDER BY name - /// let request = Player.order(sql: "name") - /// - /// The selection defaults to all columns. This default can be changed for - /// all requests by the `TableRecord.databaseSelection` property, or - /// for individual requests with the `TableRecord.select` method. - public static func order(sql: String, arguments: StatementArguments = StatementArguments()) -> QueryInterfaceRequest { - return all().order(literal: SQLLiteral(sql: sql, arguments: arguments)) - } - - /// Creates a request sorted according to an SQL *literal*. - /// - /// // SELECT * FROM player ORDER BY name - /// let request = Player.order(literal: SQLLiteral(sql: "name")) - /// - /// With Swift 5, you can safely embed raw values in your SQL queries, - /// without any risk of syntax errors or SQL injection: - /// - /// // SELECT * FROM player ORDER BY name - /// let request = Player.order(literal: "name")) - /// - /// The selection defaults to all columns. This default can be changed for - /// all requests by the `TableRecord.databaseSelection` property, or - /// for individual requests with the `TableRecord.select` method. - public static func order(literal sqlLiteral: SQLLiteral) -> QueryInterfaceRequest { - return all().order(literal: sqlLiteral) - } - - /// Creates a request which fetches *limit* rows, starting at - /// *offset*. - /// - /// // SELECT * FROM player LIMIT 1 - /// let request = Player.limit(1) - /// - /// The selection defaults to all columns. This default can be changed for - /// all requests by the `TableRecord.databaseSelection` property, or - /// for individual requests with the `TableRecord.select` method. - public static func limit(_ limit: Int, offset: Int? = nil) -> QueryInterfaceRequest { - return all().limit(limit, offset: offset) - } - - /// Creates a request that allows you to define expressions that target - /// a specific database table. - /// - /// In the example below, the "team.avgScore < player.score" condition in - /// the ON clause could be not achieved without table aliases. - /// - /// struct Player: TableRecord { - /// static let team = belongsTo(Team.self) - /// } - /// - /// // SELECT player.*, team.* - /// // JOIN team ON ... AND team.avgScore < player.score - /// let playerAlias = TableAlias() - /// let request = Player - /// .aliased(playerAlias) - /// .including(required: Player.team.filter(Column("avgScore") < playerAlias[Column("score")]) - public static func aliased(_ alias: TableAlias) -> QueryInterfaceRequest { - return all().aliased(alias) - } -} diff --git a/GRDB/QueryInterface/RequestProtocols.swift b/GRDB/QueryInterface/Request/RequestProtocols.swift similarity index 100% rename from GRDB/QueryInterface/RequestProtocols.swift rename to GRDB/QueryInterface/Request/RequestProtocols.swift diff --git a/GRDB/QueryInterface/Row+QueryInterface.swift b/GRDB/QueryInterface/Row+QueryInterfaceRequest.swift similarity index 98% rename from GRDB/QueryInterface/Row+QueryInterface.swift rename to GRDB/QueryInterface/Row+QueryInterfaceRequest.swift index 33097f021..4efd97c5e 100644 --- a/GRDB/QueryInterface/Row+QueryInterface.swift +++ b/GRDB/QueryInterface/Row+QueryInterfaceRequest.swift @@ -145,7 +145,7 @@ extension Row { // CAUTION: Keep this code in sync with QueryInterfaceRequest.databaseRegion(_:) for association in associations { - let pivotMapping = try association.pivotCondition.columnMapping(db) + let pivotMappings = try association.pivot.condition.columnMappings(db) let prefetchedRows: [[DatabaseValue] : [Row]] do { @@ -170,7 +170,7 @@ extension Row { // // FROM book // // WHERE authorId IN (1, 2, 3) // Author.including(all: Author.books) - let pivotColumns = pivotMapping.map { $0.right } + let pivotColumns = pivotMappings.map { $0.right } let pivotAlias = TableAlias() let prefetchedRelation = association .mapPivotRelation { $0.qualified(with: pivotAlias) } @@ -182,7 +182,7 @@ extension Row { // TODO: can we remove those grdb_ columns now that grouping has been done? } - let groupingIndexes = firstRow.indexes(ofColumns: pivotMapping.map { $0.left }) + let groupingIndexes = firstRow.indexes(ofColumns: pivotMappings.map { $0.left }) for row in rows { let groupingKey = groupingIndexes.map { row.impl.databaseValue(atUncheckedIndex: $0) } let prefetchedRows = prefetchedRows[groupingKey, default: []] diff --git a/GRDB/QueryInterface/Column.swift b/GRDB/QueryInterface/SQL/Column.swift similarity index 100% rename from GRDB/QueryInterface/Column.swift rename to GRDB/QueryInterface/SQL/Column.swift diff --git a/GRDB/QueryInterface/DatabasePromise.swift b/GRDB/QueryInterface/SQL/DatabasePromise.swift similarity index 100% rename from GRDB/QueryInterface/DatabasePromise.swift rename to GRDB/QueryInterface/SQL/DatabasePromise.swift diff --git a/GRDB/QueryInterface/SQL/SQLAssociation.swift b/GRDB/QueryInterface/SQL/SQLAssociation.swift new file mode 100644 index 000000000..a918fcea5 --- /dev/null +++ b/GRDB/QueryInterface/SQL/SQLAssociation.swift @@ -0,0 +1,353 @@ +// MARK: - SQLAssociation + +/// An SQL association is a non-empty chain of steps which starts at the +/// "pivot" and ends on the "destination": +/// +/// // SELECT origin.*, destination.* +/// // FROM origin +/// // JOIN pivot ON ... +/// // JOIN ... +/// // JOIN ... +/// // JOIN destination ON ... +/// Origin.including(required: association) +/// +/// For direct associations such as BelongTo or HasMany, the chain contains a +/// single element, the "destination", without intermediate step: +/// +/// // "Origin" belongsTo "destination": +/// // SELECT origin.*, destination.* +/// // FROM origin +/// // JOIN destination ON destination.originId = origin.id +/// let association = Origin.belongsTo(Destination.self) +/// Origin.including(required: association) +/// +/// Indirect associations such as HasManyThrough have one or several +/// intermediate steps: +/// +/// // "Origin" has many "destination" through "pivot": +/// // SELECT origin.*, destination.* +/// // FROM origin +/// // JOIN pivot ON pivot.originId = origin.id +/// // JOIN destination ON destination.id = pivot.destinationId +/// let association = Origin.hasMany( +/// Destination.self, +/// through: Origin.hasMany(Pivot.self), +/// via: Pivot.belongsTo(Destination.self)) +/// Origin.including(required: association) +/// +/// // "Origin" has many "destination" through "pivot1" and "pivot2": +/// // SELECT origin.*, destination.* +/// // FROM origin +/// // JOIN pivot1 ON pivot1.originId = origin.id +/// // JOIN pivot2 ON pivot2.pivot1Id = pivot1.id +/// // JOIN destination ON destination.id = pivot.destinationId +/// let association = Origin.hasMany( +/// Destination.self, +/// through: Origin.hasMany(Pivot1.self), +/// via: Pivot1.hasMany( +/// Destination.self, +/// through: Pivot1.hasMany(Pivot2.self), +/// via: Pivot2.belongsTo(Destination.self))) +/// Origin.including(required: association) +/// +/// :nodoc: +public /* TODO: internal */ struct SQLAssociation { + // All steps, from pivot to destination. Never empty. + private(set) var steps: [SQLAssociationStep] + var keyPath: [String] { + return steps.map { $0.key.name(for: $0.cardinality) } + } + + var destination: SQLAssociationStep { + get { return steps[steps.count - 1] } + set { steps[steps.count - 1] = newValue } + } + + var pivot: SQLAssociationStep { + get { return steps[0] } + set { steps[0] = newValue } + } + + init(steps: [SQLAssociationStep]) { + assert(!steps.isEmpty) + self.steps = steps + } + + init( + key: SQLAssociationKey, + condition: SQLAssociationCondition, + relation: SQLRelation, + cardinality: SQLAssociationCardinality) + { + let step = SQLAssociationStep( + key: key, + condition: condition, + relation: relation, + cardinality: cardinality) + self.init(steps: [step]) + } + + /// Changes the destination key + func forDestinationKey(_ key: SQLAssociationKey) -> SQLAssociation { + var result = self + result.destination.key = key + return result + } + + /// Transforms the destination relation + func mapDestinationRelation(_ transform: (SQLRelation) -> SQLRelation) -> SQLAssociation { + var result = self + result.destination = result.destination.mapRelation(transform) + return result + } + + /// Transforms the pivot relation + func mapPivotRelation(_ transform: (SQLRelation) -> SQLRelation) -> SQLAssociation { + var result = self + result.pivot = result.pivot.mapRelation(transform) + return result + } + + /// Returns a new association + func through(_ other: SQLAssociation) -> SQLAssociation { + return SQLAssociation(steps: other.steps + steps) + } + + /// Given an origin alias and rows, returns the destination of the + /// association as a relation. + /// + /// This method provides support for association methods such + /// as `request(for:)`: + /// + /// struct Destination: TableRecord { } + /// struct Origin: TableRecord, EncodableRecord { + /// static let destinations = hasMany(Destination.self) + /// var destinations: QueryInterface { + /// return request(for: Origin.destinations) + /// } + /// } + /// + /// // SELECT destination.* + /// // FROM destination + /// // WHERE destination.originId = 1 + /// let origin = Origin(id: 1) + /// let destinations = origin.destinations.fetchAll(db) + /// + /// At low-level, this gives: + /// + /// let origin = Origin(id: 1) + /// let originAlias = TableAlias(tableName: Origin.databaseTableName) + /// let sqlAssociation = Origin.destination.sqlAssociation + /// let destinationRelation = sqlAssociation.destinationRelation( + /// from: originAlias, + /// rows: { db in try [Row(PersistenceContainer(db, origin))] }) + /// let query = SQLQuery(relation: destinationRelation) + /// let generator = SQLQueryGenerator(query) + /// let statement, _ = try generator.prepare(db) + /// print(statement.sql) + /// // SELECT destination.* + /// // FROM destination + /// // WHERE destination.originId = 1 + /// + /// This method works for simple direct associations such as BelongsTo or + /// HasMany in the above examples, but also for indirect associations such + /// as HasManyThrough, which have any number of pivot relations between the + /// origin and the destination. + func destinationRelation(fromOriginRows originRows: @escaping (Database) throws -> [Row]) -> SQLRelation { + // Filter the pivot + let pivot = self.pivot + let pivotAlias = TableAlias() + let filteredPivotRelation = pivot.relation + .qualified(with: pivotAlias) + .filter({ db in + // `pivot.originId = 123` or `pivot.originId IN (1, 2, 3)` + try pivot.condition.filteringExpression(db, leftRows: originRows(db), rightAlias: pivotAlias) + }) + + if steps.count == 1 { + // This is a direct join from origin to destination, without + // intermediate step. + // + // SELECT destination.* + // FROM destination + // WHERE destination.originId = 1 + // + // let association = Origin.hasMany(Destination.self) + // Origin(id: 1).request(for: association) + return filteredPivotRelation + } + + // This is an indirect join from origin to destination, through + // some intermediate steps: + // + // SELECT destination.* + // FROM destination + // JOIN pivot ON (pivot.destinationId = destination.id) AND (pivot.originId = 1) + // + // let association = Origin.hasMany( + // Destination.self, + // through: Origin.hasMany(Pivot.self), + // via: Pivot.belongsTo(Destination.self)) + // Origin(id: 1).request(for: association) + let reversedSteps = zip(steps, steps.dropFirst()) + .map { (step, nextStep) -> SQLAssociationStep in + // Intermediate steps are not included in the selection, and + // don't have any child. + let relation = step.relation.select([]).deletingChildren() + return SQLAssociationStep( + key: step.key, + condition: nextStep.condition.reversed, + relation: relation, + cardinality: step.cardinality) + } + .reversed() + + var reversedAssociation = SQLAssociation(steps: Array(reversedSteps)) + // Replace pivot with the filtered one (not included in the selection, + // without children). + reversedAssociation = reversedAssociation.mapDestinationRelation { _ in + filteredPivotRelation.select([]).deletingChildren() + } + return destination.relation.appending(reversedAssociation, kind: .oneRequired) + } +} + +struct SQLAssociationStep { + var key: SQLAssociationKey + var condition: SQLAssociationCondition + var relation: SQLRelation + var cardinality: SQLAssociationCardinality + + func mapRelation(_ transform: (SQLRelation) -> SQLRelation) -> SQLAssociationStep { + return SQLAssociationStep( + key: key, + condition: condition, + relation: transform(relation), + cardinality: cardinality) + } +} + +enum SQLAssociationCardinality { + case toOne + case toMany +} + +// MARK: - SQLAssociationKey + +/// Associations are meant to be consumed, most often into Decodable records. +/// +/// Those records have singular or plural property names, and we want +/// associations to be able to fill those singular or plural names +/// automatically, so that the user does not have to perform explicit +/// decoding configuration. +/// +/// Those plural or singular names are not decided when the association is +/// defined. For example, the Author.books association, which looks plural, may +/// actually generate "book" or "books" depending on the context: +/// +/// struct Author: TableRecord { +/// static let books = hasMany(Book.self) +/// } +/// struct Book: TableRecord { +/// } +/// +/// // "books" +/// struct AuthorInfo: FetchableRecord, Decodable { +/// var author: Author +/// var books: [Book] +/// } +/// let request = Author.including(all: Author.books) +/// let authorInfos = try AuthorInfo.fetchAll(db, request) +/// +/// "book" +/// struct AuthorInfo: FetchableRecord, Decodable { +/// var author: Author +/// var book: Book +/// } +/// let request = Author.including(required: Author.books) +/// let authorInfos = try AuthorInfo.fetchAll(db, request) +/// +/// "bookCount" +/// struct AuthorInfo: FetchableRecord, Decodable { +/// var author: Author +/// var bookCount: Int +/// } +/// let request = Author.annotated(with: Author.books.count) +/// let authorInfos = try AuthorInfo.fetchAll(db, request) +/// +/// The SQLAssociationKey type aims at providing the necessary support for +/// those various inflections. +enum SQLAssociationKey { + /// A key that is inflected in singular and plural contexts. + /// + /// For example: + /// + /// struct Author: TableRecord { + /// static let databaseTableName = "authors" + /// } + /// struct Book: TableRecord { + /// let author = belongsTo(Author.self) + /// } + /// + /// let request = Book.including(required: Book.author) + /// let row = try Row.fetchOne(db, request)! + /// row.scopes["author"] // singularized "authors" table name + case inflected(String) + + /// A key that is inflected in plural contexts, but stricly honors + /// user-provided name in singular contexts. + /// + /// For example: + /// + /// struct Country: TableRecord { + /// let demographics = hasOne(Demographics.self, key: "demographics") + /// } + /// + /// let request = Country.including(required: Country.demographics) + /// let row = try Row.fetchOne(db, request)! + /// row.scopes["demographics"] // not singularized + case fixedSingular(String) + + /// A key that is inflected in singular contexts, but stricly honors + /// user-provided name in plural contexts. + /// See .inflected and .fixedSingular for some context. + case fixedPlural(String) + + /// A key that is never inflected. + case fixed(String) + + func name(for cardinality: SQLAssociationCardinality) -> String { + switch cardinality { + case .toOne: + return singularizedName + case .toMany: + return pluralizedName + } + } + + var pluralizedName: String { + switch self { + case .inflected(let name): + return name.pluralized + case .fixedSingular(let name): + return name.pluralized + case .fixedPlural(let name): + return name + case .fixed(let name): + return name + } + } + + var singularizedName: String { + switch self { + case .inflected(let name): + return name.singularized + case .fixedSingular(let name): + return name + case .fixedPlural(let name): + return name.singularized + case .fixed(let name): + return name + } + } +} diff --git a/GRDB/QueryInterface/SQLCollatedExpression.swift b/GRDB/QueryInterface/SQL/SQLCollatedExpression.swift similarity index 100% rename from GRDB/QueryInterface/SQLCollatedExpression.swift rename to GRDB/QueryInterface/SQL/SQLCollatedExpression.swift diff --git a/GRDB/QueryInterface/SQLCollection.swift b/GRDB/QueryInterface/SQL/SQLCollection.swift similarity index 100% rename from GRDB/QueryInterface/SQLCollection.swift rename to GRDB/QueryInterface/SQL/SQLCollection.swift diff --git a/GRDB/QueryInterface/SQLExpressible.swift b/GRDB/QueryInterface/SQL/SQLExpressible.swift similarity index 100% rename from GRDB/QueryInterface/SQLExpressible.swift rename to GRDB/QueryInterface/SQL/SQLExpressible.swift diff --git a/GRDB/QueryInterface/SQLExpression+QueryInterface.swift b/GRDB/QueryInterface/SQL/SQLExpression+QueryInterface.swift similarity index 100% rename from GRDB/QueryInterface/SQLExpression+QueryInterface.swift rename to GRDB/QueryInterface/SQL/SQLExpression+QueryInterface.swift diff --git a/GRDB/QueryInterface/SQLExpression.swift b/GRDB/QueryInterface/SQL/SQLExpression.swift similarity index 100% rename from GRDB/QueryInterface/SQLExpression.swift rename to GRDB/QueryInterface/SQL/SQLExpression.swift diff --git a/GRDB/QueryInterface/Association/ForeignKeyRequest.swift b/GRDB/QueryInterface/SQL/SQLForeignKeyRequest.swift similarity index 96% rename from GRDB/QueryInterface/Association/ForeignKeyRequest.swift rename to GRDB/QueryInterface/SQL/SQLForeignKeyRequest.swift index 580b665aa..8514256da 100644 --- a/GRDB/QueryInterface/Association/ForeignKeyRequest.swift +++ b/GRDB/QueryInterface/SQL/SQLForeignKeyRequest.swift @@ -1,11 +1,11 @@ -/// ForeignKeyRequest looks for the foreign keys associations need to +/// SQLForeignKeyRequest looks for the foreign keys associations need to /// join tables. /// /// Mappings come from foreign keys, when they exist in the database schema. /// /// When the schema does not define any foreign key, we can still infer complete /// mappings from partial information and primary keys. -struct ForeignKeyRequest: Equatable { +struct SQLForeignKeyRequest: Equatable { let originTable: String let destinationTable: String let originColumns: [String]? diff --git a/GRDB/QueryInterface/Support/SQLFunctions.swift b/GRDB/QueryInterface/SQL/SQLFunctions.swift similarity index 100% rename from GRDB/QueryInterface/Support/SQLFunctions.swift rename to GRDB/QueryInterface/SQL/SQLFunctions.swift diff --git a/GRDB/QueryInterface/Support/SQLOperators.swift b/GRDB/QueryInterface/SQL/SQLOperators.swift similarity index 100% rename from GRDB/QueryInterface/Support/SQLOperators.swift rename to GRDB/QueryInterface/SQL/SQLOperators.swift diff --git a/GRDB/QueryInterface/SQLOrdering.swift b/GRDB/QueryInterface/SQL/SQLOrdering.swift similarity index 100% rename from GRDB/QueryInterface/SQLOrdering.swift rename to GRDB/QueryInterface/SQL/SQLOrdering.swift diff --git a/GRDB/QueryInterface/SQLSelectQuery.swift b/GRDB/QueryInterface/SQL/SQLQuery.swift similarity index 80% rename from GRDB/QueryInterface/SQLSelectQuery.swift rename to GRDB/QueryInterface/SQL/SQLQuery.swift index b5ebc68f7..3d0ba88f7 100644 --- a/GRDB/QueryInterface/SQLSelectQuery.swift +++ b/GRDB/QueryInterface/SQL/SQLQuery.swift @@ -1,7 +1,7 @@ -/// SQLSelectQuery is a representation of an SQL SELECT query. +/// SQLQuery is a representation of an SQL query. /// -/// See SQLSelectQueryGenerator for actual SQL generation. -struct SQLSelectQuery { +/// See SQLQueryGenerator for actual SQL generation. +struct SQLQuery { var relation: SQLRelation var isDistinct: Bool var expectsSingleResult: Bool @@ -26,38 +26,38 @@ struct SQLSelectQuery { } } -extension SQLSelectQuery: SelectionRequest, FilteredRequest, OrderedRequest { - func select(_ selection: [SQLSelectable]) -> SQLSelectQuery { +extension SQLQuery: SelectionRequest, FilteredRequest, OrderedRequest { + func select(_ selection: [SQLSelectable]) -> SQLQuery { return mapRelation { $0.select(selection) } } - func annotated(with selection: [SQLSelectable]) -> SQLSelectQuery { + func annotated(with selection: [SQLSelectable]) -> SQLQuery { return mapRelation { $0.annotated(with: selection) } } - func distinct() -> SQLSelectQuery { + func distinct() -> SQLQuery { var query = self query.isDistinct = true return query } - func expectingSingleResult() -> SQLSelectQuery { + func expectingSingleResult() -> SQLQuery { var query = self query.expectsSingleResult = true return query } - func filter(_ predicate: @escaping (Database) throws -> SQLExpressible) -> SQLSelectQuery { + func filter(_ predicate: @escaping (Database) throws -> SQLExpressible) -> SQLQuery { return mapRelation { $0.filter(predicate) } } - func group(_ expressions: @escaping (Database) throws -> [SQLExpressible]) -> SQLSelectQuery { + func group(_ expressions: @escaping (Database) throws -> [SQLExpressible]) -> SQLQuery { var query = self query.groupPromise = DatabasePromise { db in try expressions(db).map { $0.sqlExpression } } return query } - func having(_ predicate: SQLExpressible) -> SQLSelectQuery { + func having(_ predicate: SQLExpressible) -> SQLQuery { var query = self if let havingExpression = query.havingExpression { query.havingExpression = (havingExpression && predicate).sqlExpression @@ -67,43 +67,43 @@ extension SQLSelectQuery: SelectionRequest, FilteredRequest, OrderedRequest { return query } - func order(_ orderings: @escaping (Database) throws -> [SQLOrderingTerm]) -> SQLSelectQuery { + func order(_ orderings: @escaping (Database) throws -> [SQLOrderingTerm]) -> SQLQuery { return mapRelation { $0.order(orderings) } } - func reversed() -> SQLSelectQuery { + func reversed() -> SQLQuery { return mapRelation { $0.reversed() } } - func unordered() -> SQLSelectQuery { + func unordered() -> SQLQuery { return mapRelation { $0.unordered() } } - func limit(_ limit: Int, offset: Int? = nil) -> SQLSelectQuery { + func limit(_ limit: Int, offset: Int? = nil) -> SQLQuery { var query = self query.limit = SQLLimit(limit: limit, offset: offset) return query } - func qualified(with alias: TableAlias) -> SQLSelectQuery { + func qualified(with alias: TableAlias) -> SQLQuery { return mapRelation { $0.qualified(with: alias) } } /// Returns a query whose relation is transformed by the given closure. - func mapRelation(_ transform: (SQLRelation) -> SQLRelation) -> SQLSelectQuery { + func mapRelation(_ transform: (SQLRelation) -> SQLRelation) -> SQLQuery { var query = self query.relation = transform(relation) return query } } -extension SQLSelectQuery { +extension SQLQuery { func fetchCount(_ db: Database) throws -> Int { - let (statement, adapter) = try SQLSelectQueryGenerator(countQuery).prepare(db) + let (statement, adapter) = try SQLQueryGenerator(countQuery).prepare(db) return try Int.fetchOne(statement, adapter: adapter)! } - private var countQuery: SQLSelectQuery { + private var countQuery: SQLQuery { guard groupPromise == nil && limit == nil else { // SELECT ... GROUP BY ... // SELECT ... LIMIT ... @@ -149,11 +149,11 @@ extension SQLSelectQuery { } // SELECT COUNT(*) FROM (self) - private var trivialCountQuery: SQLSelectQuery { + private var trivialCountQuery: SQLQuery { let relation = SQLRelation( source: .query(unordered()), selection: [SQLExpressionCount(AllColumns())]) - return SQLSelectQuery(relation: relation) + return SQLQuery(relation: relation) } } diff --git a/GRDB/QueryInterface/SQLRelation.swift b/GRDB/QueryInterface/SQL/SQLRelation.swift similarity index 78% rename from GRDB/QueryInterface/SQLRelation.swift rename to GRDB/QueryInterface/SQL/SQLRelation.swift index 4e66edbc4..dfc2c8479 100644 --- a/GRDB/QueryInterface/SQLRelation.swift +++ b/GRDB/QueryInterface/SQL/SQLRelation.swift @@ -12,7 +12,7 @@ /// • selection /// /// Other SQL clauses such as GROUP BY, LIMIT are defined one level up, in the -/// SQLSelectQuery type. +/// SQLQuery type. /// /// ## Promises /// @@ -110,12 +110,12 @@ struct SQLRelation { // Record.including(all: associationThroughPivot) case allNotPrefetched - var isSingular: Bool { + var cardinality: SQLAssociationCardinality { switch self { case .oneOptional, .oneRequired: - return true + return .toOne case .allPrefetched, .allNotPrefetched: - return false + return .toMany } } } @@ -139,7 +139,11 @@ struct SQLRelation { fileprivate func makeAssociationForKey(_ key: String) -> SQLAssociation { let key = SQLAssociationKey.fixed(key) - return SQLAssociation(key: key, condition: condition, relation: relation, isSingular: kind.isSingular) + return SQLAssociation( + key: key, + condition: condition, + relation: relation, + cardinality: kind.cardinality) } func mapRelation(_ transform: (SQLRelation) -> SQLRelation) -> Child { @@ -227,7 +231,147 @@ extension SQLRelation { return relation } - func appendingChild(_ child: SQLRelation.Child, forKey key: String) -> SQLRelation { + func qualified(with alias: TableAlias) -> SQLRelation { + var relation = self + relation.source = source.qualified(with: alias) + return relation + } +} + +extension SQLRelation { + func deletingChildren() -> SQLRelation { + var relation = self + relation.children = [:] + return relation + } + + /// Creates a relation that prefetches another one. + func including(all association: SQLAssociation) -> SQLRelation { + return appending(association, kind: .allPrefetched) + } + + /// Creates a relation that includes another one. The columns of the + /// associated record are selected. The returned relation does not + /// require that the associated database table contains a matching row. + func including(optional association: SQLAssociation) -> SQLRelation { + return appending(association, kind: .oneOptional) + } + + /// Creates a relation that includes another one. The columns of the + /// associated record are selected. The returned relation requires + /// that the associated database table contains a matching row. + func including(required association: SQLAssociation) -> SQLRelation { + return appending(association, kind: .oneRequired) + } + + /// Creates a relation that joins another one. The columns of the + /// associated record are not selected. The returned relation does not + /// require that the associated database table contains a matching row. + func joining(optional association: SQLAssociation) -> SQLRelation { + return appending(association.mapDestinationRelation { $0.select([]) }, kind: .oneOptional) + } + + /// Creates a relation that joins another one. The columns of the + /// associated record are not selected. The returned relation requires + /// that the associated database table contains a matching row. + func joining(required association: SQLAssociation) -> SQLRelation { + return appending(association.mapDestinationRelation { $0.select([]) }, kind: .oneRequired) + } + + /// Returns a relation extended with an association. + /// + /// This method provides support for public joining methods such + /// as `including(required:)`: + /// + /// struct Destination: TableRecord { } + /// struct Origin: TableRecord { + /// static let destination = belongsTo(Destination.self) + /// } + /// + /// // SELECT origin.*, destination.* + /// // FROM origin + /// // JOIN destination ON destination.id = origin.destinationId + /// let request = Origin.including(required: Origin.destination) + /// + /// At low-level, this gives: + /// + /// let sqlAssociation = Origin.destination.sqlAssociation + /// let origin = Origin.all().query.relation + /// let relation = origin.appending(sqlAssociation, kind: .oneRequired) + /// let query = SQLQuery(relation: relation) + /// let generator = SQLQueryGenerator(query) + /// let statement, _ = try generator.prepare(db) + /// print(statement.sql) + /// // SELECT origin.*, destination.* + /// // FROM origin + /// // JOIN destination ON destination.originId = origin.id + /// + /// This method works for simple direct associations such as BelongsTo or + /// HasMany in the above examples, but also for indirect associations such + /// as HasManyThrough, which have any number of pivot relations between the + /// origin and the destination. + func appending(_ association: SQLAssociation, kind: SQLRelation.Child.Kind) -> SQLRelation { + let destinationChildKey = association.destination.key.name(for: kind.cardinality) + let destinationChild = SQLRelation.Child( + kind: kind, + condition: association.destination.condition, + relation: association.destination.relation) + + let initialSteps = association.steps.dropLast() + if initialSteps.isEmpty { + // This is a direct join from origin to destination, without + // intermediate step. + // + // SELECT origin.*, destination.* + // FROM origin + // JOIN destination ON destination.id = origin.destinationId + // + // let association = Origin.belongsTo(Destination.self) + // Origin.including(required: association) + return appendingChild(destinationChild, forKey: destinationChildKey) + } + + // This is an indirect join from origin to destination, through + // some pivot(s): + // + // SELECT origin.*, destination.* + // FROM origin + // JOIN pivot ON pivot.originId = origin.id + // JOIN destination ON destination.id = pivot.destinationId + // + // let association = Origin.hasMany( + // Destination.self, + // through: Origin.hasMany(Pivot.self), + // via: Pivot.belongsTo(Destination.self)) + // Origin.including(required: association) + // + // Let's recurse toward a direct join, by making a new association which + // ends on the last pivot, to which we join our destination: + var reducedAssociation = SQLAssociation(steps: Array(initialSteps)) + + reducedAssociation.destination.relation = reducedAssociation.destination.relation + .select([]) // Intermediate steps are not prefetched + .appendingChild(destinationChild, forKey: destinationChildKey) + + switch kind { + case .oneRequired, .oneOptional, .allNotPrefetched: + return appending(reducedAssociation, kind: kind) + case .allPrefetched: + // Intermediate steps of indirect associations are not prefetched. + // + // For example, the request below prefetches citizens, not + // intermediate passports: + // + // extension Country { + // static let passports = hasMany(Passport.self) + // static let citizens = hasMany(Citizens.self, through: passports, using: Passport.citizen) + // } + // let request = Country.including(all: Country.citizens) + return appending(reducedAssociation, kind: .allNotPrefetched) + } + } + + private func appendingChild(_ child: SQLRelation.Child, forKey key: String) -> SQLRelation { var relation = self if let existingChild = relation.children.removeValue(forKey: key) { guard let mergedChild = existingChild.merged(with: child) else { @@ -240,25 +384,13 @@ extension SQLRelation { } return relation } - - func deletingChildren() -> SQLRelation { - var relation = self - relation.children = [:] - return relation - } - - func qualified(with alias: TableAlias) -> SQLRelation { - var relation = self - relation.source = source.qualified(with: alias) - return relation - } } // MARK: - SQLSource enum SQLSource { case table(tableName: String, alias: TableAlias?) - indirect case query(SQLSelectQuery) + indirect case query(SQLQuery) func qualified(with alias: TableAlias) -> SQLSource { switch self { @@ -394,7 +526,7 @@ extension SQLRelation { /// .including(optional: Book.author.filter(condition2)) struct SQLAssociationCondition: Equatable { /// Definition of a foreign key - var foreignKeyRequest: ForeignKeyRequest + var foreignKeyRequest: SQLForeignKeyRequest /// True if the table at the origin of the foreign key is on the left of /// the sql JOIN operator. @@ -422,7 +554,7 @@ struct SQLAssociationCondition: Equatable { } /// Orient foreignKey according to the originIsLeft flag - func columnMapping(_ db: Database) throws -> [(left: String, right: String)] { + func columnMappings(_ db: Database) throws -> [(left: String, right: String)] { let foreignKeyMapping = try foreignKeyRequest.fetchMapping(db) if originIsLeft { return foreignKeyMapping.map { (left: $0.origin, right: $0.destination) } @@ -444,7 +576,7 @@ struct SQLAssociationCondition: Equatable { /// JOIN operator. /// - Returns: An SQL expression. func joinExpression(_ db: Database, leftAlias: TableAlias, rightAlias: TableAlias) throws -> SQLExpression { - return try columnMapping(db) + return try columnMappings(db) .map { QualifiedColumn($0.right, alias: rightAlias) == QualifiedColumn($0.left, alias: leftAlias) } .joined(operator: .and) } @@ -460,7 +592,7 @@ struct SQLAssociationCondition: Equatable { return false.sqlExpression } - let columnMappings = try self.columnMapping(db) + let columnMappings = try self.columnMappings(db) guard let columnMapping = columnMappings.first else { // Degenerate case: no joining column return true.sqlExpression diff --git a/GRDB/QueryInterface/SQLSelectable+QueryInterface.swift b/GRDB/QueryInterface/SQL/SQLSelectable+QueryInterface.swift similarity index 100% rename from GRDB/QueryInterface/SQLSelectable+QueryInterface.swift rename to GRDB/QueryInterface/SQL/SQLSelectable+QueryInterface.swift diff --git a/GRDB/QueryInterface/SQLSelectable.swift b/GRDB/QueryInterface/SQL/SQLSelectable.swift similarity index 100% rename from GRDB/QueryInterface/SQLSelectable.swift rename to GRDB/QueryInterface/SQL/SQLSelectable.swift diff --git a/GRDB/QueryInterface/SQLSpecificExpressible+QueryInterface.swift b/GRDB/QueryInterface/SQL/SQLSpecificExpressible+QueryInterface.swift similarity index 100% rename from GRDB/QueryInterface/SQLSpecificExpressible+QueryInterface.swift rename to GRDB/QueryInterface/SQL/SQLSpecificExpressible+QueryInterface.swift diff --git a/GRDB/QueryInterface/SQLGenerationContext.swift b/GRDB/QueryInterface/SQLGeneration/SQLGenerationContext.swift similarity index 99% rename from GRDB/QueryInterface/SQLGenerationContext.swift rename to GRDB/QueryInterface/SQLGeneration/SQLGenerationContext.swift index b8fff15a8..60d5f4a1b 100644 --- a/GRDB/QueryInterface/SQLGenerationContext.swift +++ b/GRDB/QueryInterface/SQLGeneration/SQLGenerationContext.swift @@ -18,7 +18,7 @@ public struct SQLGenerationContext { qualifierNeeded: false) } - /// Used for SQLSelectQuery.makeSelectStatement() and SQLSelectQuery.makeDeleteStatement() + /// Used for SQLQuery.makeSelectStatement() and SQLQuery.makeDeleteStatement() static func queryGenerationContext(aliases: [TableAlias]) -> SQLGenerationContext { // TODO: since 5d9fa76, in the lines below, we started uniquing aliases. // Something tells me this is a wrong fix. We should try to investigate diff --git a/GRDB/QueryInterface/SQLSelectQueryGenerator.swift b/GRDB/QueryInterface/SQLGeneration/SQLQueryGenerator.swift similarity index 98% rename from GRDB/QueryInterface/SQLSelectQueryGenerator.swift rename to GRDB/QueryInterface/SQLGeneration/SQLQueryGenerator.swift index 96ae7caf3..e40a98579 100644 --- a/GRDB/QueryInterface/SQLSelectQueryGenerator.swift +++ b/GRDB/QueryInterface/SQLGeneration/SQLQueryGenerator.swift @@ -1,12 +1,12 @@ -/// SQLSelectQueryGenerator is able to generate an SQL SELECT query. -struct SQLSelectQueryGenerator { +/// SQLQueryGenerator is able to generate an SQL SELECT query. +struct SQLQueryGenerator { fileprivate let relation: SQLQualifiedRelation private let isDistinct: Bool private let groupPromise: DatabasePromise<[SQLExpression]>? private let havingExpression: SQLExpression? private let limit: SQLLimit? - init(_ query: SQLSelectQuery) { + init(_ query: SQLQuery) { // To generate SQL, we need a "qualified" relation, where all tables, // expressions, etc, are identified with table aliases. // @@ -325,12 +325,12 @@ private struct SQLQualifiedRelation { ownOrdering = relation.ordering.qualified(with: alias) } - /// See SQLSelectQueryGenerator.rowAdapter(_:) + /// See SQLQueryGenerator.rowAdapter(_:) /// /// - parameter db: A database connection. /// - parameter startIndex: The index of the leftmost selected column of /// this relation in a full SQL query. `startIndex` is 0 for the relation - /// at the root of a SQLSelectQueryGenerator (as opposed to the + /// at the root of a SQLQueryGenerator (as opposed to the /// joined relations). /// - returns: An optional tuple made of a RowAdapter and the index past the /// rightmost selected column of this relation. Nil is returned if this @@ -389,7 +389,7 @@ private struct SQLQualifiedRelation { /// A "qualified" source, where all tables are identified with a table alias. private enum SQLQualifiedSource { case table(tableName: String, alias: TableAlias) - indirect case query(SQLSelectQueryGenerator) + indirect case query(SQLQueryGenerator) var alias: TableAlias { switch self { @@ -415,7 +415,7 @@ private enum SQLQualifiedSource { let alias = alias ?? TableAlias(tableName: tableName) self = .table(tableName: tableName, alias: alias) case .query(let query): - self = .query(SQLSelectQueryGenerator(query)) + self = .query(SQLQueryGenerator(query)) } } diff --git a/GRDB/QueryInterface/TableDefinition.swift b/GRDB/QueryInterface/Schema/TableDefinition.swift similarity index 100% rename from GRDB/QueryInterface/TableDefinition.swift rename to GRDB/QueryInterface/Schema/TableDefinition.swift diff --git a/GRDB/QueryInterface/VirtualTableModule.swift b/GRDB/QueryInterface/Schema/VirtualTableModule.swift similarity index 100% rename from GRDB/QueryInterface/VirtualTableModule.swift rename to GRDB/QueryInterface/Schema/VirtualTableModule.swift diff --git a/GRDB/QueryInterface/TableRecord+Association.swift b/GRDB/QueryInterface/TableRecord+Association.swift new file mode 100644 index 000000000..5ea8bf58f --- /dev/null +++ b/GRDB/QueryInterface/TableRecord+Association.swift @@ -0,0 +1,627 @@ +extension TableRecord { + /// Creates a "Belongs To" association between Self and the + /// destination type. + /// + /// struct Author: TableRecord { ... } + /// struct Book: TableRecord { + /// static let author = belongsTo(Author.self) + /// } + /// + /// The association will let you define requests that load both the source + /// and the destination type: + /// + /// // A request for all books with their authors: + /// let request = Book.including(optional: Book.author) + /// + /// To consume those requests, define a type that adopts both the + /// FetchableRecord and Decodable protocols: + /// + /// struct BookInfo: FetchableRecord, Decodable { + /// var book: Book + /// var author: Author? + /// } + /// + /// let bookInfos = try dbQueue.read { db in + /// return try BookInfo.fetchAll(db, request) + /// } + /// for bookInfo in bookInfos { + /// print("\(bookInfo.book.title) by \(bookInfo.author.name)") + /// } + /// + /// It is recommended that you define, alongside the static association, a + /// property with the same name: + /// + /// struct Book: TableRecord, EncodableRecord { + /// static let author = belongsTo(Author.self) + /// var author: QueryInterfaceRequest { + /// return request(for: Book.author) + /// } + /// } + /// + /// This property will let you navigate from the source type to the + /// destination type: + /// + /// try dbQueue.read { db in + /// let book: Book = ... + /// let author = try book.author.fetchOne(db) // Author? + /// } + /// + /// - parameters: + /// - destination: The record type at the other side of the association. + /// - key: An eventual decoding key for the association. By default, it + /// is `destination.databaseTableName`. + /// - foreignKey: An eventual foreign key. You need to provide an + /// explicit foreign key when GRDB can't infer one from the database + /// schema. This happens when the schema does not define any foreign + /// key to the destination table, or when the schema defines several + /// foreign keys to the destination table. + public static func belongsTo( + _ destination: Destination.Type, + key: String? = nil, + using foreignKey: ForeignKey? = nil) + -> BelongsToAssociation + where Destination: TableRecord + { + let foreignKeyRequest = SQLForeignKeyRequest( + originTable: databaseTableName, + destinationTable: Destination.databaseTableName, + foreignKey: foreignKey) + + let condition = SQLAssociationCondition( + foreignKeyRequest: foreignKeyRequest, + originIsLeft: true) + + let associationKey: SQLAssociationKey + if let key = key { + associationKey = .fixedSingular(key) + } else { + associationKey = .inflected(Destination.databaseTableName) + } + + return BelongsToAssociation(sqlAssociation: SQLAssociation( + key: associationKey, + condition: condition, + relation: Destination.all().relation, + cardinality: .toOne)) + } + + /// Creates a "Has many" association between Self and the + /// destination type. + /// + /// struct Book: TableRecord { ... } + /// struct Author: TableRecord { + /// static let books = hasMany(Book.self) + /// } + /// + /// The association will let you define requests that load both the source + /// and the destination type: + /// + /// // A request for all (author, book) pairs: + /// let request = Author.including(required: Author.books) + /// + /// To consume those requests, define a type that adopts both the + /// FetchableRecord and Decodable protocols: + /// + /// struct Authorship: FetchableRecord, Decodable { + /// var author: Author + /// var book: Book + /// } + /// + /// let authorships = try dbQueue.read { db in + /// return try Authorship.fetchAll(db, request) + /// } + /// for authorship in authorships { + /// print("\(authorship.author.name) wrote \(authorship.book.title)") + /// } + /// + /// It is recommended that you define, alongside the static association, a + /// property with the same name: + /// + /// struct Author: TableRecord, EncodableRecord { + /// static let books = hasMany(Book.self) + /// var books: QueryInterfaceRequest { + /// return request(for: Author.books) + /// } + /// } + /// + /// This property will let you navigate from the source type to the + /// destination type: + /// + /// try dbQueue.read { db in + /// let author: Author = ... + /// let books = try author.books.fetchAll(db) // [Book] + /// } + /// + /// - parameters: + /// - destination: The record type at the other side of the association. + /// - key: An eventual decoding key for the association. By default, it + /// is `destination.databaseTableName`. + /// - foreignKey: An eventual foreign key. You need to provide an + /// explicit foreign key when GRDB can't infer one from the database + /// schema. This happens when the schema does not define any foreign + /// key from the destination table, or when the schema defines several + /// foreign keys from the destination table. + public static func hasMany( + _ destination: Destination.Type, + key: String? = nil, + using foreignKey: ForeignKey? = nil) + -> HasManyAssociation + where Destination: TableRecord + { + let foreignKeyRequest = SQLForeignKeyRequest( + originTable: Destination.databaseTableName, + destinationTable: databaseTableName, + foreignKey: foreignKey) + + let condition = SQLAssociationCondition( + foreignKeyRequest: foreignKeyRequest, + originIsLeft: false) + + let associationKey: SQLAssociationKey + if let key = key { + associationKey = .fixedPlural(key) + } else { + associationKey = .inflected(Destination.databaseTableName) + } + + return HasManyAssociation(sqlAssociation: SQLAssociation( + key: associationKey, + condition: condition, + relation: Destination.all().relation, + cardinality: .toMany)) + } + + /// Creates a "Has Many Through" association between Self and the + /// destination type. + /// + /// struct Country: TableRecord { + /// static let passports = hasMany(Passport.self) + /// static let citizens = hasMany(Citizen.self, through: passports, using: Passport.citizen) + /// } + /// + /// struct Passport: TableRecord { + /// static let citizen = belongsTo(Citizen.self) + /// } + /// + /// struct Citizen: TableRecord { } + /// + /// The association will let you define requests that load both the source + /// and the destination type: + /// + /// // A request for all (country, citizen) pairs: + /// let request = Country.including(required: Coutry.citizens) + /// + /// To consume those requests, define a type that adopts both the + /// FetchableRecord and Decodable protocols: + /// + /// struct Citizenship: FetchableRecord, Decodable { + /// var country: Country + /// var citizen: Citizen + /// } + /// + /// let citizenships = try dbQueue.read { db in + /// return try Citizenship.fetchAll(db, request) + /// } + /// for citizenship in citizenships { + /// print("\(citizenship.citizen.name) is a citizen of \(citizenship.country.name)") + /// } + /// + /// It is recommended that you define, alongside the static association, a + /// property with the same name: + /// + /// struct Country: TableRecord, EncodableRecord { + /// static let passports = hasMany(Passport.self) + /// static let citizens = hasMany(Citizen.self, through: passports, using: Passport.citizen) + /// var citizens: QueryInterfaceRequest { + /// return request(for: Country.citizens) + /// } + /// } + /// + /// This property will let you navigate from the source type to the + /// destination type: + /// + /// try dbQueue.read { db in + /// let country: Country = ... + /// let citizens = try country.citizens.fetchAll(db) // [Country] + /// } + /// + /// - parameters: + /// - destination: The record type at the other side of the association. + /// - pivot: An association from Self to the intermediate type. + /// - target: A target association from the intermediate type to the + /// destination type. + /// - key: An eventual decoding key for the association. By default, it + /// is the same key as the target. + public static func hasMany( + _ destination: Target.RowDecoder.Type, + through pivot: Pivot, + using target: Target, + key: String? = nil) + -> HasManyThroughAssociation + where Pivot: Association, + Target: Association, + Pivot.OriginRowDecoder == Self, + Pivot.RowDecoder == Target.OriginRowDecoder + { + let association = HasManyThroughAssociation( + sqlAssociation: target.sqlAssociation.through(pivot.sqlAssociation)) + + if let key = key { + return association.forKey(key) + } else { + return association + } + } + + /// Creates a "Has one" association between Self and the + /// destination type. + /// + /// struct Demographics: TableRecord { ... } + /// struct Country: TableRecord { + /// static let demographics = hasOne(Demographics.self) + /// } + /// + /// The association will let you define requests that load both the source + /// and the destination type: + /// + /// // A request for all countries with their demographic profile: + /// let request = Country.including(optional: Country.demographics) + /// + /// To consume those requests, define a type that adopts both the + /// FetchableRecord and Decodable protocols: + /// + /// struct CountryInfo: FetchableRecord, Decodable { + /// var country: Country + /// var demographics: Demographics? + /// } + /// + /// let countryInfos = try dbQueue.read { db in + /// return try CountryInfo.fetchAll(db, request) + /// } + /// for countryInfo in countryInfos { + /// print("\(countryInfo.country.name) has \(countryInfo.demographics.population) citizens") + /// } + /// + /// It is recommended that you define, alongside the static association, a + /// property with the same name: + /// + /// struct Country: TableRecord, EncodableRecord { + /// static let demographics = hasOne(Demographics.self) + /// var demographics: QueryInterfaceRequest { + /// return request(for: Country.demographics) + /// } + /// } + /// + /// This property will let you navigate from the source type to the + /// destination type: + /// + /// try dbQueue.read { db in + /// let country: Country = ... + /// let demographics = try country.demographics.fetchOne(db) // Demographics? + /// } + /// + /// - parameters: + /// - destination: The record type at the other side of the association. + /// - key: An eventual decoding key for the association. By default, it + /// is `destination.databaseTableName`. + /// - foreignKey: An eventual foreign key. You need to provide an + /// explicit foreign key when GRDB can't infer one from the database + /// schema. This happens when the schema does not define any foreign + /// key from the destination table, or when the schema defines several + /// foreign keys from the destination table. + public static func hasOne( + _ destination: Destination.Type, + key: String? = nil, + using foreignKey: ForeignKey? = nil) + -> HasOneAssociation + where Destination: TableRecord + { + let foreignKeyRequest = SQLForeignKeyRequest( + originTable: Destination.databaseTableName, + destinationTable: databaseTableName, + foreignKey: foreignKey) + + let condition = SQLAssociationCondition( + foreignKeyRequest: foreignKeyRequest, + originIsLeft: false) + + let associationKey: SQLAssociationKey + if let key = key { + associationKey = .fixedSingular(key) + } else { + associationKey = .inflected(Destination.databaseTableName) + } + + return HasOneAssociation(sqlAssociation: SQLAssociation( + key: associationKey, + condition: condition, + relation: Destination.all().relation, + cardinality: .toOne)) + } + + /// Creates a "Has One Through" association between Self and the + /// destination type. + /// + /// struct Book: TableRecord { + /// static let library = belongsTo(Library.self) + /// static let returnAddress = hasOne(Address.self, through: library, using: library.address) + /// } + /// + /// struct Library: TableRecord { + /// static let address = hasOne(Address.self) + /// } + /// + /// struct Address: TableRecord { ... } + /// + /// The association will let you define requests that load both the source + /// and the destination type: + /// + /// // A request for all (book, returnAddress) pairs: + /// let request = Book.including(required: Book.returnAddress) + /// + /// To consume those requests, define a type that adopts both the + /// FetchableRecord and Decodable protocols: + /// + /// struct Todo: FetchableRecord, Decodable { + /// var book: Book + /// var address: Address + /// } + /// + /// let todos = try dbQueue.read { db in + /// return try Todo.fetchAll(db, request) + /// } + /// for todo in todos { + /// print("Please return \(todo.book) to \(todo.address)") + /// } + /// + /// It is recommended that you define, alongside the static association, a + /// property with the same name: + /// + /// struct Book: TableRecord, EncodableRecord { + /// static let library = belongsTo(Library.self) + /// static let returnAddress = hasOne(Address.self, through: library, using: library.address) + /// var returnAddress: QueryInterfaceRequest
{ + /// return request(for: Book.returnAddress) + /// } + /// } + /// + /// This property will let you navigate from the source type to the + /// destination type: + /// + /// try dbQueue.read { db in + /// let book: Book = ... + /// let address = try book.returnAddress.fetchOne(db) // Address? + /// } + /// + /// - parameters: + /// - destination: The record type at the other side of the association. + /// - pivot: An association from Self to the intermediate type. + /// - target: A target association from the intermediate type to the + /// destination type. + /// - key: An eventual decoding key for the association. By default, it + /// is the same key as the target. + public static func hasOne( + _ destination: Target.RowDecoder.Type, + through pivot: Pivot, + using target: Target, + key: String? = nil) + -> HasOneThroughAssociation + where Pivot: AssociationToOne, + Target: AssociationToOne, + Pivot.OriginRowDecoder == Self, + Pivot.RowDecoder == Target.OriginRowDecoder + { + let association = HasOneThroughAssociation( + sqlAssociation: target.sqlAssociation.through(pivot.sqlAssociation)) + + if let key = key { + return association.forKey(key) + } else { + return association + } + } +} + +/// A ForeignKey helps building associations when GRDB can't infer a foreign +/// key from the database schema. +/// +/// Sometimes the database schema does not define any foreign key between two +/// tables. And sometimes, there are several foreign keys from a table +/// to another: +/// +/// | Table book | | Table person | +/// | ------------ | | ------------ | +/// | id | +-->• id | +/// | authorId •---+ | name | +/// | translatorId •---+ +/// | title | +/// +/// When this happens, associations can't be automatically inferred from the +/// database schema. GRDB will complain with a fatal error such as "Ambiguous +/// foreign key from book to person", or "Could not infer foreign key from book +/// to person". +/// +/// Your help is needed. You have to instruct GRDB which foreign key to use: +/// +/// struct Book: TableRecord { +/// // Define foreign keys +/// static let authorForeignKey = ForeignKey(["authorId"])) +/// static let translatorForeignKey = ForeignKey(["translatorId"])) +/// +/// // Use foreign keys to define associations: +/// static let author = belongsTo(Person.self, using: authorForeignKey) +/// static let translator = belongsTo(Person.self, using: translatorForeignKey) +/// } +/// +/// Foreign keys are always defined from the table that contains the columns at +/// the origin of the foreign key. Person's symmetric HasMany associations reuse +/// Book's foreign keys: +/// +/// struct Person: TableRecord { +/// static let writtenBooks = hasMany(Book.self, using: Book.authorForeignKey) +/// static let translatedBooks = hasMany(Book.self, using: Book.translatorForeignKey) +/// } +/// +/// Foreign keys can also be defined from query interface columns: +/// +/// struct Book: TableRecord { +/// enum Columns: String, ColumnExpression { +/// case id, title, authorId, translatorId +/// } +/// +/// static let authorForeignKey = ForeignKey([Columns.authorId])) +/// static let translatorForeignKey = ForeignKey([Columns.translatorId])) +/// } +/// +/// When the destination table of a foreign key does not define any primary key, +/// you need to provide the full definition of a foreign key: +/// +/// struct Book: TableRecord { +/// static let authorForeignKey = ForeignKey(["authorId"], to: ["id"])) +/// static let author = belongsTo(Person.self, using: authorForeignKey) +/// } +public struct ForeignKey { + var originColumns: [String] + var destinationColumns: [String]? + + /// Creates a ForeignKey intended to define a record association. + /// + /// struct Book: TableRecord { + /// // Define foreign keys + /// static let authorForeignKey = ForeignKey(["authorId"])) + /// static let translatorForeignKey = ForeignKey(["translatorId"])) + /// + /// // Use foreign keys to define associations: + /// static let author = belongsTo(Person.self, using: authorForeignKey) + /// static let translator = belongsTo(Person.self, using: translatorForeignKey) + /// } + /// + /// - parameter originColumns: The columns at the origin of the foreign key. + /// - parameter destinationColumns: The columns at the destination of the + /// foreign key. When nil (the default), GRDB automatically uses the + /// primary key. + public init(_ originColumns: [String], to destinationColumns: [String]? = nil) { + self.originColumns = originColumns + self.destinationColumns = destinationColumns + } + + /// Creates a ForeignKey intended to define a record association. + /// + /// struct Book: TableRecord { + /// // Define columns + /// enum Columns: String, ColumnExpression { + /// case id, title, authorId, translatorId + /// } + /// + /// // Define foreign keys + /// static let authorForeignKey = ForeignKey([Columns.authorId])) + /// static let translatorForeignKey = ForeignKey([Columns.translatorId])) + /// + /// // Use foreign keys to define associations: + /// static let author = belongsTo(Person.self, using: authorForeignKey) + /// static let translator = belongsTo(Person.self, using: translatorForeignKey) + /// } + /// + /// - parameter originColumns: The columns at the origin of the foreign key. + /// - parameter destinationColumns: The columns at the destination of the + /// foreign key. When nil (the default), GRDB automatically uses the + /// primary key. + public init(_ originColumns: [ColumnExpression], to destinationColumns: [ColumnExpression]? = nil) { + self.init(originColumns.map { $0.name }, to: destinationColumns?.map { $0.name }) + } +} + +extension TableRecord where Self: EncodableRecord { + /// Creates a request that fetches the associated record(s). + /// + /// For example: + /// + /// struct Team: TableRecord, EncodableRecord { + /// static let players = hasMany(Player.self) + /// var players: QueryInterfaceRequest { + /// return request(for: Team.players) + /// } + /// } + /// + /// let team: Team = ... + /// let players = try team.players.fetchAll(db) // [Player] + public func request(for association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == Self { + let destinationRelation = association.sqlAssociation.destinationRelation(fromOriginRows: { db in + try [Row(PersistenceContainer(db, self))] + }) + return QueryInterfaceRequest(relation: destinationRelation) + } +} + +extension TableRecord { + + // MARK: - Associations + + /// Creates a request that prefetches an association. + public static func including(all association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == Self { + return all().including(all: association) + } + + /// Creates a request that includes an association. The columns of the + /// associated record are selected. The returned association does not + /// require that the associated database table contains a matching row. + public static func including(optional association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == Self { + return all().including(optional: association) + } + + /// Creates a request that includes an association. The columns of the + /// associated record are selected. The returned association requires + /// that the associated database table contains a matching row. + public static func including(required association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == Self { + return all().including(required: association) + } + + /// Creates a request that includes an association. The columns of the + /// associated record are not selected. The returned association does not + /// require that the associated database table contains a matching row. + public static func joining(optional association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == Self { + return all().joining(optional: association) + } + + /// Creates a request that includes an association. The columns of the + /// associated record are not selected. The returned association requires + /// that the associated database table contains a matching row. + public static func joining(required association: A) -> QueryInterfaceRequest where A.OriginRowDecoder == Self { + return all().joining(required: association) + } + + // MARK: - Association Aggregates + + /// Creates a request with *aggregates* appended to the selection. + /// + /// // SELECT player.*, COUNT(DISTINCT book.rowid) AS bookCount + /// // FROM player LEFT JOIN book ... + /// var request = Player.annotated(with: Player.books.count) + public static func annotated(with aggregates: AssociationAggregate...) -> QueryInterfaceRequest { + return all().annotated(with: aggregates) + } + + /// Creates a request with *aggregates* appended to the selection. + /// + /// // SELECT player.*, COUNT(DISTINCT book.rowid) AS bookCount + /// // FROM player LEFT JOIN book ... + /// var request = Player.annotated(with: [Player.books.count]) + public static func annotated(with aggregates: [AssociationAggregate]) -> QueryInterfaceRequest { + return all().annotated(with: aggregates) + } + + /// Creates a request with the provided aggregate *predicate*. + /// + /// // SELECT player.* + /// // FROM player LEFT JOIN book ... + /// // HAVING COUNT(DISTINCT book.rowid) = 0 + /// var request = Player.all() + /// request = request.having(Player.books.isEmpty) + /// + /// The selection defaults to all columns. This default can be changed for + /// all requests by the `TableRecord.databaseSelection` property, or + /// for individual requests with the `TableRecord.select` method. + public static func having(_ predicate: AssociationAggregate) -> QueryInterfaceRequest { + return all().having(predicate) + } +} diff --git a/GRDB/QueryInterface/TableRecord+QueryInterfaceRequest.swift b/GRDB/QueryInterface/TableRecord+QueryInterfaceRequest.swift new file mode 100644 index 000000000..e759a39d0 --- /dev/null +++ b/GRDB/QueryInterface/TableRecord+QueryInterfaceRequest.swift @@ -0,0 +1,324 @@ +extension TableRecord { + + // MARK: Request Derivation + + /// Creates a request which fetches all records. + /// + /// // SELECT * FROM player + /// let request = Player.all() + /// + /// The selection defaults to all columns. This default can be changed for + /// all requests by the `TableRecord.databaseSelection` property, or + /// for individual requests with the `TableRecord.select` method. + public static func all() -> QueryInterfaceRequest { + let relation = SQLRelation( + source: .table(tableName: databaseTableName, alias: nil), + selection: databaseSelection) + return QueryInterfaceRequest(relation: relation) + } + + /// Creates a request which fetches no record. + public static func none() -> QueryInterfaceRequest { + return all().none() // don't laugh + } + + /// Creates a request which selects *selection*. + /// + /// // SELECT id, email FROM player + /// let request = Player.select(Column("id"), Column("email")) + public static func select(_ selection: SQLSelectable...) -> QueryInterfaceRequest { + return all().select(selection) + } + + /// Creates a request which selects *selection*. + /// + /// // SELECT id, email FROM player + /// let request = Player.select([Column("id"), Column("email")]) + public static func select(_ selection: [SQLSelectable]) -> QueryInterfaceRequest { + return all().select(selection) + } + + /// Creates a request which selects *sql*. + /// + /// // SELECT id, email FROM player + /// let request = Player.select(sql: "id, email") + public static func select(sql: String, arguments: StatementArguments = StatementArguments()) -> QueryInterfaceRequest { + return select(literal: SQLLiteral(sql: sql, arguments: arguments)) + } + + /// Creates a request which selects an SQL *literal*. + /// + /// // SELECT id, email FROM player + /// let request = Player.select(literal: SQLLiteral(sql: "id, email")) + public static func select(literal sqlLiteral: SQLLiteral) -> QueryInterfaceRequest { + return all().select(literal: sqlLiteral) + } + + /// Creates a request which selects *selection*, and fetches values of + /// type *type*. + /// + /// try dbQueue.read { db in + /// // SELECT max(score) FROM player + /// let request = Player.select([max(Column("score"))], as: Int.self) + /// let maxScore: Int? = try request.fetchOne(db) + /// } + public static func select(_ selection: [SQLSelectable], as type: RowDecoder.Type) -> QueryInterfaceRequest { + return all().select(selection, as: type) + } + + /// Creates a request which selects *selection*, and fetches values of + /// type *type*. + /// + /// try dbQueue.read { db in + /// // SELECT max(score) FROM player + /// let request = Player.select(max(Column("score")), as: Int.self) + /// let maxScore: Int? = try request.fetchOne(db) + /// } + public static func select(_ selection: SQLSelectable..., as type: RowDecoder.Type) -> QueryInterfaceRequest { + return all().select(selection, as: type) + } + + /// Creates a request which selects *sql*, and fetches values of + /// type *type*. + /// + /// try dbQueue.read { db in + /// // SELECT max(score) FROM player + /// let request = Player.select(sql: "max(score)", as: Int.self) + /// let maxScore: Int? = try request.fetchOne(db) + /// } + public static func select(sql: String, arguments: StatementArguments = StatementArguments(), as type: RowDecoder.Type) -> QueryInterfaceRequest { + return all().select(literal: SQLLiteral(sql: sql, arguments: arguments), as: type) + } + + /// Creates a request which selects an SQL *literal*, and fetches values of + /// type *type*. + /// + /// try dbQueue.read { db in + /// // SELECT max(score) FROM player + /// let request = Player.select(literal: SQLLiteral(sql: "max(score)"), as: Int.self) + /// let maxScore: Int? = try request.fetchOne(db) + /// } + public static func select(literal sqlLiteral: SQLLiteral, as type: RowDecoder.Type) -> QueryInterfaceRequest { + return all().select(literal: sqlLiteral, as: type) + } + + /// Creates a request which appends *selection*. + /// + /// // SELECT id, email, name FROM player + /// le request = Player + /// .select([Column("id"), Column("email")]) + /// .annotated(with: [Column("name")]) + public static func annotated(with selection: [SQLSelectable]) -> QueryInterfaceRequest { + return all().annotated(with: selection) + } + + /// Creates a request which appends *selection*. + /// + /// // SELECT id, email, name FROM player + /// le request = Player + /// .select([Column("id"), Column("email")]) + /// .annotated(with: Column("name")) + public static func annotated(with selection: SQLSelectable...) -> QueryInterfaceRequest { + return all().annotated(with: selection) + } + + /// Creates a request with the provided *predicate*. + /// + /// // SELECT * FROM player WHERE email = 'arthur@example.com' + /// let request = Player.filter(Column("email") == "arthur@example.com") + /// + /// The selection defaults to all columns. This default can be changed for + /// all requests by the `TableRecord.databaseSelection` property, or + /// for individual requests with the `TableRecord.select` method. + public static func filter(_ predicate: SQLExpressible) -> QueryInterfaceRequest { + return all().filter(predicate) + } + + /// Creates a request with the provided primary key *predicate*. + /// + /// // SELECT * FROM player WHERE id = 1 + /// let request = Player.filter(key: 1) + /// + /// The selection defaults to all columns. This default can be changed for + /// all requests by the `TableRecord.databaseSelection` property, or + /// for individual requests with the `TableRecord.select` method. + public static func filter(key: PrimaryKeyType?) -> QueryInterfaceRequest { + return all().filter(key: key) + } + + /// Creates a request with the provided primary key *predicate*. + /// + /// // SELECT * FROM player WHERE id IN (1, 2, 3) + /// let request = Player.filter(keys: [1, 2, 3]) + /// + /// The selection defaults to all columns. This default can be changed for + /// all requests by the `TableRecord.databaseSelection` property, or + /// for individual requests with the `TableRecord.select` method. + public static func filter(keys: Sequence) -> QueryInterfaceRequest where Sequence.Element: DatabaseValueConvertible { + return all().filter(keys: keys) + } + + /// Creates a request with the provided primary key *predicate*. + /// + /// // SELECT * FROM passport WHERE personId = 1 AND countryCode = 'FR' + /// let request = Passport.filter(key: ["personId": 1, "countryCode": "FR"]) + /// + /// When executed, this request raises a fatal error if there is no unique + /// index on the key columns. + /// + /// The selection defaults to all columns. This default can be changed for + /// all requests by the `TableRecord.databaseSelection` property, or + /// for individual requests with the `TableRecord.select` method. + public static func filter(key: [String: DatabaseValueConvertible?]?) -> QueryInterfaceRequest { + return all().filter(key: key) + } + + /// Creates a request with the provided primary key *predicate*. + /// + /// // SELECT * FROM passport WHERE (personId = 1 AND countryCode = 'FR') OR ... + /// let request = Passport.filter(keys: [["personId": 1, "countryCode": "FR"], ...]) + /// + /// When executed, this request raises a fatal error if there is no unique + /// index on the key columns. + /// + /// The selection defaults to all columns. This default can be changed for + /// all requests by the `TableRecord.databaseSelection` property, or + /// for individual requests with the `TableRecord.select` method. + public static func filter(keys: [[String: DatabaseValueConvertible?]]) -> QueryInterfaceRequest { + return all().filter(keys: keys) + } + + /// Creates a request with the provided *predicate*. + /// + /// // SELECT * FROM player WHERE email = 'arthur@example.com' + /// let request = Player.filter(sql: "email = ?", arguments: ["arthur@example.com"]) + /// + /// The selection defaults to all columns. This default can be changed for + /// all requests by the `TableRecord.databaseSelection` property, or + /// for individual requests with the `TableRecord.select` method. + public static func filter(sql: String, arguments: StatementArguments = StatementArguments()) -> QueryInterfaceRequest { + return filter(literal: SQLLiteral(sql: sql, arguments: arguments)) + } + + /// Creates a request with the provided *predicate*. + /// + /// // SELECT * FROM player WHERE email = 'arthur@example.com' + /// let request = Player.filter(literal: SQLLiteral(sql: "email = ?", arguments: ["arthur@example.com"])) + /// + /// With Swift 5, you can safely embed raw values in your SQL queries, + /// without any risk of syntax errors or SQL injection: + /// + /// let request = Player.filter(literal: "name = \("O'Brien")) + /// + /// The selection defaults to all columns. This default can be changed for + /// all requests by the `TableRecord.databaseSelection` property, or + /// for individual requests with the `TableRecord.select` method. + public static func filter(literal sqlLiteral: SQLLiteral) -> QueryInterfaceRequest { + // NOT TESTED + return all().filter(literal: sqlLiteral) + } + + /// Creates a request sorted according to the + /// provided *orderings*. + /// + /// // SELECT * FROM player ORDER BY name + /// let request = Player.order(Column("name")) + /// + /// The selection defaults to all columns. This default can be changed for + /// all requests by the `TableRecord.databaseSelection` property, or + /// for individual requests with the `TableRecord.select` method. + public static func order(_ orderings: SQLOrderingTerm...) -> QueryInterfaceRequest { + return all().order(orderings) + } + + /// Creates a request sorted according to the + /// provided *orderings*. + /// + /// // SELECT * FROM player ORDER BY name + /// let request = Player.order([Column("name")]) + /// + /// The selection defaults to all columns. This default can be changed for + /// all requests by the `TableRecord.databaseSelection` property, or + /// for individual requests with the `TableRecord.select` method. + public static func order(_ orderings: [SQLOrderingTerm]) -> QueryInterfaceRequest { + return all().order(orderings) + } + + /// Creates a request sorted by primary key. + /// + /// // SELECT * FROM player ORDER BY id + /// let request = Player.orderByPrimaryKey() + /// + /// // SELECT * FROM country ORDER BY code + /// let request = Country.orderByPrimaryKey() + /// + /// The selection defaults to all columns. This default can be changed for + /// all requests by the `TableRecord.databaseSelection` property, or + /// for individual requests with the `TableRecord.select` method. + public static func orderByPrimaryKey() -> QueryInterfaceRequest { + return all().orderByPrimaryKey() + } + + /// Creates a request sorted according to *sql*. + /// + /// // SELECT * FROM player ORDER BY name + /// let request = Player.order(sql: "name") + /// + /// The selection defaults to all columns. This default can be changed for + /// all requests by the `TableRecord.databaseSelection` property, or + /// for individual requests with the `TableRecord.select` method. + public static func order(sql: String, arguments: StatementArguments = StatementArguments()) -> QueryInterfaceRequest { + return all().order(literal: SQLLiteral(sql: sql, arguments: arguments)) + } + + /// Creates a request sorted according to an SQL *literal*. + /// + /// // SELECT * FROM player ORDER BY name + /// let request = Player.order(literal: SQLLiteral(sql: "name")) + /// + /// With Swift 5, you can safely embed raw values in your SQL queries, + /// without any risk of syntax errors or SQL injection: + /// + /// // SELECT * FROM player ORDER BY name + /// let request = Player.order(literal: "name")) + /// + /// The selection defaults to all columns. This default can be changed for + /// all requests by the `TableRecord.databaseSelection` property, or + /// for individual requests with the `TableRecord.select` method. + public static func order(literal sqlLiteral: SQLLiteral) -> QueryInterfaceRequest { + return all().order(literal: sqlLiteral) + } + + /// Creates a request which fetches *limit* rows, starting at + /// *offset*. + /// + /// // SELECT * FROM player LIMIT 1 + /// let request = Player.limit(1) + /// + /// The selection defaults to all columns. This default can be changed for + /// all requests by the `TableRecord.databaseSelection` property, or + /// for individual requests with the `TableRecord.select` method. + public static func limit(_ limit: Int, offset: Int? = nil) -> QueryInterfaceRequest { + return all().limit(limit, offset: offset) + } + + /// Creates a request that allows you to define expressions that target + /// a specific database table. + /// + /// In the example below, the "team.avgScore < player.score" condition in + /// the ON clause could be not achieved without table aliases. + /// + /// struct Player: TableRecord { + /// static let team = belongsTo(Team.self) + /// } + /// + /// // SELECT player.*, team.* + /// // JOIN team ON ... AND team.avgScore < player.score + /// let playerAlias = TableAlias() + /// let request = Player + /// .aliased(playerAlias) + /// .including(required: Player.team.filter(Column("avgScore") < playerAlias[Column("score")]) + public static func aliased(_ alias: TableAlias) -> QueryInterfaceRequest { + return all().aliased(alias) + } +} diff --git a/GRDBCustom.xcodeproj/project.pbxproj b/GRDBCustom.xcodeproj/project.pbxproj index 11880e340..3a9f1b1bf 100755 --- a/GRDBCustom.xcodeproj/project.pbxproj +++ b/GRDBCustom.xcodeproj/project.pbxproj @@ -15,10 +15,6 @@ 56057C5A2291B18E00A7CB10 /* AssociationHasManyRowScopeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56057C572291B18E00A7CB10 /* AssociationHasManyRowScopeTests.swift */; }; 56057C652291C7E500A7CB10 /* AssociationHasManyThroughRowScopeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56057C642291C7E500A7CB10 /* AssociationHasManyThroughRowScopeTests.swift */; }; 56057C662291C7E500A7CB10 /* AssociationHasManyThroughRowScopeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56057C642291C7E500A7CB10 /* AssociationHasManyThroughRowScopeTests.swift */; }; - 5607149B227618660091BB10 /* Row+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56071499227618660091BB10 /* Row+QueryInterface.swift */; }; - 5607149C227618660091BB10 /* Row+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56071499227618660091BB10 /* Row+QueryInterface.swift */; }; - 5607149E227618800091BB10 /* FetchableRecord+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5607149D227618800091BB10 /* FetchableRecord+QueryInterface.swift */; }; - 5607149F227618800091BB10 /* FetchableRecord+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5607149D227618800091BB10 /* FetchableRecord+QueryInterface.swift */; }; 560714ED227DD10F0091BB10 /* AssociationPrefetchingSQLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560714EB227DD10F0091BB10 /* AssociationPrefetchingSQLTests.swift */; }; 560714EE227DD10F0091BB10 /* AssociationPrefetchingSQLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560714EB227DD10F0091BB10 /* AssociationPrefetchingSQLTests.swift */; }; 56071A501DB54ED300CA6E47 /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift */; }; @@ -52,8 +48,6 @@ 5615B286222B17BA00061C1C /* AssociationHasOneThroughDecodableRecordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5615B284222B17B900061C1C /* AssociationHasOneThroughDecodableRecordTests.swift */; }; 561667041D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 561667001D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift */; }; 561667081D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 561667001D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift */; }; - 5616AAF6207CD59400AC3664 /* RequestProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5616AAF4207CD59300AC3664 /* RequestProtocols.swift */; }; - 5616AAF7207CD59400AC3664 /* RequestProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5616AAF4207CD59300AC3664 /* RequestProtocols.swift */; }; 561729552235340E0006E219 /* EncodableRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 561729532235340E0006E219 /* EncodableRecord.swift */; }; 561729562235340E0006E219 /* EncodableRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 561729532235340E0006E219 /* EncodableRecord.swift */; }; 56176C7E1EACCD2F000F3F2B /* EncryptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567156701CB18050007DC145 /* EncryptionTests.swift */; }; @@ -107,8 +101,6 @@ 563B071C21862F5600B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563B071A21862F5600B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift */; }; 563EF420215F8A76007DAACD /* OrderedDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF41E215F8A76007DAACD /* OrderedDictionary.swift */; }; 563EF421215F8A76007DAACD /* OrderedDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF41E215F8A76007DAACD /* OrderedDictionary.swift */; }; - 563EF4382161182C007DAACD /* AssociationAggregate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF4362161182C007DAACD /* AssociationAggregate.swift */; }; - 563EF4392161182C007DAACD /* AssociationAggregate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF4362161182C007DAACD /* AssociationAggregate.swift */; }; 563EF442216131F5007DAACD /* AssociationAggregateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF441216131F5007DAACD /* AssociationAggregateTests.swift */; }; 563EF443216131F5007DAACD /* AssociationAggregateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF441216131F5007DAACD /* AssociationAggregateTests.swift */; }; 563EF44D2161F196007DAACD /* Inflections.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563EF44C2161F196007DAACD /* Inflections.swift */; }; @@ -143,20 +135,6 @@ 564F9C251F069B4E00877A00 /* DatabaseAggregateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564F9C1D1F069B4E00877A00 /* DatabaseAggregateTests.swift */; }; 564F9C301F07611500877A00 /* DatabaseFunction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564F9C2C1F075DD200877A00 /* DatabaseFunction.swift */; }; 564F9C331F07611800877A00 /* DatabaseFunction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 564F9C2C1F075DD200877A00 /* DatabaseFunction.swift */; }; - 5653EB4120961F6100F46237 /* BelongsToAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3720961F6000F46237 /* BelongsToAssociation.swift */; }; - 5653EB4220961F6100F46237 /* BelongsToAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3720961F6000F46237 /* BelongsToAssociation.swift */; }; - 5653EB4320961F6100F46237 /* HasOneAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3820961F6000F46237 /* HasOneAssociation.swift */; }; - 5653EB4420961F6100F46237 /* HasOneAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3820961F6000F46237 /* HasOneAssociation.swift */; }; - 5653EB4720961F6100F46237 /* HasManyAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3A20961F6000F46237 /* HasManyAssociation.swift */; }; - 5653EB4820961F6100F46237 /* HasManyAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3A20961F6000F46237 /* HasManyAssociation.swift */; }; - 5653EB4920961F6100F46237 /* ForeignKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3B20961F6000F46237 /* ForeignKey.swift */; }; - 5653EB4A20961F6100F46237 /* ForeignKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3B20961F6000F46237 /* ForeignKey.swift */; }; - 5653EB4B20961F6100F46237 /* ForeignKeyRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3C20961F6000F46237 /* ForeignKeyRequest.swift */; }; - 5653EB4C20961F6100F46237 /* ForeignKeyRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3C20961F6000F46237 /* ForeignKeyRequest.swift */; }; - 5653EB4F20961F6100F46237 /* Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3E20961F6100F46237 /* Association.swift */; }; - 5653EB5020961F6100F46237 /* Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB3E20961F6100F46237 /* Association.swift */; }; - 5653EB5420961F7D00F46237 /* QueryInterfaceRequest+Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB5320961F7D00F46237 /* QueryInterfaceRequest+Association.swift */; }; - 5653EB5520961F7D00F46237 /* QueryInterfaceRequest+Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB5320961F7D00F46237 /* QueryInterfaceRequest+Association.swift */; }; 5653EB6820961FB200F46237 /* AssociationParallelSQLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB5820961FB000F46237 /* AssociationParallelSQLTests.swift */; }; 5653EB6920961FB200F46237 /* AssociationParallelSQLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB5820961FB000F46237 /* AssociationParallelSQLTests.swift */; }; 5653EB6A20961FB200F46237 /* AssociationBelongsToFetchableRecordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB5920961FB100F46237 /* AssociationBelongsToFetchableRecordTests.swift */; }; @@ -185,10 +163,84 @@ 5653EB8120961FB200F46237 /* AssociationBelongsToDecodableRecordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB6420961FB200F46237 /* AssociationBelongsToDecodableRecordTests.swift */; }; 5653EB8220961FB200F46237 /* AssociationBelongsToRowScopeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB6520961FB200F46237 /* AssociationBelongsToRowScopeTests.swift */; }; 5653EB8320961FB200F46237 /* AssociationBelongsToRowScopeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EB6520961FB200F46237 /* AssociationBelongsToRowScopeTests.swift */; }; - 5653EC082098737400F46237 /* SQLGenerationContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EC072098737400F46237 /* SQLGenerationContext.swift */; }; - 5653EC092098737400F46237 /* SQLGenerationContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5653EC072098737400F46237 /* SQLGenerationContext.swift */; }; 5656A7F622946B1B001FF3FF /* ValueObservationQueryInterfaceRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A7F422946B1B001FF3FF /* ValueObservationQueryInterfaceRequestTests.swift */; }; 5656A7F722946B1B001FF3FF /* ValueObservationQueryInterfaceRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A7F422946B1B001FF3FF /* ValueObservationQueryInterfaceRequestTests.swift */; }; + 5656A8512295BD56001FF3FF /* SQLInterpolation+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8262295BD56001FF3FF /* SQLInterpolation+QueryInterface.swift */; }; + 5656A8522295BD56001FF3FF /* SQLInterpolation+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8262295BD56001FF3FF /* SQLInterpolation+QueryInterface.swift */; }; + 5656A8552295BD56001FF3FF /* FTS5+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8282295BD56001FF3FF /* FTS5+QueryInterface.swift */; }; + 5656A8562295BD56001FF3FF /* FTS5+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8282295BD56001FF3FF /* FTS5+QueryInterface.swift */; }; + 5656A8572295BD56001FF3FF /* SQLQueryGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A82A2295BD56001FF3FF /* SQLQueryGenerator.swift */; }; + 5656A8582295BD56001FF3FF /* SQLQueryGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A82A2295BD56001FF3FF /* SQLQueryGenerator.swift */; }; + 5656A8592295BD56001FF3FF /* SQLGenerationContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A82B2295BD56001FF3FF /* SQLGenerationContext.swift */; }; + 5656A85A2295BD56001FF3FF /* SQLGenerationContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A82B2295BD56001FF3FF /* SQLGenerationContext.swift */; }; + 5656A85B2295BD56001FF3FF /* TableDefinition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A82D2295BD56001FF3FF /* TableDefinition.swift */; }; + 5656A85C2295BD56001FF3FF /* TableDefinition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A82D2295BD56001FF3FF /* TableDefinition.swift */; }; + 5656A85D2295BD56001FF3FF /* VirtualTableModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A82E2295BD56001FF3FF /* VirtualTableModule.swift */; }; + 5656A85E2295BD56001FF3FF /* VirtualTableModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A82E2295BD56001FF3FF /* VirtualTableModule.swift */; }; + 5656A85F2295BD56001FF3FF /* FTS3+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A82F2295BD56001FF3FF /* FTS3+QueryInterface.swift */; }; + 5656A8602295BD56001FF3FF /* FTS3+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A82F2295BD56001FF3FF /* FTS3+QueryInterface.swift */; }; + 5656A8612295BD56001FF3FF /* TableRecord+Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8312295BD56001FF3FF /* TableRecord+Association.swift */; }; + 5656A8622295BD56001FF3FF /* TableRecord+Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8312295BD56001FF3FF /* TableRecord+Association.swift */; }; + 5656A8632295BD56001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8322295BD56001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift */; }; + 5656A8642295BD56001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8322295BD56001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift */; }; + 5656A8652295BD56001FF3FF /* BelongsToAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8342295BD56001FF3FF /* BelongsToAssociation.swift */; }; + 5656A8662295BD56001FF3FF /* BelongsToAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8342295BD56001FF3FF /* BelongsToAssociation.swift */; }; + 5656A8672295BD56001FF3FF /* HasOneAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8352295BD56001FF3FF /* HasOneAssociation.swift */; }; + 5656A8682295BD56001FF3FF /* HasOneAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8352295BD56001FF3FF /* HasOneAssociation.swift */; }; + 5656A8692295BD56001FF3FF /* AssociationAggregate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8362295BD56001FF3FF /* AssociationAggregate.swift */; }; + 5656A86A2295BD56001FF3FF /* AssociationAggregate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8362295BD56001FF3FF /* AssociationAggregate.swift */; }; + 5656A86B2295BD56001FF3FF /* HasManyAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8372295BD56001FF3FF /* HasManyAssociation.swift */; }; + 5656A86C2295BD56001FF3FF /* HasManyAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8372295BD56001FF3FF /* HasManyAssociation.swift */; }; + 5656A86D2295BD56001FF3FF /* HasManyThroughAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8382295BD56001FF3FF /* HasManyThroughAssociation.swift */; }; + 5656A86E2295BD56001FF3FF /* HasManyThroughAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8382295BD56001FF3FF /* HasManyThroughAssociation.swift */; }; + 5656A86F2295BD56001FF3FF /* Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8392295BD56001FF3FF /* Association.swift */; }; + 5656A8702295BD56001FF3FF /* Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8392295BD56001FF3FF /* Association.swift */; }; + 5656A8712295BD56001FF3FF /* HasOneThroughAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A83A2295BD56001FF3FF /* HasOneThroughAssociation.swift */; }; + 5656A8722295BD56001FF3FF /* HasOneThroughAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A83A2295BD56001FF3FF /* HasOneThroughAssociation.swift */; }; + 5656A8732295BD56001FF3FF /* QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A83B2295BD56001FF3FF /* QueryInterfaceRequest.swift */; }; + 5656A8742295BD56001FF3FF /* QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A83B2295BD56001FF3FF /* QueryInterfaceRequest.swift */; }; + 5656A8752295BD56001FF3FF /* RequestProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A83C2295BD56001FF3FF /* RequestProtocols.swift */; }; + 5656A8762295BD56001FF3FF /* RequestProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A83C2295BD56001FF3FF /* RequestProtocols.swift */; }; + 5656A8772295BD56001FF3FF /* TableRecord+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A83D2295BD56001FF3FF /* TableRecord+QueryInterfaceRequest.swift */; }; + 5656A8782295BD56001FF3FF /* TableRecord+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A83D2295BD56001FF3FF /* TableRecord+QueryInterfaceRequest.swift */; }; + 5656A8792295BD56001FF3FF /* Row+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A83E2295BD56001FF3FF /* Row+QueryInterfaceRequest.swift */; }; + 5656A87A2295BD56001FF3FF /* Row+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A83E2295BD56001FF3FF /* Row+QueryInterfaceRequest.swift */; }; + 5656A87B2295BD56001FF3FF /* QueryInterfaceRequest+Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A83F2295BD56001FF3FF /* QueryInterfaceRequest+Association.swift */; }; + 5656A87C2295BD56001FF3FF /* QueryInterfaceRequest+Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A83F2295BD56001FF3FF /* QueryInterfaceRequest+Association.swift */; }; + 5656A87D2295BD56001FF3FF /* SQLAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8412295BD56001FF3FF /* SQLAssociation.swift */; }; + 5656A87E2295BD56001FF3FF /* SQLAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8412295BD56001FF3FF /* SQLAssociation.swift */; }; + 5656A87F2295BD56001FF3FF /* SQLForeignKeyRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8422295BD56001FF3FF /* SQLForeignKeyRequest.swift */; }; + 5656A8802295BD56001FF3FF /* SQLForeignKeyRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8422295BD56001FF3FF /* SQLForeignKeyRequest.swift */; }; + 5656A8812295BD56001FF3FF /* SQLCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8432295BD56001FF3FF /* SQLCollection.swift */; }; + 5656A8822295BD56001FF3FF /* SQLCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8432295BD56001FF3FF /* SQLCollection.swift */; }; + 5656A8832295BD56001FF3FF /* SQLExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8442295BD56001FF3FF /* SQLExpression.swift */; }; + 5656A8842295BD56001FF3FF /* SQLExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8442295BD56001FF3FF /* SQLExpression.swift */; }; + 5656A8852295BD56001FF3FF /* SQLOrdering.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8452295BD56001FF3FF /* SQLOrdering.swift */; }; + 5656A8862295BD56001FF3FF /* SQLOrdering.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8452295BD56001FF3FF /* SQLOrdering.swift */; }; + 5656A8872295BD56001FF3FF /* SQLOperators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8462295BD56001FF3FF /* SQLOperators.swift */; }; + 5656A8882295BD56001FF3FF /* SQLOperators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8462295BD56001FF3FF /* SQLOperators.swift */; }; + 5656A8892295BD56001FF3FF /* SQLExpressible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8472295BD56001FF3FF /* SQLExpressible.swift */; }; + 5656A88A2295BD56001FF3FF /* SQLExpressible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8472295BD56001FF3FF /* SQLExpressible.swift */; }; + 5656A88B2295BD56001FF3FF /* SQLExpression+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8482295BD56001FF3FF /* SQLExpression+QueryInterface.swift */; }; + 5656A88C2295BD56001FF3FF /* SQLExpression+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8482295BD56001FF3FF /* SQLExpression+QueryInterface.swift */; }; + 5656A88D2295BD56001FF3FF /* SQLSelectable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8492295BD56001FF3FF /* SQLSelectable.swift */; }; + 5656A88E2295BD56001FF3FF /* SQLSelectable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8492295BD56001FF3FF /* SQLSelectable.swift */; }; + 5656A88F2295BD56001FF3FF /* Column.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A84A2295BD56001FF3FF /* Column.swift */; }; + 5656A8902295BD56001FF3FF /* Column.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A84A2295BD56001FF3FF /* Column.swift */; }; + 5656A8912295BD56001FF3FF /* SQLSpecificExpressible+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A84B2295BD56001FF3FF /* SQLSpecificExpressible+QueryInterface.swift */; }; + 5656A8922295BD56001FF3FF /* SQLSpecificExpressible+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A84B2295BD56001FF3FF /* SQLSpecificExpressible+QueryInterface.swift */; }; + 5656A8932295BD56001FF3FF /* SQLFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A84C2295BD56001FF3FF /* SQLFunctions.swift */; }; + 5656A8942295BD56001FF3FF /* SQLFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A84C2295BD56001FF3FF /* SQLFunctions.swift */; }; + 5656A8952295BD56001FF3FF /* SQLCollatedExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A84D2295BD56001FF3FF /* SQLCollatedExpression.swift */; }; + 5656A8962295BD56001FF3FF /* SQLCollatedExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A84D2295BD56001FF3FF /* SQLCollatedExpression.swift */; }; + 5656A8972295BD56001FF3FF /* SQLRelation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A84E2295BD56001FF3FF /* SQLRelation.swift */; }; + 5656A8982295BD56001FF3FF /* SQLRelation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A84E2295BD56001FF3FF /* SQLRelation.swift */; }; + 5656A8992295BD56001FF3FF /* SQLSelectable+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A84F2295BD56001FF3FF /* SQLSelectable+QueryInterface.swift */; }; + 5656A89A2295BD56001FF3FF /* SQLSelectable+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A84F2295BD56001FF3FF /* SQLSelectable+QueryInterface.swift */; }; + 5656A89B2295BD56001FF3FF /* SQLQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8502295BD56001FF3FF /* SQLQuery.swift */; }; + 5656A89C2295BD56001FF3FF /* SQLQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8502295BD56001FF3FF /* SQLQuery.swift */; }; + 5656A8A72295BF44001FF3FF /* DatabasePromise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8A52295BF44001FF3FF /* DatabasePromise.swift */; }; + 5656A8A82295BF44001FF3FF /* DatabasePromise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5656A8A52295BF44001FF3FF /* DatabasePromise.swift */; }; 5657AABB1D107001006283EF /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AAB81D107001006283EF /* NSData.swift */; }; 5657AABE1D107001006283EF /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AAB81D107001006283EF /* NSData.swift */; }; 5657AB111D10899D006283EF /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5657AB0E1D10899D006283EF /* URL.swift */; }; @@ -217,16 +269,6 @@ 5659F4A51EA8D997004A4992 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5659F49F1EA8D997004A4992 /* Result.swift */; }; 565EFAF11D0436CE00A8FA9D /* NumericOverflowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565EFAED1D0436CE00A8FA9D /* NumericOverflowTests.swift */; }; 565EFAF51D0436CE00A8FA9D /* NumericOverflowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 565EFAED1D0436CE00A8FA9D /* NumericOverflowTests.swift */; }; - 5664759C1D97D8A000FF74B8 /* SQLCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566475991D97D8A000FF74B8 /* SQLCollection.swift */; }; - 5664759F1D97D8A000FF74B8 /* SQLCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566475991D97D8A000FF74B8 /* SQLCollection.swift */; }; - 566475A41D9810A400FF74B8 /* SQLSelectable+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566475A11D9810A400FF74B8 /* SQLSelectable+QueryInterface.swift */; }; - 566475A71D9810A400FF74B8 /* SQLSelectable+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566475A11D9810A400FF74B8 /* SQLSelectable+QueryInterface.swift */; }; - 566475BC1D981AD200FF74B8 /* SQLSpecificExpressible+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566475B91D981AD200FF74B8 /* SQLSpecificExpressible+QueryInterface.swift */; }; - 566475BF1D981AD200FF74B8 /* SQLSpecificExpressible+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566475B91D981AD200FF74B8 /* SQLSpecificExpressible+QueryInterface.swift */; }; - 566475CE1D981D5E00FF74B8 /* SQLFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566475CA1D981D5E00FF74B8 /* SQLFunctions.swift */; }; - 566475D11D981D5E00FF74B8 /* SQLFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566475CA1D981D5E00FF74B8 /* SQLFunctions.swift */; }; - 566475D51D981D5E00FF74B8 /* SQLOperators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566475CB1D981D5E00FF74B8 /* SQLOperators.swift */; }; - 566475D81D981D5E00FF74B8 /* SQLOperators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566475CB1D981D5E00FF74B8 /* SQLOperators.swift */; }; 5665F868203EF4640084C6C0 /* ColumnInfoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5665F865203EF4590084C6C0 /* ColumnInfoTests.swift */; }; 5665F869203EF4650084C6C0 /* ColumnInfoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5665F865203EF4590084C6C0 /* ColumnInfoTests.swift */; }; 5665FA1E2129D807004D8612 /* DatabaseDateDecodingStrategyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5665FA1C2129D807004D8612 /* DatabaseDateDecodingStrategyTests.swift */; }; @@ -239,8 +281,6 @@ 566A843620413DE400E50BFD /* DatabaseSnapshotTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A843420413DE400E50BFD /* DatabaseSnapshotTests.swift */; }; 566A84432041AB2D00E50BFD /* MutablePersistableRecordChangesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A84422041AB2D00E50BFD /* MutablePersistableRecordChangesTests.swift */; }; 566A84442041AB2D00E50BFD /* MutablePersistableRecordChangesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566A84422041AB2D00E50BFD /* MutablePersistableRecordChangesTests.swift */; }; - 566AD8B41D5318F4002EC1A8 /* TableDefinition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566AD8B11D5318F4002EC1A8 /* TableDefinition.swift */; }; - 566AD8B71D5318F4002EC1A8 /* TableDefinition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566AD8B11D5318F4002EC1A8 /* TableDefinition.swift */; }; 566AD8C91D531BEB002EC1A8 /* TableDefinitionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566AD8C51D531BE4002EC1A8 /* TableDefinitionTests.swift */; }; 566AD8CD1D531BEE002EC1A8 /* TableDefinitionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566AD8C51D531BE4002EC1A8 /* TableDefinitionTests.swift */; }; 566B910B1FA4C3970012D5B0 /* Database+Statements.swift in Sources */ = {isa = PBXBuildFile; fileRef = 566B91081FA4C3960012D5B0 /* Database+Statements.swift */; }; @@ -291,8 +331,6 @@ 567F45AF1F888B2600030B59 /* TruncateOptimizationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 567F45A71F888B2600030B59 /* TruncateOptimizationTests.swift */; }; 568068341EBBA26100EFB8AA /* SQLRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568068301EBBA26100EFB8AA /* SQLRequestTests.swift */; }; 568068381EBBA26100EFB8AA /* SQLRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568068301EBBA26100EFB8AA /* SQLRequestTests.swift */; }; - 568D13152207210400674B58 /* SQLSelectQueryGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568D13142207210400674B58 /* SQLSelectQueryGenerator.swift */; }; - 568D13162207210400674B58 /* SQLSelectQueryGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 568D13142207210400674B58 /* SQLSelectQueryGenerator.swift */; }; 5690C3291D23E6D800E59934 /* FoundationDateComponentsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5690C3251D23E6D800E59934 /* FoundationDateComponentsTests.swift */; }; 5690C32D1D23E6D800E59934 /* FoundationDateComponentsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5690C3251D23E6D800E59934 /* FoundationDateComponentsTests.swift */; }; 5690C33A1D23E7D200E59934 /* FoundationDateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5690C3361D23E7D200E59934 /* FoundationDateTests.swift */; }; @@ -301,8 +339,6 @@ 5690C3451D23E82A00E59934 /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5690C33F1D23E82A00E59934 /* Data.swift */; }; 56959620222C458A002CB7C9 /* AssociationHasManyThroughSQLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5695961E222C4589002CB7C9 /* AssociationHasManyThroughSQLTests.swift */; }; 56959621222C458A002CB7C9 /* AssociationHasManyThroughSQLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5695961E222C4589002CB7C9 /* AssociationHasManyThroughSQLTests.swift */; }; - 5695962D222C4682002CB7C9 /* HasManyThroughAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5695962C222C4681002CB7C9 /* HasManyThroughAssociation.swift */; }; - 5695962E222C4682002CB7C9 /* HasManyThroughAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5695962C222C4681002CB7C9 /* HasManyThroughAssociation.swift */; }; 56959636222D058B002CB7C9 /* AssociationHasManySQLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56959635222D058B002CB7C9 /* AssociationHasManySQLTests.swift */; }; 56959637222D058B002CB7C9 /* AssociationHasManySQLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56959635222D058B002CB7C9 /* AssociationHasManySQLTests.swift */; }; 5698AC061D9B9FCF0056AF8C /* QueryInterfaceExtensibilityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AC021D9B9FCF0056AF8C /* QueryInterfaceExtensibilityTests.swift */; }; @@ -313,8 +349,6 @@ 5698AC471DA2BED90056AF8C /* FTS3PatternTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AC3F1DA2BED90056AF8C /* FTS3PatternTests.swift */; }; 5698AC4C1DA2D48A0056AF8C /* FTS3RecordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AC481DA2D48A0056AF8C /* FTS3RecordTests.swift */; }; 5698AC501DA2D48A0056AF8C /* FTS3RecordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AC481DA2D48A0056AF8C /* FTS3RecordTests.swift */; }; - 5698AC7A1DA37DCB0056AF8C /* VirtualTableModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AC771DA37DCB0056AF8C /* VirtualTableModule.swift */; }; - 5698AC7D1DA37DCB0056AF8C /* VirtualTableModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AC771DA37DCB0056AF8C /* VirtualTableModule.swift */; }; 5698AC831DA380A20056AF8C /* VirtualTableModuleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AC7F1DA380A20056AF8C /* VirtualTableModuleTests.swift */; }; 5698AC871DA380A20056AF8C /* VirtualTableModuleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AC7F1DA380A20056AF8C /* VirtualTableModuleTests.swift */; }; 5698AC8C1DA389380056AF8C /* FTS3TableBuilderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AC881DA389380056AF8C /* FTS3TableBuilderTests.swift */; }; @@ -359,8 +393,6 @@ 56A8C2461D1918EF0096E9D4 /* FoundationUUIDTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A8C21E1D1914110096E9D4 /* FoundationUUIDTests.swift */; }; 56A8C24D1D1918F30096E9D4 /* FoundationNSUUIDTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A8C2361D1914790096E9D4 /* FoundationNSUUIDTests.swift */; }; 56A8C24E1D1918F30096E9D4 /* FoundationUUIDTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A8C21E1D1914110096E9D4 /* FoundationUUIDTests.swift */; }; - 56AE6421222AAB1700AD1B0B /* HasOneThroughAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56AE641F222AAB1700AD1B0B /* HasOneThroughAssociation.swift */; }; - 56AE6422222AAB1700AD1B0B /* HasOneThroughAssociation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56AE641F222AAB1700AD1B0B /* HasOneThroughAssociation.swift */; }; 56AE6427222AACE300AD1B0B /* AssociationHasOneThroughSQLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56AE6426222AACE300AD1B0B /* AssociationHasOneThroughSQLTests.swift */; }; 56AE6428222AACE300AD1B0B /* AssociationHasOneThroughSQLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56AE6426222AACE300AD1B0B /* AssociationHasOneThroughSQLTests.swift */; }; 56AF746E1D41FB9C005E9FF3 /* DatabaseValueConvertibleEscapingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56AF746A1D41FB9C005E9FF3 /* DatabaseValueConvertibleEscapingTests.swift */; }; @@ -402,28 +434,10 @@ 56CEB4FF1EAA2F4D00BFAF62 /* FTS3.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB4F81EAA2F4D00BFAF62 /* FTS3.swift */; }; 56CEB5031EAA2F4D00BFAF62 /* FTS4.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB4F91EAA2F4D00BFAF62 /* FTS4.swift */; }; 56CEB5061EAA2F4D00BFAF62 /* FTS4.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB4F91EAA2F4D00BFAF62 /* FTS4.swift */; }; - 56CEB5131EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5101EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift */; }; - 56CEB5161EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5101EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift */; }; - 56CEB51B1EAA328900BFAF62 /* FTS5+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5181EAA328900BFAF62 /* FTS5+QueryInterface.swift */; }; - 56CEB51E1EAA328900BFAF62 /* FTS5+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5181EAA328900BFAF62 /* FTS5+QueryInterface.swift */; }; - 56CEB5471EAA359A00BFAF62 /* Column.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5401EAA359A00BFAF62 /* Column.swift */; }; - 56CEB54A1EAA359A00BFAF62 /* Column.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5401EAA359A00BFAF62 /* Column.swift */; }; - 56CEB54E1EAA359A00BFAF62 /* SQLExpressible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5411EAA359A00BFAF62 /* SQLExpressible.swift */; }; - 56CEB5511EAA359A00BFAF62 /* SQLExpressible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5411EAA359A00BFAF62 /* SQLExpressible.swift */; }; - 56CEB5551EAA359A00BFAF62 /* SQLExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5421EAA359A00BFAF62 /* SQLExpression.swift */; }; - 56CEB5581EAA359A00BFAF62 /* SQLExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5421EAA359A00BFAF62 /* SQLExpression.swift */; }; - 56CEB55C1EAA359A00BFAF62 /* SQLOrdering.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5431EAA359A00BFAF62 /* SQLOrdering.swift */; }; - 56CEB55F1EAA359A00BFAF62 /* SQLOrdering.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5431EAA359A00BFAF62 /* SQLOrdering.swift */; }; - 56CEB5631EAA359A00BFAF62 /* SQLSelectable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5441EAA359A00BFAF62 /* SQLSelectable.swift */; }; - 56CEB5661EAA359A00BFAF62 /* SQLSelectable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56CEB5441EAA359A00BFAF62 /* SQLSelectable.swift */; }; 56D507611F6BAE8600AE1C5B /* PrimaryKeyInfoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D5075D1F6BAE8600AE1C5B /* PrimaryKeyInfoTests.swift */; }; 56D507651F6BAE8600AE1C5B /* PrimaryKeyInfoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D5075D1F6BAE8600AE1C5B /* PrimaryKeyInfoTests.swift */; }; 56D51D021EA789FA0074638A /* FetchableRecord+TableRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D51CFF1EA789FA0074638A /* FetchableRecord+TableRecord.swift */; }; 56D51D051EA789FA0074638A /* FetchableRecord+TableRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D51CFF1EA789FA0074638A /* FetchableRecord+TableRecord.swift */; }; - 56D91A9F2205E02300770D8D /* SQLRelation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D91A9E2205E02300770D8D /* SQLRelation.swift */; }; - 56D91AA02205E02300770D8D /* SQLRelation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D91A9E2205E02300770D8D /* SQLRelation.swift */; }; - 56D91AA62205F2CF00770D8D /* DatabasePromise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D91AA52205F2CF00770D8D /* DatabasePromise.swift */; }; - 56D91AA72205F2CF00770D8D /* DatabasePromise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56D91AA52205F2CF00770D8D /* DatabasePromise.swift */; }; 56DAA2D51DE99DAB006E10C8 /* DatabaseCursorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56DAA2D11DE99DAB006E10C8 /* DatabaseCursorTests.swift */; }; 56DAA2D91DE99DAB006E10C8 /* DatabaseCursorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56DAA2D11DE99DAB006E10C8 /* DatabaseCursorTests.swift */; }; 56DAA2DD1DE9C827006E10C8 /* Cursor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56DAA2DA1DE9C827006E10C8 /* Cursor.swift */; }; @@ -434,8 +448,6 @@ 56DF0018228DDB8300D611F3 /* AssociationPrefetchingRowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56DF0014228DDB8200D611F3 /* AssociationPrefetchingRowTests.swift */; }; 56E9FAC42210468500C703A8 /* SQLInterpolation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56E9FAC32210468500C703A8 /* SQLInterpolation.swift */; }; 56E9FAC52210468500C703A8 /* SQLInterpolation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56E9FAC32210468500C703A8 /* SQLInterpolation.swift */; }; - 56E9FAD22210479700C703A8 /* SQLInterpolation+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56E9FAD12210479700C703A8 /* SQLInterpolation+QueryInterface.swift */; }; - 56E9FAD32210479700C703A8 /* SQLInterpolation+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56E9FAD12210479700C703A8 /* SQLInterpolation+QueryInterface.swift */; }; 56E9FAD52210538400C703A8 /* SQLLiteral.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56E9FAD42210538400C703A8 /* SQLLiteral.swift */; }; 56E9FAD62210538400C703A8 /* SQLLiteral.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56E9FAD42210538400C703A8 /* SQLLiteral.swift */; }; 56EA63C9209C7F1E009715B8 /* DerivableRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56EA63C7209C7F1E009715B8 /* DerivableRequestTests.swift */; }; @@ -446,8 +458,6 @@ 56F3E7501E66F83A00BF0F01 /* ResultCodeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56F3E7481E66F83A00BF0F01 /* ResultCodeTests.swift */; }; 56FBFED62210731100945324 /* SQLRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FBFED52210731000945324 /* SQLRequest.swift */; }; 56FBFED72210731100945324 /* SQLRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FBFED52210731000945324 /* SQLRequest.swift */; }; - 56FC987A1D969DEF00E3C842 /* SQLExpression+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FC98771D969DEF00E3C842 /* SQLExpression+QueryInterface.swift */; }; - 56FC987D1D969DEF00E3C842 /* SQLExpression+QueryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FC98771D969DEF00E3C842 /* SQLExpression+QueryInterface.swift */; }; 56FEE7FE1F47253700D930EA /* TableRecordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FEE7FA1F47253700D930EA /* TableRecordTests.swift */; }; 56FEE8021F47253700D930EA /* TableRecordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FEE7FA1F47253700D930EA /* TableRecordTests.swift */; }; 56FF45431D2C23BA00F21EF9 /* MutablePersistableRecordDeleteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FF453F1D2C23BA00F21EF9 /* MutablePersistableRecordDeleteTests.swift */; }; @@ -481,9 +491,6 @@ F3BA80231CFB288C003DC1BA /* NSString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1521C672E4000235C62 /* NSString.swift */; }; F3BA80271CFB2891003DC1BA /* DatabaseValueConvertible+RawRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1571C672E4000235C62 /* DatabaseValueConvertible+RawRepresentable.swift */; }; F3BA80281CFB2891003DC1BA /* StandardLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1581C672E4000235C62 /* StandardLibrary.swift */; }; - F3BA802B1CFB289B003DC1BA /* QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B6F1C53F592005A543B /* QueryInterfaceRequest.swift */; }; - F3BA802C1CFB289B003DC1BA /* SQLCollatedExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1891C6B1A8700235C62 /* SQLCollatedExpression.swift */; }; - F3BA802F1CFB289B003DC1BA /* SQLSelectQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F18C1C6B1A8700235C62 /* SQLSelectQuery.swift */; }; F3BA80301CFB289F003DC1BA /* DatabaseMigrator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238921B9C750B0082EB20 /* DatabaseMigrator.swift */; }; F3BA80311CFB289F003DC1BA /* Migration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4391BEB42D500E39BBF /* Migration.swift */; }; F3BA80321CFB28A4003DC1BA /* FetchedRecordsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31A7787C1C6A4DD600F507F6 /* FetchedRecordsController.swift */; }; @@ -525,9 +532,6 @@ F3BA807F1CFB2E61003DC1BA /* NSString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1521C672E4000235C62 /* NSString.swift */; }; F3BA80831CFB2E67003DC1BA /* DatabaseValueConvertible+RawRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1571C672E4000235C62 /* DatabaseValueConvertible+RawRepresentable.swift */; }; F3BA80841CFB2E67003DC1BA /* StandardLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1581C672E4000235C62 /* StandardLibrary.swift */; }; - F3BA80871CFB2E70003DC1BA /* QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B6F1C53F592005A543B /* QueryInterfaceRequest.swift */; }; - F3BA80881CFB2E70003DC1BA /* SQLCollatedExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1891C6B1A8700235C62 /* SQLCollatedExpression.swift */; }; - F3BA808B1CFB2E70003DC1BA /* SQLSelectQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F18C1C6B1A8700235C62 /* SQLSelectQuery.swift */; }; F3BA808C1CFB2E75003DC1BA /* DatabaseMigrator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238921B9C750B0082EB20 /* DatabaseMigrator.swift */; }; F3BA808D1CFB2E75003DC1BA /* Migration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4391BEB42D500E39BBF /* Migration.swift */; }; F3BA808E1CFB2E7A003DC1BA /* FetchedRecordsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31A7787C1C6A4DD600F507F6 /* FetchedRecordsController.swift */; }; @@ -712,10 +716,6 @@ 5605F1571C672E4000235C62 /* DatabaseValueConvertible+RawRepresentable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DatabaseValueConvertible+RawRepresentable.swift"; sourceTree = ""; }; 5605F1581C672E4000235C62 /* StandardLibrary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StandardLibrary.swift; sourceTree = ""; }; 5605F1861C69111300235C62 /* DatabaseRegionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseRegionTests.swift; sourceTree = ""; }; - 5605F1891C6B1A8700235C62 /* SQLCollatedExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLCollatedExpression.swift; sourceTree = ""; }; - 5605F18C1C6B1A8700235C62 /* SQLSelectQuery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLSelectQuery.swift; sourceTree = ""; }; - 56071499227618660091BB10 /* Row+QueryInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Row+QueryInterface.swift"; sourceTree = ""; }; - 5607149D227618800091BB10 /* FetchableRecord+QueryInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FetchableRecord+QueryInterface.swift"; sourceTree = ""; }; 560714EB227DD10F0091BB10 /* AssociationPrefetchingSQLTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssociationPrefetchingSQLTests.swift; sourceTree = ""; }; 5607EFD21BB8254800605DE3 /* TransactionObserverTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransactionObserverTests.swift; sourceTree = ""; }; 560A37A31C8F625000949E71 /* DatabasePool.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabasePool.swift; sourceTree = ""; }; @@ -741,7 +741,6 @@ 5615B277222B109500061C1C /* AssociationHasOneThroughFetchableRecordTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationHasOneThroughFetchableRecordTests.swift; sourceTree = ""; }; 5615B284222B17B900061C1C /* AssociationHasOneThroughDecodableRecordTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationHasOneThroughDecodableRecordTests.swift; sourceTree = ""; }; 561667001D08A49900ADD404 /* FoundationNSDecimalNumberTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FoundationNSDecimalNumberTests.swift; sourceTree = ""; }; - 5616AAF4207CD59300AC3664 /* RequestProtocols.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RequestProtocols.swift; sourceTree = ""; }; 561729532235340E0006E219 /* EncodableRecord.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EncodableRecord.swift; sourceTree = ""; }; 562393171DECC02000A6B01F /* RowFetchTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowFetchTests.swift; sourceTree = ""; }; 5623932F1DEDFC5700A6B01F /* AnyCursorTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnyCursorTests.swift; sourceTree = ""; }; @@ -758,7 +757,6 @@ 56300B601C53C42C005A543B /* FetchableRecord+QueryInterfaceRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FetchableRecord+QueryInterfaceRequestTests.swift"; sourceTree = ""; }; 56300B671C53D25E005A543B /* QueryInterfaceExpressionsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QueryInterfaceExpressionsTests.swift; sourceTree = ""; }; 56300B6A1C53D3E8005A543B /* TableRecord+QueryInterfaceRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "TableRecord+QueryInterfaceRequestTests.swift"; sourceTree = ""; }; - 56300B6F1C53F592005A543B /* QueryInterfaceRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QueryInterfaceRequest.swift; sourceTree = ""; }; 56300B841C54DC95005A543B /* Record+QueryInterfaceRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Record+QueryInterfaceRequestTests.swift"; sourceTree = ""; }; 563363A91C933FF8000BE133 /* MutablePersistableRecordTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MutablePersistableRecordTests.swift; sourceTree = ""; }; 563363AA1C933FF8000BE133 /* PersistableRecordTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PersistableRecordTests.swift; sourceTree = ""; }; @@ -779,7 +777,6 @@ 563B071121862C3E00B38F35 /* ValueObservationRecordTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationRecordTests.swift; sourceTree = ""; }; 563B071A21862F5600B38F35 /* ValueObservationDatabaseValueConvertibleTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationDatabaseValueConvertibleTests.swift; sourceTree = ""; }; 563EF41E215F8A76007DAACD /* OrderedDictionary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderedDictionary.swift; sourceTree = ""; }; - 563EF4362161182C007DAACD /* AssociationAggregate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationAggregate.swift; sourceTree = ""; }; 563EF441216131F5007DAACD /* AssociationAggregateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationAggregateTests.swift; sourceTree = ""; }; 563EF44C2161F196007DAACD /* Inflections.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Inflections.swift; sourceTree = ""; }; 563EF45521631E3E007DAACD /* QueryInterfacePromiseTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QueryInterfacePromiseTests.swift; sourceTree = ""; }; @@ -798,13 +795,6 @@ 564E73E7203DA278000C443C /* JoinSupportTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JoinSupportTests.swift; sourceTree = ""; }; 564F9C1D1F069B4E00877A00 /* DatabaseAggregateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseAggregateTests.swift; sourceTree = ""; }; 564F9C2C1F075DD200877A00 /* DatabaseFunction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseFunction.swift; sourceTree = ""; }; - 5653EB3720961F6000F46237 /* BelongsToAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BelongsToAssociation.swift; sourceTree = ""; }; - 5653EB3820961F6000F46237 /* HasOneAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HasOneAssociation.swift; sourceTree = ""; }; - 5653EB3A20961F6000F46237 /* HasManyAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HasManyAssociation.swift; sourceTree = ""; }; - 5653EB3B20961F6000F46237 /* ForeignKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForeignKey.swift; sourceTree = ""; }; - 5653EB3C20961F6000F46237 /* ForeignKeyRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForeignKeyRequest.swift; sourceTree = ""; }; - 5653EB3E20961F6100F46237 /* Association.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Association.swift; sourceTree = ""; }; - 5653EB5320961F7D00F46237 /* QueryInterfaceRequest+Association.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "QueryInterfaceRequest+Association.swift"; sourceTree = ""; }; 5653EB5820961FB000F46237 /* AssociationParallelSQLTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationParallelSQLTests.swift; sourceTree = ""; }; 5653EB5920961FB100F46237 /* AssociationBelongsToFetchableRecordTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationBelongsToFetchableRecordTests.swift; sourceTree = ""; }; 5653EB5A20961FB100F46237 /* AssociationParallelDecodableRecordTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationParallelDecodableRecordTests.swift; sourceTree = ""; }; @@ -819,8 +809,45 @@ 5653EB6320961FB200F46237 /* AssociationChainSQLTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationChainSQLTests.swift; sourceTree = ""; }; 5653EB6420961FB200F46237 /* AssociationBelongsToDecodableRecordTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationBelongsToDecodableRecordTests.swift; sourceTree = ""; }; 5653EB6520961FB200F46237 /* AssociationBelongsToRowScopeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationBelongsToRowScopeTests.swift; sourceTree = ""; }; - 5653EC072098737400F46237 /* SQLGenerationContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SQLGenerationContext.swift; sourceTree = ""; }; 5656A7F422946B1B001FF3FF /* ValueObservationQueryInterfaceRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValueObservationQueryInterfaceRequestTests.swift; sourceTree = ""; }; + 5656A8262295BD56001FF3FF /* SQLInterpolation+QueryInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SQLInterpolation+QueryInterface.swift"; sourceTree = ""; }; + 5656A8282295BD56001FF3FF /* FTS5+QueryInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FTS5+QueryInterface.swift"; sourceTree = ""; }; + 5656A82A2295BD56001FF3FF /* SQLQueryGenerator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLQueryGenerator.swift; sourceTree = ""; }; + 5656A82B2295BD56001FF3FF /* SQLGenerationContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLGenerationContext.swift; sourceTree = ""; }; + 5656A82D2295BD56001FF3FF /* TableDefinition.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableDefinition.swift; sourceTree = ""; }; + 5656A82E2295BD56001FF3FF /* VirtualTableModule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VirtualTableModule.swift; sourceTree = ""; }; + 5656A82F2295BD56001FF3FF /* FTS3+QueryInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FTS3+QueryInterface.swift"; sourceTree = ""; }; + 5656A8312295BD56001FF3FF /* TableRecord+Association.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "TableRecord+Association.swift"; sourceTree = ""; }; + 5656A8322295BD56001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FetchableRecord+QueryInterfaceRequest.swift"; sourceTree = ""; }; + 5656A8342295BD56001FF3FF /* BelongsToAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BelongsToAssociation.swift; sourceTree = ""; }; + 5656A8352295BD56001FF3FF /* HasOneAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HasOneAssociation.swift; sourceTree = ""; }; + 5656A8362295BD56001FF3FF /* AssociationAggregate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationAggregate.swift; sourceTree = ""; }; + 5656A8372295BD56001FF3FF /* HasManyAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HasManyAssociation.swift; sourceTree = ""; }; + 5656A8382295BD56001FF3FF /* HasManyThroughAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HasManyThroughAssociation.swift; sourceTree = ""; }; + 5656A8392295BD56001FF3FF /* Association.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Association.swift; sourceTree = ""; }; + 5656A83A2295BD56001FF3FF /* HasOneThroughAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HasOneThroughAssociation.swift; sourceTree = ""; }; + 5656A83B2295BD56001FF3FF /* QueryInterfaceRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QueryInterfaceRequest.swift; sourceTree = ""; }; + 5656A83C2295BD56001FF3FF /* RequestProtocols.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RequestProtocols.swift; sourceTree = ""; }; + 5656A83D2295BD56001FF3FF /* TableRecord+QueryInterfaceRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "TableRecord+QueryInterfaceRequest.swift"; sourceTree = ""; }; + 5656A83E2295BD56001FF3FF /* Row+QueryInterfaceRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Row+QueryInterfaceRequest.swift"; sourceTree = ""; }; + 5656A83F2295BD56001FF3FF /* QueryInterfaceRequest+Association.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "QueryInterfaceRequest+Association.swift"; sourceTree = ""; }; + 5656A8412295BD56001FF3FF /* SQLAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLAssociation.swift; sourceTree = ""; }; + 5656A8422295BD56001FF3FF /* SQLForeignKeyRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLForeignKeyRequest.swift; sourceTree = ""; }; + 5656A8432295BD56001FF3FF /* SQLCollection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLCollection.swift; sourceTree = ""; }; + 5656A8442295BD56001FF3FF /* SQLExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLExpression.swift; sourceTree = ""; }; + 5656A8452295BD56001FF3FF /* SQLOrdering.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLOrdering.swift; sourceTree = ""; }; + 5656A8462295BD56001FF3FF /* SQLOperators.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLOperators.swift; sourceTree = ""; }; + 5656A8472295BD56001FF3FF /* SQLExpressible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLExpressible.swift; sourceTree = ""; }; + 5656A8482295BD56001FF3FF /* SQLExpression+QueryInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SQLExpression+QueryInterface.swift"; sourceTree = ""; }; + 5656A8492295BD56001FF3FF /* SQLSelectable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLSelectable.swift; sourceTree = ""; }; + 5656A84A2295BD56001FF3FF /* Column.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Column.swift; sourceTree = ""; }; + 5656A84B2295BD56001FF3FF /* SQLSpecificExpressible+QueryInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SQLSpecificExpressible+QueryInterface.swift"; sourceTree = ""; }; + 5656A84C2295BD56001FF3FF /* SQLFunctions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLFunctions.swift; sourceTree = ""; }; + 5656A84D2295BD56001FF3FF /* SQLCollatedExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLCollatedExpression.swift; sourceTree = ""; }; + 5656A84E2295BD56001FF3FF /* SQLRelation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLRelation.swift; sourceTree = ""; }; + 5656A84F2295BD56001FF3FF /* SQLSelectable+QueryInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SQLSelectable+QueryInterface.swift"; sourceTree = ""; }; + 5656A8502295BD56001FF3FF /* SQLQuery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLQuery.swift; sourceTree = ""; }; + 5656A8A52295BF44001FF3FF /* DatabasePromise.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabasePromise.swift; sourceTree = ""; }; 5657AAB81D107001006283EF /* NSData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSData.swift; sourceTree = ""; }; 5657AB0E1D10899D006283EF /* URL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = URL.swift; sourceTree = ""; }; 5657AB2F1D108BA9006283EF /* FoundationDataTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FoundationDataTests.swift; sourceTree = ""; }; @@ -839,18 +866,12 @@ 565D5D731BBC70AE00DC9BD4 /* StatementArguments+FoundationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "StatementArguments+FoundationTests.swift"; sourceTree = ""; }; 565EFAED1D0436CE00A8FA9D /* NumericOverflowTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumericOverflowTests.swift; sourceTree = ""; }; 565F03C11CE5D3AA00DE108F /* RowAdapterTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowAdapterTests.swift; sourceTree = ""; }; - 566475991D97D8A000FF74B8 /* SQLCollection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLCollection.swift; sourceTree = ""; }; - 566475A11D9810A400FF74B8 /* SQLSelectable+QueryInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SQLSelectable+QueryInterface.swift"; sourceTree = ""; }; - 566475B91D981AD200FF74B8 /* SQLSpecificExpressible+QueryInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SQLSpecificExpressible+QueryInterface.swift"; sourceTree = ""; }; - 566475CA1D981D5E00FF74B8 /* SQLFunctions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLFunctions.swift; sourceTree = ""; }; - 566475CB1D981D5E00FF74B8 /* SQLOperators.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLOperators.swift; sourceTree = ""; }; 5665F865203EF4590084C6C0 /* ColumnInfoTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColumnInfoTests.swift; sourceTree = ""; }; 5665FA1C2129D807004D8612 /* DatabaseDateDecodingStrategyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseDateDecodingStrategyTests.swift; sourceTree = ""; }; 5665FA3B2129EED8004D8612 /* DatabaseDateEncodingStrategyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseDateEncodingStrategyTests.swift; sourceTree = ""; }; 566A842B20413D9A00E50BFD /* DatabaseSnapshot.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseSnapshot.swift; sourceTree = ""; }; 566A843420413DE400E50BFD /* DatabaseSnapshotTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseSnapshotTests.swift; sourceTree = ""; }; 566A84422041AB2D00E50BFD /* MutablePersistableRecordChangesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MutablePersistableRecordChangesTests.swift; sourceTree = ""; }; - 566AD8B11D5318F4002EC1A8 /* TableDefinition.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableDefinition.swift; sourceTree = ""; }; 566AD8C51D531BE4002EC1A8 /* TableDefinitionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableDefinitionTests.swift; sourceTree = ""; }; 566B91081FA4C3960012D5B0 /* Database+Statements.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Database+Statements.swift"; sourceTree = ""; }; 566B91121FA4C3F50012D5B0 /* DatabaseCollation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatabaseCollation.swift; sourceTree = ""; }; @@ -882,7 +903,6 @@ 567F45A71F888B2600030B59 /* TruncateOptimizationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TruncateOptimizationTests.swift; sourceTree = ""; }; 568068301EBBA26100EFB8AA /* SQLRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLRequestTests.swift; sourceTree = ""; }; 5687359E1CEDE16C009B9116 /* Betty.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = Betty.jpeg; sourceTree = ""; }; - 568D13142207210400674B58 /* SQLSelectQueryGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SQLSelectQueryGenerator.swift; sourceTree = ""; }; 5690C3251D23E6D800E59934 /* FoundationDateComponentsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FoundationDateComponentsTests.swift; sourceTree = ""; }; 5690C3361D23E7D200E59934 /* FoundationDateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FoundationDateTests.swift; sourceTree = ""; }; 5690C33F1D23E82A00E59934 /* Data.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Data.swift; sourceTree = ""; }; @@ -893,13 +913,11 @@ 569531331C919DF200CF1A2B /* DatabasePoolCollationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabasePoolCollationTests.swift; sourceTree = ""; }; 569531361C919DF700CF1A2B /* DatabasePoolFunctionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabasePoolFunctionTests.swift; sourceTree = ""; }; 5695961E222C4589002CB7C9 /* AssociationHasManyThroughSQLTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationHasManyThroughSQLTests.swift; sourceTree = ""; }; - 5695962C222C4681002CB7C9 /* HasManyThroughAssociation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HasManyThroughAssociation.swift; sourceTree = ""; }; 56959635222D058B002CB7C9 /* AssociationHasManySQLTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationHasManySQLTests.swift; sourceTree = ""; }; 5698AC021D9B9FCF0056AF8C /* QueryInterfaceExtensibilityTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QueryInterfaceExtensibilityTests.swift; sourceTree = ""; }; 5698AC361D9E5A590056AF8C /* FTS3Pattern.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS3Pattern.swift; sourceTree = ""; }; 5698AC3F1DA2BED90056AF8C /* FTS3PatternTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS3PatternTests.swift; sourceTree = ""; }; 5698AC481DA2D48A0056AF8C /* FTS3RecordTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS3RecordTests.swift; sourceTree = ""; }; - 5698AC771DA37DCB0056AF8C /* VirtualTableModule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VirtualTableModule.swift; sourceTree = ""; }; 5698AC7F1DA380A20056AF8C /* VirtualTableModuleTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VirtualTableModuleTests.swift; sourceTree = ""; }; 5698AC881DA389380056AF8C /* FTS3TableBuilderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS3TableBuilderTests.swift; sourceTree = ""; }; 5698AC941DA4B0430056AF8C /* FTS4RecordTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS4RecordTests.swift; sourceTree = ""; }; @@ -957,7 +975,6 @@ 56A8C21E1D1914110096E9D4 /* FoundationUUIDTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FoundationUUIDTests.swift; sourceTree = ""; }; 56A8C22F1D1914540096E9D4 /* UUID.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UUID.swift; sourceTree = ""; }; 56A8C2361D1914790096E9D4 /* FoundationNSUUIDTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FoundationNSUUIDTests.swift; sourceTree = ""; }; - 56AE641F222AAB1700AD1B0B /* HasOneThroughAssociation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HasOneThroughAssociation.swift; sourceTree = ""; }; 56AE6426222AACE300AD1B0B /* AssociationHasOneThroughSQLTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssociationHasOneThroughSQLTests.swift; sourceTree = ""; }; 56AF746A1D41FB9C005E9FF3 /* DatabaseValueConvertibleEscapingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseValueConvertibleEscapingTests.swift; sourceTree = ""; }; 56B021C81D8C0D3900B239BB /* MutablePersistableRecordPersistenceConflictPolicyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MutablePersistableRecordPersistenceConflictPolicyTests.swift; sourceTree = ""; }; @@ -986,17 +1003,8 @@ 56CEB4F01EAA2EFA00BFAF62 /* FetchableRecord.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchableRecord.swift; sourceTree = ""; }; 56CEB4F81EAA2F4D00BFAF62 /* FTS3.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS3.swift; sourceTree = ""; }; 56CEB4F91EAA2F4D00BFAF62 /* FTS4.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS4.swift; sourceTree = ""; }; - 56CEB5101EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FTS3+QueryInterfaceRequest.swift"; sourceTree = ""; }; - 56CEB5181EAA328900BFAF62 /* FTS5+QueryInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FTS5+QueryInterface.swift"; sourceTree = ""; }; - 56CEB5401EAA359A00BFAF62 /* Column.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Column.swift; sourceTree = ""; }; - 56CEB5411EAA359A00BFAF62 /* SQLExpressible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLExpressible.swift; sourceTree = ""; }; - 56CEB5421EAA359A00BFAF62 /* SQLExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLExpression.swift; sourceTree = ""; }; - 56CEB5431EAA359A00BFAF62 /* SQLOrdering.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLOrdering.swift; sourceTree = ""; }; - 56CEB5441EAA359A00BFAF62 /* SQLSelectable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLSelectable.swift; sourceTree = ""; }; 56D5075D1F6BAE8600AE1C5B /* PrimaryKeyInfoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimaryKeyInfoTests.swift; sourceTree = ""; }; 56D51CFF1EA789FA0074638A /* FetchableRecord+TableRecord.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FetchableRecord+TableRecord.swift"; sourceTree = ""; }; - 56D91A9E2205E02300770D8D /* SQLRelation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLRelation.swift; sourceTree = ""; }; - 56D91AA52205F2CF00770D8D /* DatabasePromise.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatabasePromise.swift; sourceTree = ""; }; 56DAA2D11DE99DAB006E10C8 /* DatabaseCursorTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseCursorTests.swift; sourceTree = ""; }; 56DAA2DA1DE9C827006E10C8 /* Cursor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Cursor.swift; sourceTree = ""; }; 56DE7B101C3D93ED00861EB8 /* StatementArgumentsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementArgumentsTests.swift; sourceTree = ""; }; @@ -1005,7 +1013,6 @@ 56E8CE0C1BB4FA5600828BEC /* DatabaseValueConvertibleFetchTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseValueConvertibleFetchTests.swift; sourceTree = ""; }; 56E8CE0F1BB4FE5B00828BEC /* StatementColumnConvertibleFetchTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementColumnConvertibleFetchTests.swift; sourceTree = ""; }; 56E9FAC32210468500C703A8 /* SQLInterpolation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLInterpolation.swift; sourceTree = ""; }; - 56E9FAD12210479700C703A8 /* SQLInterpolation+QueryInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SQLInterpolation+QueryInterface.swift"; sourceTree = ""; }; 56E9FAD42210538400C703A8 /* SQLLiteral.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLLiteral.swift; sourceTree = ""; }; 56EA63C7209C7F1E009715B8 /* DerivableRequestTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DerivableRequestTests.swift; sourceTree = ""; }; 56EA86931C91DFE7002BB4DF /* DatabaseReaderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseReaderTests.swift; sourceTree = ""; }; @@ -1015,7 +1022,6 @@ 56F0B98E1B6001C600A2F135 /* FoundationNSDateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FoundationNSDateTests.swift; sourceTree = ""; }; 56F3E7481E66F83A00BF0F01 /* ResultCodeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ResultCodeTests.swift; sourceTree = ""; }; 56FBFED52210731000945324 /* SQLRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SQLRequest.swift; sourceTree = ""; }; - 56FC98771D969DEF00E3C842 /* SQLExpression+QueryInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SQLExpression+QueryInterface.swift"; sourceTree = ""; }; 56FDECE11BB32DFD009AD709 /* RowFromStatementTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowFromStatementTests.swift; sourceTree = ""; }; 56FEE7FA1F47253700D930EA /* TableRecordTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableRecordTests.swift; sourceTree = ""; }; 56FF453F1D2C23BA00F21EF9 /* MutablePersistableRecordDeleteTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MutablePersistableRecordDeleteTests.swift; sourceTree = ""; }; @@ -1286,40 +1292,6 @@ name = QueryInterface; sourceTree = ""; }; - 56300B6D1C53F592005A543B /* QueryInterface */ = { - isa = PBXGroup; - children = ( - 5653EB3620961F6000F46237 /* Association */, - 56CEB5401EAA359A00BFAF62 /* Column.swift */, - 56D91AA52205F2CF00770D8D /* DatabasePromise.swift */, - 5607149D227618800091BB10 /* FetchableRecord+QueryInterface.swift */, - 56CEB5101EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift */, - 56CEB5181EAA328900BFAF62 /* FTS5+QueryInterface.swift */, - 56300B6F1C53F592005A543B /* QueryInterfaceRequest.swift */, - 5653EB5320961F7D00F46237 /* QueryInterfaceRequest+Association.swift */, - 5616AAF4207CD59300AC3664 /* RequestProtocols.swift */, - 56071499227618660091BB10 /* Row+QueryInterface.swift */, - 5605F1891C6B1A8700235C62 /* SQLCollatedExpression.swift */, - 566475991D97D8A000FF74B8 /* SQLCollection.swift */, - 56CEB5411EAA359A00BFAF62 /* SQLExpressible.swift */, - 56CEB5421EAA359A00BFAF62 /* SQLExpression.swift */, - 56FC98771D969DEF00E3C842 /* SQLExpression+QueryInterface.swift */, - 5653EC072098737400F46237 /* SQLGenerationContext.swift */, - 56E9FAD12210479700C703A8 /* SQLInterpolation+QueryInterface.swift */, - 56CEB5431EAA359A00BFAF62 /* SQLOrdering.swift */, - 56D91A9E2205E02300770D8D /* SQLRelation.swift */, - 56CEB5441EAA359A00BFAF62 /* SQLSelectable.swift */, - 566475A11D9810A400FF74B8 /* SQLSelectable+QueryInterface.swift */, - 5605F18C1C6B1A8700235C62 /* SQLSelectQuery.swift */, - 568D13142207210400674B58 /* SQLSelectQueryGenerator.swift */, - 566475B91D981AD200FF74B8 /* SQLSpecificExpressible+QueryInterface.swift */, - 566475C91D981D5E00FF74B8 /* Support */, - 566AD8B11D5318F4002EC1A8 /* TableDefinition.swift */, - 5698AC771DA37DCB0056AF8C /* VirtualTableModule.swift */, - ); - path = QueryInterface; - sourceTree = ""; - }; 563363BB1C93FD32000BE133 /* DatabaseQueue */ = { isa = PBXGroup; children = ( @@ -1353,22 +1325,6 @@ name = ValueObservation; sourceTree = ""; }; - 5653EB3620961F6000F46237 /* Association */ = { - isa = PBXGroup; - children = ( - 5653EB3E20961F6100F46237 /* Association.swift */, - 563EF4362161182C007DAACD /* AssociationAggregate.swift */, - 5653EB3720961F6000F46237 /* BelongsToAssociation.swift */, - 5653EB3B20961F6000F46237 /* ForeignKey.swift */, - 5653EB3C20961F6000F46237 /* ForeignKeyRequest.swift */, - 5653EB3A20961F6000F46237 /* HasManyAssociation.swift */, - 5695962C222C4681002CB7C9 /* HasManyThroughAssociation.swift */, - 5653EB3820961F6000F46237 /* HasOneAssociation.swift */, - 56AE641F222AAB1700AD1B0B /* HasOneThroughAssociation.swift */, - ); - path = Association; - sourceTree = ""; - }; 5653EB5620961F8900F46237 /* Association */ = { isa = PBXGroup; children = ( @@ -1405,6 +1361,91 @@ name = Association; sourceTree = ""; }; + 5656A8252295BD56001FF3FF /* QueryInterface */ = { + isa = PBXGroup; + children = ( + 5656A8322295BD56001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift */, + 5656A82F2295BD56001FF3FF /* FTS3+QueryInterface.swift */, + 5656A8282295BD56001FF3FF /* FTS5+QueryInterface.swift */, + 5656A8302295BD56001FF3FF /* Request */, + 5656A83E2295BD56001FF3FF /* Row+QueryInterfaceRequest.swift */, + 5656A82C2295BD56001FF3FF /* Schema */, + 5656A8402295BD56001FF3FF /* SQL */, + 5656A8292295BD56001FF3FF /* SQLGeneration */, + 5656A8262295BD56001FF3FF /* SQLInterpolation+QueryInterface.swift */, + 5656A8312295BD56001FF3FF /* TableRecord+Association.swift */, + 5656A83D2295BD56001FF3FF /* TableRecord+QueryInterfaceRequest.swift */, + ); + path = QueryInterface; + sourceTree = ""; + }; + 5656A8292295BD56001FF3FF /* SQLGeneration */ = { + isa = PBXGroup; + children = ( + 5656A82B2295BD56001FF3FF /* SQLGenerationContext.swift */, + 5656A82A2295BD56001FF3FF /* SQLQueryGenerator.swift */, + ); + path = SQLGeneration; + sourceTree = ""; + }; + 5656A82C2295BD56001FF3FF /* Schema */ = { + isa = PBXGroup; + children = ( + 5656A82D2295BD56001FF3FF /* TableDefinition.swift */, + 5656A82E2295BD56001FF3FF /* VirtualTableModule.swift */, + ); + path = Schema; + sourceTree = ""; + }; + 5656A8302295BD56001FF3FF /* Request */ = { + isa = PBXGroup; + children = ( + 5656A8332295BD56001FF3FF /* Association */, + 5656A83B2295BD56001FF3FF /* QueryInterfaceRequest.swift */, + 5656A83F2295BD56001FF3FF /* QueryInterfaceRequest+Association.swift */, + 5656A83C2295BD56001FF3FF /* RequestProtocols.swift */, + ); + path = Request; + sourceTree = ""; + }; + 5656A8332295BD56001FF3FF /* Association */ = { + isa = PBXGroup; + children = ( + 5656A8392295BD56001FF3FF /* Association.swift */, + 5656A8362295BD56001FF3FF /* AssociationAggregate.swift */, + 5656A8342295BD56001FF3FF /* BelongsToAssociation.swift */, + 5656A8372295BD56001FF3FF /* HasManyAssociation.swift */, + 5656A8382295BD56001FF3FF /* HasManyThroughAssociation.swift */, + 5656A8352295BD56001FF3FF /* HasOneAssociation.swift */, + 5656A83A2295BD56001FF3FF /* HasOneThroughAssociation.swift */, + ); + path = Association; + sourceTree = ""; + }; + 5656A8402295BD56001FF3FF /* SQL */ = { + isa = PBXGroup; + children = ( + 5656A84A2295BD56001FF3FF /* Column.swift */, + 5656A8A52295BF44001FF3FF /* DatabasePromise.swift */, + 5656A8412295BD56001FF3FF /* SQLAssociation.swift */, + 5656A84D2295BD56001FF3FF /* SQLCollatedExpression.swift */, + 5656A8432295BD56001FF3FF /* SQLCollection.swift */, + 5656A8472295BD56001FF3FF /* SQLExpressible.swift */, + 5656A8442295BD56001FF3FF /* SQLExpression.swift */, + 5656A8482295BD56001FF3FF /* SQLExpression+QueryInterface.swift */, + 5656A8422295BD56001FF3FF /* SQLForeignKeyRequest.swift */, + 5656A84C2295BD56001FF3FF /* SQLFunctions.swift */, + 5656A8462295BD56001FF3FF /* SQLOperators.swift */, + 5656A8452295BD56001FF3FF /* SQLOrdering.swift */, + 5656A8502295BD56001FF3FF /* SQLQuery.swift */, + 5656A84E2295BD56001FF3FF /* SQLRelation.swift */, + 5656A8492295BD56001FF3FF /* SQLSelectable.swift */, + 5656A84F2295BD56001FF3FF /* SQLSelectable+QueryInterface.swift */, + 5656A84B2295BD56001FF3FF /* SQLSpecificExpressible+QueryInterface.swift */, + ); + path = SQL; + sourceTree = ""; + }; 5659F4861EA8D94E004A4992 /* Utils */ = { isa = PBXGroup; children = ( @@ -1419,15 +1460,6 @@ path = Utils; sourceTree = ""; }; - 566475C91D981D5E00FF74B8 /* Support */ = { - isa = PBXGroup; - children = ( - 566475CA1D981D5E00FF74B8 /* SQLFunctions.swift */, - 566475CB1D981D5E00FF74B8 /* SQLOperators.swift */, - ); - path = Support; - sourceTree = ""; - }; 5674A7251F30A8EF0095F066 /* FetchableRecord */ = { isa = PBXGroup; children = ( @@ -1745,7 +1777,7 @@ 5614089D221596A100DAD589 /* Fixit */, 5698AC291D9E5A480056AF8C /* FTS */, 56A238911B9C750B0082EB20 /* Migration */, - 56300B6D1C53F592005A543B /* QueryInterface */, + 5656A8252295BD56001FF3FF /* QueryInterface */, 56A2389F1B9C753B0082EB20 /* Record */, DC37743319C8CFCE004FCF85 /* Supporting Files */, 5659F4861EA8D94E004A4992 /* Utils */, @@ -2050,28 +2082,30 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 563EF4392161182C007DAACD /* AssociationAggregate.swift in Sources */, - 5616AAF7207CD59400AC3664 /* RequestProtocols.swift in Sources */, + 5656A8722295BD56001FF3FF /* HasOneThroughAssociation.swift in Sources */, 5636E9C11D22574100B9B05F /* FetchRequest.swift in Sources */, F3BA801B1CFB2886003DC1BA /* CGFloat.swift in Sources */, + 5656A85E2295BD56001FF3FF /* VirtualTableModule.swift in Sources */, + 5656A8882295BD56001FF3FF /* SQLOperators.swift in Sources */, 563EF44E2161F196007DAACD /* Inflections.swift in Sources */, 566B910E1FA4C3970012D5B0 /* Database+Statements.swift in Sources */, + 5656A8682295BD56001FF3FF /* HasOneAssociation.swift in Sources */, 566B91281FA4CF810012D5B0 /* Database+Schema.swift in Sources */, - 56CEB5161EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift in Sources */, + 5656A8602295BD56001FF3FF /* FTS3+QueryInterface.swift in Sources */, + 5656A8982295BD56001FF3FF /* SQLRelation.swift in Sources */, 5659F4951EA8D964004A4992 /* ReadWriteBox.swift in Sources */, 566A842E20413D9A00E50BFD /* DatabaseSnapshot.swift in Sources */, 56CEB4F61EAA2EFA00BFAF62 /* FetchableRecord.swift in Sources */, + 5656A8522295BD56001FF3FF /* SQLInterpolation+QueryInterface.swift in Sources */, 56BB6EAE1D3009B100A1CA52 /* SchedulingWatchdog.swift in Sources */, F3BA801A1CFB2876003DC1BA /* StatementColumnConvertible.swift in Sources */, - 5653EB4C20961F6100F46237 /* ForeignKeyRequest.swift in Sources */, 5613ED6821A95E6100DC7A68 /* ValueObservation+Row.swift in Sources */, 566B91381FA4D3810012D5B0 /* TransactionObserver.swift in Sources */, 5613ED7021A95E6100DC7A68 /* ValueObservation+Count.swift in Sources */, - 566475D81D981D5E00FF74B8 /* SQLOperators.swift in Sources */, - 5653EB4420961F6100F46237 /* HasOneAssociation.swift in Sources */, - 56CEB5661EAA359A00BFAF62 /* SQLSelectable.swift in Sources */, 56CEB4FF1EAA2F4D00BFAF62 /* FTS3.swift in Sources */, + 5656A8922295BD56001FF3FF /* SQLSpecificExpressible+QueryInterface.swift in Sources */, 5698AD3A1DABAF4A0056AF8C /* FTS5CustomTokenizer.swift in Sources */, + 5656A8742295BD56001FF3FF /* QueryInterfaceRequest.swift in Sources */, 564CE5A321B7A9C700652B19 /* ValueObservation+DistinctUntilChanged.swift in Sources */, 566B91181FA4C3F50012D5B0 /* DatabaseCollation.swift in Sources */, F3BA80181CFB2876003DC1BA /* SerializedDatabase.swift in Sources */, @@ -2079,100 +2113,100 @@ 5659F4A51EA8D997004A4992 /* Result.swift in Sources */, 564CE52521B312AD00652B19 /* ValueObservation+MapReducer.swift in Sources */, F3BA800D1CFB2871003DC1BA /* DatabasePool.swift in Sources */, + 5656A87C2295BD56001FF3FF /* QueryInterfaceRequest+Association.swift in Sources */, F3BA800B1CFB286D003DC1BA /* Database.swift in Sources */, F3BA80341CFB28A4003DC1BA /* Record.swift in Sources */, + 5656A87A2295BD56001FF3FF /* Row+QueryInterfaceRequest.swift in Sources */, 56E9FAC52210468500C703A8 /* SQLInterpolation.swift in Sources */, 563EF421215F8A76007DAACD /* OrderedDictionary.swift in Sources */, F3BA80161CFB2876003DC1BA /* Row.swift in Sources */, 569EF0E7200D37FD00A9FA45 /* DatabaseRegion.swift in Sources */, F3BA80101CFB2876003DC1BA /* DatabaseReader.swift in Sources */, 564F9C331F07611800877A00 /* DatabaseFunction.swift in Sources */, + 5656A8942295BD56001FF3FF /* SQLFunctions.swift in Sources */, 5659F49D1EA8D989004A4992 /* Pool.swift in Sources */, - 5653EB4220961F6100F46237 /* BelongsToAssociation.swift in Sources */, 5674A6F61F307F600095F066 /* EncodableRecord+Encodable.swift in Sources */, - 56CEB5511EAA359A00BFAF62 /* SQLExpressible.swift in Sources */, + 5656A88A2295BD56001FF3FF /* SQLExpressible.swift in Sources */, 5698AC3C1D9E5A590056AF8C /* FTS3Pattern.swift in Sources */, - 566475D11D981D5E00FF74B8 /* SQLFunctions.swift in Sources */, - 5664759F1D97D8A000FF74B8 /* SQLCollection.swift in Sources */, - 5653EB5520961F7D00F46237 /* QueryInterfaceRequest+Association.swift in Sources */, - F3BA802B1CFB289B003DC1BA /* QueryInterfaceRequest.swift in Sources */, 5698AD171DAAD16F0056AF8C /* FTS5Tokenizer.swift in Sources */, 569BBA4C229170B300478429 /* Inflections+English.swift in Sources */, + 5656A8762295BD56001FF3FF /* RequestProtocols.swift in Sources */, 561729552235340E0006E219 /* EncodableRecord.swift in Sources */, + 5656A87E2295BD56001FF3FF /* SQLAssociation.swift in Sources */, F3BA80131CFB2876003DC1BA /* DatabaseValue.swift in Sources */, 56B964B61DA51D010002DA19 /* FTS5TokenizerDescriptor.swift in Sources */, F3BA80171CFB2876003DC1BA /* RowAdapter.swift in Sources */, 564CE4DB21B2DEEB00652B19 /* ValueObservation+CompactMap.swift in Sources */, - F3BA802F1CFB289B003DC1BA /* SQLSelectQuery.swift in Sources */, 56CEB5061EAA2F4D00BFAF62 /* FTS4.swift in Sources */, - 56CEB55F1EAA359A00BFAF62 /* SQLOrdering.swift in Sources */, F3BA80201CFB288C003DC1BA /* Date.swift in Sources */, 56A8C2351D1914540096E9D4 /* UUID.swift in Sources */, - 56AE6421222AAB1700AD1B0B /* HasOneThroughAssociation.swift in Sources */, + 5656A8822295BD56001FF3FF /* SQLCollection.swift in Sources */, 56D51D051EA789FA0074638A /* FetchableRecord+TableRecord.swift in Sources */, F3BA80151CFB2876003DC1BA /* DatabaseWriter.swift in Sources */, 5613ED6E21A95E6100DC7A68 /* ValueReducer.swift in Sources */, F3BA800A1CFB286A003DC1BA /* Configuration.swift in Sources */, - 566475BF1D981AD200FF74B8 /* SQLSpecificExpressible+QueryInterface.swift in Sources */, + 5656A86C2295BD56001FF3FF /* HasManyAssociation.swift in Sources */, + 5656A88E2295BD56001FF3FF /* SQLSelectable.swift in Sources */, 5671FC251DA3CAC9003BF4FF /* FTS3TokenizerDescriptor.swift in Sources */, - 56CEB54A1EAA359A00BFAF62 /* Column.swift in Sources */, + 5656A8862295BD56001FF3FF /* SQLOrdering.swift in Sources */, F3BA80311CFB289F003DC1BA /* Migration.swift in Sources */, F3BA801D1CFB288C003DC1BA /* DatabaseDateComponents.swift in Sources */, 5674A6ED1F307F0E0095F066 /* DatabaseValueConvertible+Encodable.swift in Sources */, 5657AB141D10899D006283EF /* URL.swift in Sources */, 5613ED6A21A95E6100DC7A68 /* ValueObservation+FetchableRecord.swift in Sources */, - 56D91AA02205E02300770D8D /* SQLRelation.swift in Sources */, 5644DE7920F8C8EA001FFDDE /* DatabaseValueConversion.swift in Sources */, 56DAA2E01DE9C827006E10C8 /* Cursor.swift in Sources */, - 56D91AA72205F2CF00770D8D /* DatabasePromise.swift in Sources */, - 5695962D222C4682002CB7C9 /* HasManyThroughAssociation.swift in Sources */, F3BA800C1CFB286F003DC1BA /* DatabaseError.swift in Sources */, + 5656A8782295BD56001FF3FF /* TableRecord+QueryInterfaceRequest.swift in Sources */, 566B91301FA4D0CC0012D5B0 /* StatementAuthorizer.swift in Sources */, + 5656A86A2295BD56001FF3FF /* AssociationAggregate.swift in Sources */, F3BA80221CFB288C003DC1BA /* NSNumber.swift in Sources */, + 5656A8582295BD56001FF3FF /* SQLQueryGenerator.swift in Sources */, F3BA80321CFB28A4003DC1BA /* FetchedRecordsController.swift in Sources */, + 5656A8842295BD56001FF3FF /* SQLExpression.swift in Sources */, 5659F48D1EA8D94E004A4992 /* Utils.swift in Sources */, F3BA80231CFB288C003DC1BA /* NSString.swift in Sources */, + 5656A85A2295BD56001FF3FF /* SQLGenerationContext.swift in Sources */, 5690C3451D23E82A00E59934 /* Data.swift in Sources */, - 56FC987D1D969DEF00E3C842 /* SQLExpression+QueryInterface.swift in Sources */, + 5656A8A82295BF44001FF3FF /* DatabasePromise.swift in Sources */, + 5656A86E2295BD56001FF3FF /* HasManyThroughAssociation.swift in Sources */, F3BA80111CFB2876003DC1BA /* DatabaseSchemaCache.swift in Sources */, F3BA80281CFB2891003DC1BA /* StandardLibrary.swift in Sources */, F3BA80331CFB28A4003DC1BA /* PersistableRecord.swift in Sources */, - 568D13162207210400674B58 /* SQLSelectQueryGenerator.swift in Sources */, + 5656A8802295BD56001FF3FF /* SQLForeignKeyRequest.swift in Sources */, 56B964BE1DA51D0A0002DA19 /* FTS5Pattern.swift in Sources */, 561408A1221596A100DAD589 /* GRDB-4.0.swift in Sources */, F3BA80211CFB288C003DC1BA /* NSNull.swift in Sources */, - 56CEB51E1EAA328900BFAF62 /* FTS5+QueryInterface.swift in Sources */, 56FBFED72210731100945324 /* SQLRequest.swift in Sources */, 564CE43D21AA955B00652B19 /* ValueObserver.swift in Sources */, 5674A6FD1F307F600095F066 /* FetchableRecord+Decodable.swift in Sources */, F3BA80141CFB2876003DC1BA /* DatabaseValueConvertible.swift in Sources */, - 5698AC7D1DA37DCB0056AF8C /* VirtualTableModule.swift in Sources */, - 566AD8B71D5318F4002EC1A8 /* TableDefinition.swift in Sources */, + 5656A8702295BD56001FF3FF /* Association.swift in Sources */, + 5656A89C2295BD56001FF3FF /* SQLQuery.swift in Sources */, + 5656A88C2295BD56001FF3FF /* SQLExpression+QueryInterface.swift in Sources */, 5613ED6621A95E6100DC7A68 /* ValueObservation+Map.swift in Sources */, 5698AD261DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift in Sources */, - 56E9FAD32210479700C703A8 /* SQLInterpolation+QueryInterface.swift in Sources */, + 5656A85C2295BD56001FF3FF /* TableDefinition.swift in Sources */, + 5656A8562295BD56001FF3FF /* FTS5+QueryInterface.swift in Sources */, + 5656A8902295BD56001FF3FF /* Column.swift in Sources */, 564CE5B821B8FBEB00652B19 /* DatabaseRegionObservation.swift in Sources */, - F3BA802C1CFB289B003DC1BA /* SQLCollatedExpression.swift in Sources */, - 5653EB4A20961F6100F46237 /* ForeignKey.swift in Sources */, 5613ED6C21A95E6100DC7A68 /* ValueObservation+DatabaseValueConvertible.swift in Sources */, - 5653EB4820961F6100F46237 /* HasManyAssociation.swift in Sources */, + 5656A8622295BD56001FF3FF /* TableRecord+Association.swift in Sources */, F3BA80301CFB289F003DC1BA /* DatabaseMigrator.swift in Sources */, 56E9FAD62210538400C703A8 /* SQLLiteral.swift in Sources */, - 5607149F227618800091BB10 /* FetchableRecord+QueryInterface.swift in Sources */, 5613ED6221A95E6100DC7A68 /* ValueObservation.swift in Sources */, F3BA80361CFB28A4003DC1BA /* TableRecord.swift in Sources */, - 5607149C227618660091BB10 /* Row+QueryInterface.swift in Sources */, 567071F5208A00BE006AD95A /* SQLiteDateParser.swift in Sources */, + 5656A89A2295BD56001FF3FF /* SQLSelectable+QueryInterface.swift in Sources */, F3BA80271CFB2891003DC1BA /* DatabaseValueConvertible+RawRepresentable.swift in Sources */, 5613ED6421A95E6100DC7A68 /* ValueObservation+Combine.swift in Sources */, - 5653EC092098737400F46237 /* SQLGenerationContext.swift in Sources */, - 566475A71D9810A400FF74B8 /* SQLSelectable+QueryInterface.swift in Sources */, 5657AABE1D107001006283EF /* NSData.swift in Sources */, 5674A6E61F307F0E0095F066 /* DatabaseValueConvertible+Decodable.swift in Sources */, - 5653EB5020961F6100F46237 /* Association.swift in Sources */, + 5656A8662295BD56001FF3FF /* BelongsToAssociation.swift in Sources */, F3BA800E1CFB2876003DC1BA /* DatabaseQueue.swift in Sources */, F3BA80191CFB2876003DC1BA /* Statement.swift in Sources */, - 56CEB5581EAA359A00BFAF62 /* SQLExpression.swift in Sources */, + 5656A8962295BD56001FF3FF /* SQLCollatedExpression.swift in Sources */, + 5656A8642295BD56001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift in Sources */, 56B964A21DA51B4C0002DA19 /* FTS5.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2380,28 +2414,30 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 563EF4382161182C007DAACD /* AssociationAggregate.swift in Sources */, - 5616AAF6207CD59400AC3664 /* RequestProtocols.swift in Sources */, + 5656A8712295BD56001FF3FF /* HasOneThroughAssociation.swift in Sources */, 5636E9BE1D22574100B9B05F /* FetchRequest.swift in Sources */, F3BA80771CFB2E5C003DC1BA /* CGFloat.swift in Sources */, + 5656A85D2295BD56001FF3FF /* VirtualTableModule.swift in Sources */, + 5656A8872295BD56001FF3FF /* SQLOperators.swift in Sources */, 563EF44D2161F196007DAACD /* Inflections.swift in Sources */, 566B910B1FA4C3970012D5B0 /* Database+Statements.swift in Sources */, + 5656A8672295BD56001FF3FF /* HasOneAssociation.swift in Sources */, 566B91251FA4CF810012D5B0 /* Database+Schema.swift in Sources */, - 56CEB5131EAA324B00BFAF62 /* FTS3+QueryInterfaceRequest.swift in Sources */, + 5656A85F2295BD56001FF3FF /* FTS3+QueryInterface.swift in Sources */, + 5656A8972295BD56001FF3FF /* SQLRelation.swift in Sources */, 5659F4921EA8D964004A4992 /* ReadWriteBox.swift in Sources */, 566A842D20413D9A00E50BFD /* DatabaseSnapshot.swift in Sources */, 56CEB4F31EAA2EFA00BFAF62 /* FetchableRecord.swift in Sources */, + 5656A8512295BD56001FF3FF /* SQLInterpolation+QueryInterface.swift in Sources */, 56BB6EAB1D3009B100A1CA52 /* SchedulingWatchdog.swift in Sources */, F3BA80761CFB2E55003DC1BA /* StatementColumnConvertible.swift in Sources */, - 5653EB4B20961F6100F46237 /* ForeignKeyRequest.swift in Sources */, 5613ED6721A95E6100DC7A68 /* ValueObservation+Row.swift in Sources */, 566B91351FA4D3810012D5B0 /* TransactionObserver.swift in Sources */, 5613ED6F21A95E6100DC7A68 /* ValueObservation+Count.swift in Sources */, - 566475D51D981D5E00FF74B8 /* SQLOperators.swift in Sources */, - 5653EB4320961F6100F46237 /* HasOneAssociation.swift in Sources */, - 56CEB5631EAA359A00BFAF62 /* SQLSelectable.swift in Sources */, 56CEB4FC1EAA2F4D00BFAF62 /* FTS3.swift in Sources */, + 5656A8912295BD56001FF3FF /* SQLSpecificExpressible+QueryInterface.swift in Sources */, 5698AD371DABAF4A0056AF8C /* FTS5CustomTokenizer.swift in Sources */, + 5656A8732295BD56001FF3FF /* QueryInterfaceRequest.swift in Sources */, 564CE5A221B7A9C700652B19 /* ValueObservation+DistinctUntilChanged.swift in Sources */, 566B91151FA4C3F50012D5B0 /* DatabaseCollation.swift in Sources */, F3BA80741CFB2E55003DC1BA /* SerializedDatabase.swift in Sources */, @@ -2409,100 +2445,100 @@ 5659F4A21EA8D997004A4992 /* Result.swift in Sources */, 564CE52421B312AD00652B19 /* ValueObservation+MapReducer.swift in Sources */, F3BA80691CFB2E55003DC1BA /* DatabasePool.swift in Sources */, + 5656A87B2295BD56001FF3FF /* QueryInterfaceRequest+Association.swift in Sources */, F3BA80671CFB2E55003DC1BA /* Database.swift in Sources */, F3BA80901CFB2E7A003DC1BA /* Record.swift in Sources */, + 5656A8792295BD56001FF3FF /* Row+QueryInterfaceRequest.swift in Sources */, 56E9FAC42210468500C703A8 /* SQLInterpolation.swift in Sources */, 563EF420215F8A76007DAACD /* OrderedDictionary.swift in Sources */, F3BA80721CFB2E55003DC1BA /* Row.swift in Sources */, 569EF0E6200D37FD00A9FA45 /* DatabaseRegion.swift in Sources */, F3BA806C1CFB2E55003DC1BA /* DatabaseReader.swift in Sources */, 564F9C301F07611500877A00 /* DatabaseFunction.swift in Sources */, + 5656A8932295BD56001FF3FF /* SQLFunctions.swift in Sources */, 5659F49A1EA8D989004A4992 /* Pool.swift in Sources */, - 5653EB4120961F6100F46237 /* BelongsToAssociation.swift in Sources */, 5674A6F51F307F600095F066 /* EncodableRecord+Encodable.swift in Sources */, - 56CEB54E1EAA359A00BFAF62 /* SQLExpressible.swift in Sources */, + 5656A8892295BD56001FF3FF /* SQLExpressible.swift in Sources */, 5698AC391D9E5A590056AF8C /* FTS3Pattern.swift in Sources */, - 566475CE1D981D5E00FF74B8 /* SQLFunctions.swift in Sources */, - 5664759C1D97D8A000FF74B8 /* SQLCollection.swift in Sources */, - 5653EB5420961F7D00F46237 /* QueryInterfaceRequest+Association.swift in Sources */, - F3BA80871CFB2E70003DC1BA /* QueryInterfaceRequest.swift in Sources */, 5698AD161DAAD16F0056AF8C /* FTS5Tokenizer.swift in Sources */, 569BBA4D229170B300478429 /* Inflections+English.swift in Sources */, + 5656A8752295BD56001FF3FF /* RequestProtocols.swift in Sources */, 561729562235340E0006E219 /* EncodableRecord.swift in Sources */, + 5656A87D2295BD56001FF3FF /* SQLAssociation.swift in Sources */, F3BA806F1CFB2E55003DC1BA /* DatabaseValue.swift in Sources */, 56B964B31DA51D010002DA19 /* FTS5TokenizerDescriptor.swift in Sources */, F3BA80731CFB2E55003DC1BA /* RowAdapter.swift in Sources */, 564CE4DA21B2DEEB00652B19 /* ValueObservation+CompactMap.swift in Sources */, - F3BA808B1CFB2E70003DC1BA /* SQLSelectQuery.swift in Sources */, 56CEB5031EAA2F4D00BFAF62 /* FTS4.swift in Sources */, - 56CEB55C1EAA359A00BFAF62 /* SQLOrdering.swift in Sources */, F3BA807C1CFB2E61003DC1BA /* Date.swift in Sources */, 56A8C2321D1914540096E9D4 /* UUID.swift in Sources */, - 56AE6422222AAB1700AD1B0B /* HasOneThroughAssociation.swift in Sources */, + 5656A8812295BD56001FF3FF /* SQLCollection.swift in Sources */, 56D51D021EA789FA0074638A /* FetchableRecord+TableRecord.swift in Sources */, F3BA80711CFB2E55003DC1BA /* DatabaseWriter.swift in Sources */, 5613ED6D21A95E6100DC7A68 /* ValueReducer.swift in Sources */, F3BA80661CFB2E55003DC1BA /* Configuration.swift in Sources */, - 566475BC1D981AD200FF74B8 /* SQLSpecificExpressible+QueryInterface.swift in Sources */, + 5656A86B2295BD56001FF3FF /* HasManyAssociation.swift in Sources */, + 5656A88D2295BD56001FF3FF /* SQLSelectable.swift in Sources */, 5671FC221DA3CAC9003BF4FF /* FTS3TokenizerDescriptor.swift in Sources */, - 56CEB5471EAA359A00BFAF62 /* Column.swift in Sources */, + 5656A8852295BD56001FF3FF /* SQLOrdering.swift in Sources */, F3BA808D1CFB2E75003DC1BA /* Migration.swift in Sources */, F3BA80791CFB2E61003DC1BA /* DatabaseDateComponents.swift in Sources */, 5674A6EC1F307F0E0095F066 /* DatabaseValueConvertible+Encodable.swift in Sources */, 5657AB111D10899D006283EF /* URL.swift in Sources */, 5613ED6921A95E6100DC7A68 /* ValueObservation+FetchableRecord.swift in Sources */, - 56D91A9F2205E02300770D8D /* SQLRelation.swift in Sources */, 5644DE7820F8C8EA001FFDDE /* DatabaseValueConversion.swift in Sources */, 56DAA2DD1DE9C827006E10C8 /* Cursor.swift in Sources */, - 56D91AA62205F2CF00770D8D /* DatabasePromise.swift in Sources */, - 5695962E222C4682002CB7C9 /* HasManyThroughAssociation.swift in Sources */, F3BA80681CFB2E55003DC1BA /* DatabaseError.swift in Sources */, + 5656A8772295BD56001FF3FF /* TableRecord+QueryInterfaceRequest.swift in Sources */, 566B912D1FA4D0CC0012D5B0 /* StatementAuthorizer.swift in Sources */, + 5656A8692295BD56001FF3FF /* AssociationAggregate.swift in Sources */, F3BA807E1CFB2E61003DC1BA /* NSNumber.swift in Sources */, + 5656A8572295BD56001FF3FF /* SQLQueryGenerator.swift in Sources */, F3BA808E1CFB2E7A003DC1BA /* FetchedRecordsController.swift in Sources */, + 5656A8832295BD56001FF3FF /* SQLExpression.swift in Sources */, 5659F48A1EA8D94E004A4992 /* Utils.swift in Sources */, F3BA807F1CFB2E61003DC1BA /* NSString.swift in Sources */, + 5656A8592295BD56001FF3FF /* SQLGenerationContext.swift in Sources */, 5690C3421D23E82A00E59934 /* Data.swift in Sources */, - 56FC987A1D969DEF00E3C842 /* SQLExpression+QueryInterface.swift in Sources */, + 5656A8A72295BF44001FF3FF /* DatabasePromise.swift in Sources */, + 5656A86D2295BD56001FF3FF /* HasManyThroughAssociation.swift in Sources */, F3BA806D1CFB2E55003DC1BA /* DatabaseSchemaCache.swift in Sources */, F3BA80841CFB2E67003DC1BA /* StandardLibrary.swift in Sources */, F3BA808F1CFB2E7A003DC1BA /* PersistableRecord.swift in Sources */, - 568D13152207210400674B58 /* SQLSelectQueryGenerator.swift in Sources */, + 5656A87F2295BD56001FF3FF /* SQLForeignKeyRequest.swift in Sources */, 56B964BB1DA51D0A0002DA19 /* FTS5Pattern.swift in Sources */, 561408A0221596A100DAD589 /* GRDB-4.0.swift in Sources */, F3BA807D1CFB2E61003DC1BA /* NSNull.swift in Sources */, - 56CEB51B1EAA328900BFAF62 /* FTS5+QueryInterface.swift in Sources */, 56FBFED62210731100945324 /* SQLRequest.swift in Sources */, 564CE43C21AA955B00652B19 /* ValueObserver.swift in Sources */, 5674A6FC1F307F600095F066 /* FetchableRecord+Decodable.swift in Sources */, F3BA80701CFB2E55003DC1BA /* DatabaseValueConvertible.swift in Sources */, - 5698AC7A1DA37DCB0056AF8C /* VirtualTableModule.swift in Sources */, - 566AD8B41D5318F4002EC1A8 /* TableDefinition.swift in Sources */, + 5656A86F2295BD56001FF3FF /* Association.swift in Sources */, + 5656A89B2295BD56001FF3FF /* SQLQuery.swift in Sources */, + 5656A88B2295BD56001FF3FF /* SQLExpression+QueryInterface.swift in Sources */, 5613ED6521A95E6100DC7A68 /* ValueObservation+Map.swift in Sources */, 5698AD231DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift in Sources */, - 56E9FAD22210479700C703A8 /* SQLInterpolation+QueryInterface.swift in Sources */, + 5656A85B2295BD56001FF3FF /* TableDefinition.swift in Sources */, + 5656A8552295BD56001FF3FF /* FTS5+QueryInterface.swift in Sources */, + 5656A88F2295BD56001FF3FF /* Column.swift in Sources */, 564CE5B721B8FBEB00652B19 /* DatabaseRegionObservation.swift in Sources */, - F3BA80881CFB2E70003DC1BA /* SQLCollatedExpression.swift in Sources */, - 5653EB4920961F6100F46237 /* ForeignKey.swift in Sources */, 5613ED6B21A95E6100DC7A68 /* ValueObservation+DatabaseValueConvertible.swift in Sources */, - 5653EB4720961F6100F46237 /* HasManyAssociation.swift in Sources */, + 5656A8612295BD56001FF3FF /* TableRecord+Association.swift in Sources */, F3BA808C1CFB2E75003DC1BA /* DatabaseMigrator.swift in Sources */, 56E9FAD52210538400C703A8 /* SQLLiteral.swift in Sources */, - 5607149E227618800091BB10 /* FetchableRecord+QueryInterface.swift in Sources */, 5613ED6121A95E6100DC7A68 /* ValueObservation.swift in Sources */, F3BA80921CFB2E7A003DC1BA /* TableRecord.swift in Sources */, - 5607149B227618660091BB10 /* Row+QueryInterface.swift in Sources */, 567071F4208A00BE006AD95A /* SQLiteDateParser.swift in Sources */, + 5656A8992295BD56001FF3FF /* SQLSelectable+QueryInterface.swift in Sources */, F3BA80831CFB2E67003DC1BA /* DatabaseValueConvertible+RawRepresentable.swift in Sources */, 5613ED6321A95E6100DC7A68 /* ValueObservation+Combine.swift in Sources */, - 5653EC082098737400F46237 /* SQLGenerationContext.swift in Sources */, - 566475A41D9810A400FF74B8 /* SQLSelectable+QueryInterface.swift in Sources */, 5657AABB1D107001006283EF /* NSData.swift in Sources */, 5674A6E51F307F0E0095F066 /* DatabaseValueConvertible+Decodable.swift in Sources */, - 5653EB4F20961F6100F46237 /* Association.swift in Sources */, + 5656A8652295BD56001FF3FF /* BelongsToAssociation.swift in Sources */, F3BA806A1CFB2E55003DC1BA /* DatabaseQueue.swift in Sources */, F3BA80751CFB2E55003DC1BA /* Statement.swift in Sources */, - 56CEB5551EAA359A00BFAF62 /* SQLExpression.swift in Sources */, + 5656A8952295BD56001FF3FF /* SQLCollatedExpression.swift in Sources */, + 5656A8632295BD56001FF3FF /* FetchableRecord+QueryInterfaceRequest.swift in Sources */, 56B9649F1DA51B4C0002DA19 /* FTS5.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0;