From 55472c2d7f1b533eadc7c9784396f37eda7c6ade Mon Sep 17 00:00:00 2001 From: Florent Pillet Date: Sat, 19 May 2018 18:52:35 +0200 Subject: [PATCH 1/5] Main framework compiles on Linux --- GRDB/Core/Database.swift | 8 +++++++- GRDB/Core/StatementAuthorizer.swift | 3 +++ GRDB/Core/Support/CoreGraphics/CGFloat.swift | 2 ++ GRDB/Core/Support/Foundation/Date.swift | 2 ++ GRDB/Core/Support/Foundation/NSData.swift | 2 ++ GRDB/Core/Support/Foundation/NSNumber.swift | 2 ++ GRDB/Core/Support/Foundation/NSString.swift | 2 ++ GRDB/Core/Support/Foundation/URL.swift | 2 ++ GRDB/Core/Support/Foundation/UUID.swift | 6 ++++-- 9 files changed, 26 insertions(+), 3 deletions(-) diff --git a/GRDB/Core/Database.swift b/GRDB/Core/Database.swift index cdde29f8bb..71fd0f7614 100644 --- a/GRDB/Core/Database.swift +++ b/GRDB/Core/Database.swift @@ -304,7 +304,7 @@ extension Database { let db = Unmanaged.fromOpaque(dbPointer!).takeUnretainedValue() db.configuration.trace!(sql) }, dbPointer) - #else + #elseif !os(Linux) if #available(iOS 10.0, OSX 10.12, watchOS 3.0, *) { sqlite3_trace_v2(sqliteConnection, UInt32(SQLITE_TRACE_STMT), { (mask, dbPointer, stmt, unexpandedSQL) -> Int32 in guard let stmt = stmt else { return SQLITE_OK } @@ -322,6 +322,12 @@ extension Database { db.configuration.trace!(sql) }, dbPointer) } + #else + sqlite3_trace(sqliteConnection, { (dbPointer, sql) in + guard let sql = sql.map({ String(cString: $0) }) else { return } + let db = Unmanaged.fromOpaque(dbPointer!).takeUnretainedValue() + db.configuration.trace!(sql) + }, dbPointer) #endif } diff --git a/GRDB/Core/StatementAuthorizer.swift b/GRDB/Core/StatementAuthorizer.swift index 0808209087..7a2750e43a 100644 --- a/GRDB/Core/StatementAuthorizer.swift +++ b/GRDB/Core/StatementAuthorizer.swift @@ -1,3 +1,6 @@ +#if os(Linux) + import Glibc +#endif #if SWIFT_PACKAGE import CSQLite #elseif !GRDBCUSTOMSQLITE && !GRDBCIPHER diff --git a/GRDB/Core/Support/CoreGraphics/CGFloat.swift b/GRDB/Core/Support/CoreGraphics/CGFloat.swift index 7359eb3fdb..0b7fb1f3ca 100644 --- a/GRDB/Core/Support/CoreGraphics/CGFloat.swift +++ b/GRDB/Core/Support/CoreGraphics/CGFloat.swift @@ -1,3 +1,4 @@ +#if !os(Linux) import CoreGraphics /// CGFloat adopts DatabaseValueConvertible @@ -16,3 +17,4 @@ extension CGFloat : DatabaseValueConvertible { return CGFloat(double) } } +#endif diff --git a/GRDB/Core/Support/Foundation/Date.swift b/GRDB/Core/Support/Foundation/Date.swift index 78cdbbd30f..c5e1e1d6b1 100644 --- a/GRDB/Core/Support/Foundation/Date.swift +++ b/GRDB/Core/Support/Foundation/Date.swift @@ -5,6 +5,7 @@ import Foundation import SQLite3 #endif +#if !os(Linux) /// NSDate is stored in the database using the format /// "yyyy-MM-dd HH:mm:ss.SSS", in the UTC time zone. extension NSDate : DatabaseValueConvertible { @@ -31,6 +32,7 @@ extension NSDate : DatabaseValueConvertible { return cast(date) } } +#endif /// Date is stored in the database using the format /// "yyyy-MM-dd HH:mm:ss.SSS", in the UTC time zone. diff --git a/GRDB/Core/Support/Foundation/NSData.swift b/GRDB/Core/Support/Foundation/NSData.swift index 28a7ae8ba8..8bd9d2ecf9 100644 --- a/GRDB/Core/Support/Foundation/NSData.swift +++ b/GRDB/Core/Support/Foundation/NSData.swift @@ -1,3 +1,4 @@ +#if !os(Linux) import Foundation /// NSData is convertible to and from DatabaseValue. @@ -17,3 +18,4 @@ extension NSData : DatabaseValueConvertible { return cast(data) } } +#endif diff --git a/GRDB/Core/Support/Foundation/NSNumber.swift b/GRDB/Core/Support/Foundation/NSNumber.swift index 2a00c16181..2caf60868f 100644 --- a/GRDB/Core/Support/Foundation/NSNumber.swift +++ b/GRDB/Core/Support/Foundation/NSNumber.swift @@ -1,3 +1,4 @@ +#if !os(Linux) import Foundation private let integerRoundingBehavior = NSDecimalNumberHandler(roundingMode: .plain, scale: 0, raiseOnExactness: false, raiseOnOverflow: false, raiseOnUnderflow: false, raiseOnDivideByZero: false) @@ -65,3 +66,4 @@ extension NSNumber : DatabaseValueConvertible { } } } +#endif diff --git a/GRDB/Core/Support/Foundation/NSString.swift b/GRDB/Core/Support/Foundation/NSString.swift index 577725992e..d5455bed45 100644 --- a/GRDB/Core/Support/Foundation/NSString.swift +++ b/GRDB/Core/Support/Foundation/NSString.swift @@ -1,3 +1,4 @@ +#if !os(Linux) import Foundation /// NSString adopts DatabaseValueConvertible @@ -16,3 +17,4 @@ extension NSString : DatabaseValueConvertible { return self.init(string: string) } } +#endif diff --git a/GRDB/Core/Support/Foundation/URL.swift b/GRDB/Core/Support/Foundation/URL.swift index 516dcc1fba..4cc95b1b4e 100644 --- a/GRDB/Core/Support/Foundation/URL.swift +++ b/GRDB/Core/Support/Foundation/URL.swift @@ -1,5 +1,6 @@ import Foundation +#if !os(Linux) /// NSURL stores its absoluteString in the database. extension NSURL : DatabaseValueConvertible { @@ -17,6 +18,7 @@ extension NSURL : DatabaseValueConvertible { return cast(URL(string: string)) } } +#endif /// URL stores its absoluteString in the database. extension URL : DatabaseValueConvertible { } diff --git a/GRDB/Core/Support/Foundation/UUID.swift b/GRDB/Core/Support/Foundation/UUID.swift index 5d6d7cfeeb..78a9062dd1 100644 --- a/GRDB/Core/Support/Foundation/UUID.swift +++ b/GRDB/Core/Support/Foundation/UUID.swift @@ -1,5 +1,6 @@ import Foundation +#if !os(Linux) /// NSUUID adopts DatabaseValueConvertible extension NSUUID : DatabaseValueConvertible { @@ -8,18 +9,19 @@ extension NSUUID : DatabaseValueConvertible { var uuidBytes = ContiguousArray(repeating: UInt8(0), count: 16) return uuidBytes.withUnsafeMutableBufferPointer { buffer in getBytes(buffer.baseAddress!) - return NSData(bytes: buffer.baseAddress, length: 16).databaseValue + return Data(bytes: buffer.baseAddress, length: 16).databaseValue } } /// Returns an NSUUID initialized from *dbValue*, if possible. public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self? { - guard let data = NSData.fromDatabaseValue(dbValue), data.length == 16 else { + guard let data = Data.fromDatabaseValue(dbValue), data.length == 16 else { return nil } return self.init(uuidBytes: data.bytes.assumingMemoryBound(to: UInt8.self)) } } +#endif /// UUID adopts DatabaseValueConvertible extension UUID : DatabaseValueConvertible { } From df8887be050cfcc7492ae753b22c957548dfb386 Mon Sep 17 00:00:00 2001 From: Florent Pillet Date: Sun, 20 May 2018 00:27:02 +0200 Subject: [PATCH 2/5] Fix NSUUID compilation issue (now using more Swift code) --- GRDB/Core/Support/Foundation/UUID.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/GRDB/Core/Support/Foundation/UUID.swift b/GRDB/Core/Support/Foundation/UUID.swift index 78a9062dd1..15dd51e6f1 100644 --- a/GRDB/Core/Support/Foundation/UUID.swift +++ b/GRDB/Core/Support/Foundation/UUID.swift @@ -9,16 +9,18 @@ extension NSUUID : DatabaseValueConvertible { var uuidBytes = ContiguousArray(repeating: UInt8(0), count: 16) return uuidBytes.withUnsafeMutableBufferPointer { buffer in getBytes(buffer.baseAddress!) - return Data(bytes: buffer.baseAddress, length: 16).databaseValue + return Data(buffer: buffer).databaseValue } } /// Returns an NSUUID initialized from *dbValue*, if possible. public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self? { - guard let data = Data.fromDatabaseValue(dbValue), data.length == 16 else { + guard let data = Data.fromDatabaseValue(dbValue), data.count == 16 else { return nil } - return self.init(uuidBytes: data.bytes.assumingMemoryBound(to: UInt8.self)) + return data.withUnsafeBytes { buffer in + self.init(uuidBytes: buffer) + } } } #endif From 34db8efea0546983b51d941e78131c903449a840 Mon Sep 17 00:00:00 2001 From: Florent Pillet Date: Sun, 20 May 2018 00:44:59 +0200 Subject: [PATCH 3/5] Added missing LinuxMain.swift --- Tests/LinuxMain.swift | 160 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 Tests/LinuxMain.swift diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift new file mode 100644 index 0000000000..833229ec69 --- /dev/null +++ b/Tests/LinuxMain.swift @@ -0,0 +1,160 @@ +import Foundation +@testable import GRDBTests + +XCTMain([ + testCase(AnyCursorTests.allTests), + testCase(AssociationBelongsToDecodableRecordTests.allTests), + testCase(AssociationBelongsToFetchableRecordTests.allTests), + testCase(AssociationBelongsToRowScopeTests.allTests), + testCase(AssociationBelongsToSQLDerivationTests.allTests), + testCase(AssociationBelongsToSQLTests.allTests), + testCase(AssociationChainRowScopesTests.allTests), + testCase(AssociationChainSQLTests.allTests), + testCase(AssociationHasOneSQLDerivationTests.allTests), + testCase(AssociationHasOneSQLTests.allTests), + testCase(AssociationParallelDecodableRecordTests.allTests), + testCase(AssociationParallelRowScopesTests.allTests), + testCase(AssociationParallelSQLTests.allTests), + testCase(AssociationRowScopeSearchTests.allTests), + testCase(AssociationTableAliasTestsSQLTests.allTests), + testCase(CGFloatTests.allTests), + testCase(ColumnExpressionTests.allTests), + testCase(ColumnInfoTests.allTests), + testCase(CompilationProtocolTests.allTests), + testCase(CompilationSubClassTests.allTests), + testCase(CursorTests.allTests), + testCase(DataMemoryTests.allTests), + testCase(DatabaseAfterNextTransactionCommitTests.allTests), + testCase(DatabaseAggregateTests.allTests), + testCase(DatabaseCollationTests.allTests), + testCase(DatabaseCursorTests.allTests), + testCase(DatabaseErrorTests.allTests), + testCase(DatabaseFunctionTests.allTests), + testCase(DatabaseLogErrorTests.allTests), + testCase(DatabaseMigratorTests.allTests), + testCase(DatabasePoolBackupTests.allTests), + testCase(DatabasePoolCollationTests.allTests), + testCase(DatabasePoolConcurrencyTests.allTests), + testCase(DatabasePoolFunctionTests.allTests), + testCase(DatabasePoolReadOnlyTests.allTests), + testCase(DatabasePoolReleaseMemoryTests.allTests), + testCase(DatabasePoolSchemaCacheTests.allTests), + testCase(DatabaseQueueBackupTests.allTests), + testCase(DatabaseQueueConcurrencyTests.allTests), + testCase(DatabaseQueueInMemoryTests.allTests), + testCase(DatabaseQueueReadOnlyTests.allTests), + testCase(DatabaseQueueReleaseMemoryTests.allTests), + testCase(DatabaseQueueSchemaCacheTests.allTests), + testCase(DatabaseQueueTests.allTests), + testCase(DatabaseReaderTests.allTests), + testCase(DatabaseRegionTests.allTests), + testCase(DatabaseSavepointTests.allTests), + testCase(DatabaseSnapshotTests.allTests), + testCase(DatabaseTests.allTests), + testCase(DatabaseTimestampTests.allTests), + testCase(DatabaseValueConversionTests.allTests), + testCase(DatabaseValueConvertibleDecodableTests.allTests), + testCase(DatabaseValueConvertibleEncodableTests.allTests), + testCase(DatabaseValueConvertibleEscapingTests.allTests), + testCase(DatabaseValueConvertibleFetchTests.allTests), + testCase(DatabaseValueConvertibleSubclassTests.allTests), + testCase(DatabaseValueTests.allTests), + testCase(DatabaseWriterTests.allTests), + testCase(DerivableRequestTests.allTests), + testCase(DropFirstCursorTests.allTests), + testCase(DropWhileCursorTests.allTests), + testCase(EncryptionTests.allTests), + testCase(EnumeratedCursorTests.allTests), + testCase(FTS3PatternTests.allTests), + testCase(FTS3RecordTests.allTests), + testCase(FTS3TableBuilderTests.allTests), + testCase(FTS3TokenizerTests.allTests), + testCase(FTS4RecordTests.allTests), + testCase(FTS4TableBuilderTests.allTests), + testCase(FTS5CustomTokenizerTests.allTests), + testCase(FTS5PatternTests.allTests), + testCase(FTS5RecordTests.allTests), + testCase(FTS5TableBuilderTests.allTests), + testCase(FTS5TokenizerTests.allTests), + testCase(FTS5WrapperTokenizerTests.allTests), + testCase(FetchRequestTests.allTests), + testCase(FetchableRecord+QueryInterfaceRequestTests.allTests), + testCase(FetchableRecordDecodableTests.allTests), + testCase(FetchableRecordTests.allTests), + testCase(FetchedRecordsControllerTests.allTests), + testCase(FilterCursorTests.allTests), + testCase(FlattenCursorTests.allTests), + testCase(ForeignKeyInfoTests.allTests), + testCase(FoundationDataTests.allTests), + testCase(FoundationDateComponentsTests.allTests), + testCase(FoundationDateTests.allTests), + testCase(FoundationNSDataTests.allTests), + testCase(FoundationNSDateTests.allTests), + testCase(FoundationNSDecimalNumberTests.allTests), + testCase(FoundationNSNullTests.allTests), + testCase(FoundationNSNumberTests.allTests), + testCase(FoundationNSStringTests.allTests), + testCase(FoundationNSURLTests.allTests), + testCase(FoundationNSUUIDTests.allTests), + testCase(FoundationURLTests.allTests), + testCase(FoundationUUIDTests.allTests), + testCase(GRDBTestCase.allTests), + testCase(IndexInfoTests.allTests), + testCase(JoinSupportTests.allTests), + testCase(MapCursorTests.allTests), + testCase(MutablePersistableRecordChangesTests.allTests), + testCase(MutablePersistableRecordDeleteTests.allTests), + testCase(MutablePersistableRecordEncodableTests.allTests), + testCase(MutablePersistableRecordPersistenceConflictPolicyTests.allTests), + testCase(MutablePersistableRecordTests.allTests), + testCase(NumericOverflowTests.allTests), + testCase(PersistableRecordTests.allTests), + testCase(PrefixCursorTests.allTests), + testCase(PrefixWhileCursorTests.allTests), + testCase(PrimaryKeyInfoTests.allTests), + testCase(QueryInterfaceExpressionsTests.allTests), + testCase(QueryInterfaceExtensibilityTests.allTests), + testCase(QueryInterfaceRequestTests.allTests), + testCase(RawRepresentable+DatabaseValueConvertibleTests.allTests), + testCase(Record+QueryInterfaceRequestTests.allTests), + testCase(RecordCopyTests.allTests), + testCase(RecordEditedTests.allTests), + testCase(RecordInitializersTests.allTests), + testCase(RecordMinimalPrimaryKeyRowIDTests.allTests), + testCase(RecordMinimalPrimaryKeySingleTests.allTests), + testCase(RecordPersistenceConflictPolicy.allTests), + testCase(RecordPrimaryKeyHiddenRowIDTests.allTests), + testCase(RecordPrimaryKeyMultipleTests.allTests), + testCase(RecordPrimaryKeyNoneTests.allTests), + testCase(RecordPrimaryKeyRowIDTests.allTests), + testCase(RecordPrimaryKeySingleTests.allTests), + testCase(RecordPrimaryKeySingleWithReplaceConflictResolutionTests.allTests), + testCase(RecordSubClassTests.allTests), + testCase(RecordUniqueIndexTests.allTests), + testCase(RecordWithColumnNameManglingTests.allTests), + testCase(ResultCodeTests.allTests), + testCase(Row+FoundationTests.allTests), + testCase(RowAdapterTests.allTests), + testCase(RowCopiedFromStatementTests.allTests), + testCase(RowFetchTests.allTests), + testCase(RowFromDictionaryLiteralTests.allTests), + testCase(RowFromDictionaryTests.allTests), + testCase(RowFromStatementTests.allTests), + testCase(RowTestCase.allTests), + testCase(SQLExpressionLiteralTests.allTests), + testCase(SQLRequestTests.allTests), + testCase(SchedulingWatchdogTests.allTests), + testCase(SelectStatementTests.allTests), + testCase(StatementArguments+FoundationTests.allTests), + testCase(StatementArgumentsTests.allTests), + testCase(StatementColumnConvertibleFetchTests.allTests), + testCase(StatementColumnConvertibleTests.allTests), + testCase(TableDefinitionTests.allTests), + testCase(TableRecord+QueryInterfaceRequestTests.allTests), + testCase(TableRecordTests.allTests), + testCase(TransactionObserverSavepointsTests.allTests), + testCase(TransactionObserverTests.allTests), + testCase(TruncateOptimizationTests.allTests), + testCase(UpdateStatementTests.allTests), + testCase(VirtualTableModuleTests.allTests) +]) From da65deec695bec9a0ae00df15bfc5fa879671006 Mon Sep 17 00:00:00 2001 From: Florent Pillet Date: Sun, 20 May 2018 14:21:41 +0200 Subject: [PATCH 4/5] Removed LinuxMain.swift --- Tests/LinuxMain.swift | 160 ------------------------------------------ 1 file changed, 160 deletions(-) delete mode 100644 Tests/LinuxMain.swift diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift deleted file mode 100644 index 833229ec69..0000000000 --- a/Tests/LinuxMain.swift +++ /dev/null @@ -1,160 +0,0 @@ -import Foundation -@testable import GRDBTests - -XCTMain([ - testCase(AnyCursorTests.allTests), - testCase(AssociationBelongsToDecodableRecordTests.allTests), - testCase(AssociationBelongsToFetchableRecordTests.allTests), - testCase(AssociationBelongsToRowScopeTests.allTests), - testCase(AssociationBelongsToSQLDerivationTests.allTests), - testCase(AssociationBelongsToSQLTests.allTests), - testCase(AssociationChainRowScopesTests.allTests), - testCase(AssociationChainSQLTests.allTests), - testCase(AssociationHasOneSQLDerivationTests.allTests), - testCase(AssociationHasOneSQLTests.allTests), - testCase(AssociationParallelDecodableRecordTests.allTests), - testCase(AssociationParallelRowScopesTests.allTests), - testCase(AssociationParallelSQLTests.allTests), - testCase(AssociationRowScopeSearchTests.allTests), - testCase(AssociationTableAliasTestsSQLTests.allTests), - testCase(CGFloatTests.allTests), - testCase(ColumnExpressionTests.allTests), - testCase(ColumnInfoTests.allTests), - testCase(CompilationProtocolTests.allTests), - testCase(CompilationSubClassTests.allTests), - testCase(CursorTests.allTests), - testCase(DataMemoryTests.allTests), - testCase(DatabaseAfterNextTransactionCommitTests.allTests), - testCase(DatabaseAggregateTests.allTests), - testCase(DatabaseCollationTests.allTests), - testCase(DatabaseCursorTests.allTests), - testCase(DatabaseErrorTests.allTests), - testCase(DatabaseFunctionTests.allTests), - testCase(DatabaseLogErrorTests.allTests), - testCase(DatabaseMigratorTests.allTests), - testCase(DatabasePoolBackupTests.allTests), - testCase(DatabasePoolCollationTests.allTests), - testCase(DatabasePoolConcurrencyTests.allTests), - testCase(DatabasePoolFunctionTests.allTests), - testCase(DatabasePoolReadOnlyTests.allTests), - testCase(DatabasePoolReleaseMemoryTests.allTests), - testCase(DatabasePoolSchemaCacheTests.allTests), - testCase(DatabaseQueueBackupTests.allTests), - testCase(DatabaseQueueConcurrencyTests.allTests), - testCase(DatabaseQueueInMemoryTests.allTests), - testCase(DatabaseQueueReadOnlyTests.allTests), - testCase(DatabaseQueueReleaseMemoryTests.allTests), - testCase(DatabaseQueueSchemaCacheTests.allTests), - testCase(DatabaseQueueTests.allTests), - testCase(DatabaseReaderTests.allTests), - testCase(DatabaseRegionTests.allTests), - testCase(DatabaseSavepointTests.allTests), - testCase(DatabaseSnapshotTests.allTests), - testCase(DatabaseTests.allTests), - testCase(DatabaseTimestampTests.allTests), - testCase(DatabaseValueConversionTests.allTests), - testCase(DatabaseValueConvertibleDecodableTests.allTests), - testCase(DatabaseValueConvertibleEncodableTests.allTests), - testCase(DatabaseValueConvertibleEscapingTests.allTests), - testCase(DatabaseValueConvertibleFetchTests.allTests), - testCase(DatabaseValueConvertibleSubclassTests.allTests), - testCase(DatabaseValueTests.allTests), - testCase(DatabaseWriterTests.allTests), - testCase(DerivableRequestTests.allTests), - testCase(DropFirstCursorTests.allTests), - testCase(DropWhileCursorTests.allTests), - testCase(EncryptionTests.allTests), - testCase(EnumeratedCursorTests.allTests), - testCase(FTS3PatternTests.allTests), - testCase(FTS3RecordTests.allTests), - testCase(FTS3TableBuilderTests.allTests), - testCase(FTS3TokenizerTests.allTests), - testCase(FTS4RecordTests.allTests), - testCase(FTS4TableBuilderTests.allTests), - testCase(FTS5CustomTokenizerTests.allTests), - testCase(FTS5PatternTests.allTests), - testCase(FTS5RecordTests.allTests), - testCase(FTS5TableBuilderTests.allTests), - testCase(FTS5TokenizerTests.allTests), - testCase(FTS5WrapperTokenizerTests.allTests), - testCase(FetchRequestTests.allTests), - testCase(FetchableRecord+QueryInterfaceRequestTests.allTests), - testCase(FetchableRecordDecodableTests.allTests), - testCase(FetchableRecordTests.allTests), - testCase(FetchedRecordsControllerTests.allTests), - testCase(FilterCursorTests.allTests), - testCase(FlattenCursorTests.allTests), - testCase(ForeignKeyInfoTests.allTests), - testCase(FoundationDataTests.allTests), - testCase(FoundationDateComponentsTests.allTests), - testCase(FoundationDateTests.allTests), - testCase(FoundationNSDataTests.allTests), - testCase(FoundationNSDateTests.allTests), - testCase(FoundationNSDecimalNumberTests.allTests), - testCase(FoundationNSNullTests.allTests), - testCase(FoundationNSNumberTests.allTests), - testCase(FoundationNSStringTests.allTests), - testCase(FoundationNSURLTests.allTests), - testCase(FoundationNSUUIDTests.allTests), - testCase(FoundationURLTests.allTests), - testCase(FoundationUUIDTests.allTests), - testCase(GRDBTestCase.allTests), - testCase(IndexInfoTests.allTests), - testCase(JoinSupportTests.allTests), - testCase(MapCursorTests.allTests), - testCase(MutablePersistableRecordChangesTests.allTests), - testCase(MutablePersistableRecordDeleteTests.allTests), - testCase(MutablePersistableRecordEncodableTests.allTests), - testCase(MutablePersistableRecordPersistenceConflictPolicyTests.allTests), - testCase(MutablePersistableRecordTests.allTests), - testCase(NumericOverflowTests.allTests), - testCase(PersistableRecordTests.allTests), - testCase(PrefixCursorTests.allTests), - testCase(PrefixWhileCursorTests.allTests), - testCase(PrimaryKeyInfoTests.allTests), - testCase(QueryInterfaceExpressionsTests.allTests), - testCase(QueryInterfaceExtensibilityTests.allTests), - testCase(QueryInterfaceRequestTests.allTests), - testCase(RawRepresentable+DatabaseValueConvertibleTests.allTests), - testCase(Record+QueryInterfaceRequestTests.allTests), - testCase(RecordCopyTests.allTests), - testCase(RecordEditedTests.allTests), - testCase(RecordInitializersTests.allTests), - testCase(RecordMinimalPrimaryKeyRowIDTests.allTests), - testCase(RecordMinimalPrimaryKeySingleTests.allTests), - testCase(RecordPersistenceConflictPolicy.allTests), - testCase(RecordPrimaryKeyHiddenRowIDTests.allTests), - testCase(RecordPrimaryKeyMultipleTests.allTests), - testCase(RecordPrimaryKeyNoneTests.allTests), - testCase(RecordPrimaryKeyRowIDTests.allTests), - testCase(RecordPrimaryKeySingleTests.allTests), - testCase(RecordPrimaryKeySingleWithReplaceConflictResolutionTests.allTests), - testCase(RecordSubClassTests.allTests), - testCase(RecordUniqueIndexTests.allTests), - testCase(RecordWithColumnNameManglingTests.allTests), - testCase(ResultCodeTests.allTests), - testCase(Row+FoundationTests.allTests), - testCase(RowAdapterTests.allTests), - testCase(RowCopiedFromStatementTests.allTests), - testCase(RowFetchTests.allTests), - testCase(RowFromDictionaryLiteralTests.allTests), - testCase(RowFromDictionaryTests.allTests), - testCase(RowFromStatementTests.allTests), - testCase(RowTestCase.allTests), - testCase(SQLExpressionLiteralTests.allTests), - testCase(SQLRequestTests.allTests), - testCase(SchedulingWatchdogTests.allTests), - testCase(SelectStatementTests.allTests), - testCase(StatementArguments+FoundationTests.allTests), - testCase(StatementArgumentsTests.allTests), - testCase(StatementColumnConvertibleFetchTests.allTests), - testCase(StatementColumnConvertibleTests.allTests), - testCase(TableDefinitionTests.allTests), - testCase(TableRecord+QueryInterfaceRequestTests.allTests), - testCase(TableRecordTests.allTests), - testCase(TransactionObserverSavepointsTests.allTests), - testCase(TransactionObserverTests.allTests), - testCase(TruncateOptimizationTests.allTests), - testCase(UpdateStatementTests.allTests), - testCase(VirtualTableModuleTests.allTests) -]) From c0bd8ce9177aa4aa4d7d13eb2e51ad5bed131f95 Mon Sep 17 00:00:00 2001 From: Florent Pillet Date: Sun, 20 May 2018 14:37:59 +0200 Subject: [PATCH 5/5] Rolled back to previous NSUUID extension as compiler freaks out on a more modern implementation --- GRDB/Core/Support/Foundation/UUID.swift | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/GRDB/Core/Support/Foundation/UUID.swift b/GRDB/Core/Support/Foundation/UUID.swift index 15dd51e6f1..7deb4e2cfe 100644 --- a/GRDB/Core/Support/Foundation/UUID.swift +++ b/GRDB/Core/Support/Foundation/UUID.swift @@ -9,19 +9,17 @@ extension NSUUID : DatabaseValueConvertible { var uuidBytes = ContiguousArray(repeating: UInt8(0), count: 16) return uuidBytes.withUnsafeMutableBufferPointer { buffer in getBytes(buffer.baseAddress!) - return Data(buffer: buffer).databaseValue + return NSData(bytes: buffer.baseAddress, length: 16).databaseValue } } /// Returns an NSUUID initialized from *dbValue*, if possible. public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self? { - guard let data = Data.fromDatabaseValue(dbValue), data.count == 16 else { + guard let data = NSData.fromDatabaseValue(dbValue), data.length == 16 else { return nil } - return data.withUnsafeBytes { buffer in - self.init(uuidBytes: buffer) - } - } + return self.init(uuidBytes: data.bytes.assumingMemoryBound(to: UInt8.self)) + } } #endif