mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-29 04:24:21 +00:00
Swift 4.1 compatibility (SE-0184 , SE-0187)
This commit is contained in:
1 parent
ad0f6de809
commit
85d3c584ef
12 files changed
+54
-14
No files matched your search
@@ -423,6 +423,9 @@
|
||||
56B021CD1D8C0D3900B239BB /* MutablePersistablePersistenceConflictPolicyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B021C81D8C0D3900B239BB /* MutablePersistablePersistenceConflictPolicyTests.swift */; };
|
||||
56B14E831D4DAE54000BF4A3 /* RowFromDictionaryLiteralTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B14E7E1D4DAE54000BF4A3 /* RowFromDictionaryLiteralTests.swift */; };
|
||||
56B15D0B1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B15D0A1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift */; };
|
||||
56B1C3CD201C8D0E001938DA /* Swift4.1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B1C3CC201C8D0E001938DA /* Swift4.1.swift */; };
|
||||
56B1C3CE201C8D0E001938DA /* Swift4.1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B1C3CC201C8D0E001938DA /* Swift4.1.swift */; };
|
||||
56B1C3CF201C8D0E001938DA /* Swift4.1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B1C3CC201C8D0E001938DA /* Swift4.1.swift */; };
|
||||
56B7F42A1BE14A1900E39BBF /* CGFloatTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4291BE14A1900E39BBF /* CGFloatTests.swift */; };
|
||||
56B7F43A1BEB42D500E39BBF /* Migration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4391BEB42D500E39BBF /* Migration.swift */; };
|
||||
56B7F43B1BEB42D500E39BBF /* Migration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56B7F4391BEB42D500E39BBF /* Migration.swift */; };
|
||||
@@ -940,6 +943,7 @@
|
||||
56B021C81D8C0D3900B239BB /* MutablePersistablePersistenceConflictPolicyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MutablePersistablePersistenceConflictPolicyTests.swift; sourceTree = "<group>"; };
|
||||
56B14E7E1D4DAE54000BF4A3 /* RowFromDictionaryLiteralTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowFromDictionaryLiteralTests.swift; sourceTree = "<group>"; };
|
||||
56B15D0A1CD4C35100A24C8B /* FetchedRecordsControllerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FetchedRecordsControllerTests.swift; sourceTree = "<group>"; };
|
||||
56B1C3CC201C8D0E001938DA /* Swift4.1.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Swift4.1.swift; sourceTree = "<group>"; };
|
||||
56B7F4291BE14A1900E39BBF /* CGFloatTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGFloatTests.swift; sourceTree = "<group>"; };
|
||||
56B7F4391BEB42D500E39BBF /* Migration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Migration.swift; sourceTree = "<group>"; };
|
||||
56B8C2401CA1758F00510325 /* Realm.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Realm.framework; path = "Realm/build/osx/swift-4.0.3/Realm.framework"; sourceTree = "<group>"; };
|
||||
@@ -1612,6 +1616,7 @@
|
||||
56E06F051E859064008AE2A4 /* Fixits-0.102.0.swift */,
|
||||
56D121591ED34978001347D2 /* Fixits-0.109.0.swift */,
|
||||
56873BEB1F2CB400004D24B4 /* Fixits-1.2.swift */,
|
||||
56B1C3CC201C8D0E001938DA /* Swift4.1.swift */,
|
||||
);
|
||||
path = Legacy;
|
||||
sourceTree = "<group>";
|
||||
@@ -2252,6 +2257,7 @@
|
||||
565490D61D5AE252005622CB /* StandardLibrary.swift in Sources */,
|
||||
565490B81D5AE236005622CB /* DatabaseError.swift in Sources */,
|
||||
56BF6D3C1DEF47DA006039A3 /* Fixits-0-90-1.swift in Sources */,
|
||||
56B1C3CF201C8D0E001938DA /* Swift4.1.swift in Sources */,
|
||||
56DAA2E11DE9C827006E10C8 /* Cursor.swift in Sources */,
|
||||
565490BC1D5AE236005622CB /* DatabaseSchemaCache.swift in Sources */,
|
||||
565490BA1D5AE236005622CB /* DatabaseQueue.swift in Sources */,
|
||||
@@ -2330,6 +2336,7 @@
|
||||
5674A7081F307FCD0095F066 /* DatabaseValueConvertible+ReferenceConvertible.swift in Sources */,
|
||||
56A2388C1B9C75030082EB20 /* Statement.swift in Sources */,
|
||||
5659F4931EA8D964004A4992 /* ReadWriteBox.swift in Sources */,
|
||||
56B1C3CE201C8D0E001938DA /* Swift4.1.swift in Sources */,
|
||||
5605F1941C6B1A8700235C62 /* QueryInterfaceSelectQueryDefinition.swift in Sources */,
|
||||
56B7F43B1BEB42D500E39BBF /* Migration.swift in Sources */,
|
||||
5690C3431D23E82A00E59934 /* Data.swift in Sources */,
|
||||
@@ -2735,6 +2742,7 @@
|
||||
5605F1931C6B1A8700235C62 /* QueryInterfaceSelectQueryDefinition.swift in Sources */,
|
||||
566B912B1FA4D0CC0012D5B0 /* StatementAuthorizer.swift in Sources */,
|
||||
56A2388B1B9C75030082EB20 /* Statement.swift in Sources */,
|
||||
56B1C3CD201C8D0E001938DA /* Swift4.1.swift in Sources */,
|
||||
5690C3401D23E82A00E59934 /* Data.swift in Sources */,
|
||||
5659F4881EA8D94E004A4992 /* Utils.swift in Sources */,
|
||||
56FC98781D969DEF00E3C842 /* SQLExpression+QueryInterface.swift in Sources */,
|
||||
@@ -2840,7 +2848,6 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
};
|
||||
name = Release;
|
||||
@@ -2886,7 +2893,6 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Tests/Performance/GRDBPerformanceComparisonTests-Bridging.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
};
|
||||
@@ -2974,7 +2980,6 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
};
|
||||
name = Release;
|
||||
@@ -3025,7 +3030,6 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
@@ -3063,7 +3067,6 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBiOSTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
};
|
||||
name = Release;
|
||||
@@ -3100,7 +3103,6 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
};
|
||||
name = Release;
|
||||
@@ -3200,7 +3202,6 @@
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 4.0;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
@@ -3247,7 +3248,6 @@
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
};
|
||||
name = Release;
|
||||
|
||||
@@ -274,7 +274,7 @@ public final class DatabaseFunction {
|
||||
let aggregateContextU = Unmanaged.passRetained(aggregateContext)
|
||||
var aggregateContextP = aggregateContextU.toOpaque()
|
||||
withUnsafeBytes(of: &aggregateContextP) {
|
||||
aggregateContextBufferP.copyBytes(from: $0)
|
||||
aggregateContextBufferP.copyMemory(from: $0)
|
||||
}
|
||||
return aggregateContextU
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public struct DatabaseDateComponents : DatabaseValueConvertible {
|
||||
timeString = nil
|
||||
}
|
||||
|
||||
return [dateString, timeString].flatMap { $0 }.joined(separator: " ").databaseValue
|
||||
return [dateString, timeString].compactMap { $0 }.joined(separator: " ").databaseValue
|
||||
}
|
||||
|
||||
/// Returns a DatabaseDateComponents if *dbValue* contains a
|
||||
|
||||
@@ -238,7 +238,7 @@ class DatabaseObservationBroker {
|
||||
// For example, if one observes all deletions in the table T, then
|
||||
// all individual deletions of DELETE FROM T are notified:
|
||||
let eventKind = eventKinds[0]
|
||||
statementObservations = transactionObservations.flatMap { observation in
|
||||
statementObservations = transactionObservations.compactMap { observation in
|
||||
guard observation.observes(eventsOfKind: eventKind) else {
|
||||
// observation is not interested
|
||||
return nil
|
||||
@@ -260,7 +260,7 @@ class DatabaseObservationBroker {
|
||||
// For example, if DELETE FROM T1 generates deletions in T1 and T2
|
||||
// by the mean of a foreign key action, then when one only observes
|
||||
// deletions in T1, one must not be notified of deletions in T2:
|
||||
statementObservations = transactionObservations.flatMap { observation in
|
||||
statementObservations = transactionObservations.compactMap { observation in
|
||||
let observedKinds = eventKinds.filter(observation.observes)
|
||||
if observedKinds.isEmpty {
|
||||
// observation is not interested
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Compatibility layer for Swift < 4.1
|
||||
|
||||
#if swift(>=4.1)
|
||||
#else
|
||||
extension Sequence {
|
||||
func compactMap<ElementOfResult>(_ transform: (Self.Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult] {
|
||||
return try flatMap(transform)
|
||||
}
|
||||
}
|
||||
|
||||
extension UnsafeMutableRawBufferPointer {
|
||||
func copyMemory<C>(from source: C) where C : Collection, C.Element == UInt8 {
|
||||
copyBytes(from: source)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -463,7 +463,7 @@ public final class TableDefinition {
|
||||
}
|
||||
|
||||
let indexStatements = columns
|
||||
.flatMap { $0.indexDefinition(in: name) }
|
||||
.compactMap { $0.indexDefinition(in: name) }
|
||||
.map { $0.sql() }
|
||||
statements.append(contentsOf: indexStatements)
|
||||
return statements.joined(separator: "; ")
|
||||
|
||||
@@ -14,7 +14,7 @@ private struct RowKeyedDecodingContainer<Key: CodingKey>: KeyedDecodingContainer
|
||||
let row = decoder.row
|
||||
let columnNames = Set(row.columnNames)
|
||||
let scopeNames = row.scopeNames
|
||||
return columnNames.union(scopeNames).flatMap { Key(stringValue: $0) }
|
||||
return columnNames.union(scopeNames).compactMap { Key(stringValue: $0) }
|
||||
}
|
||||
|
||||
/// Returns whether the `Decoder` contains a value associated with the given key.
|
||||
|
||||
@@ -482,6 +482,8 @@
|
||||
5698AD251DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AD201DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift */; };
|
||||
5698AD361DABAF4A0056AF8C /* FTS5CustomTokenizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AD341DABAF4A0056AF8C /* FTS5CustomTokenizer.swift */; };
|
||||
5698AD391DABAF4A0056AF8C /* FTS5CustomTokenizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AD341DABAF4A0056AF8C /* FTS5CustomTokenizer.swift */; };
|
||||
569B7FA8201C904C0069DE70 /* Swift4.1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569B7FA6201C904C0069DE70 /* Swift4.1.swift */; };
|
||||
569B7FA9201C904C0069DE70 /* Swift4.1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569B7FA6201C904C0069DE70 /* Swift4.1.swift */; };
|
||||
569C1EB31CF07DDD0042627B /* SchedulingWatchdogTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569C1EB11CF07DDD0042627B /* SchedulingWatchdogTests.swift */; };
|
||||
569C1EB41CF07DDD0042627B /* SchedulingWatchdogTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569C1EB11CF07DDD0042627B /* SchedulingWatchdogTests.swift */; };
|
||||
569C1EB61CF07DDD0042627B /* SchedulingWatchdogTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569C1EB11CF07DDD0042627B /* SchedulingWatchdogTests.swift */; };
|
||||
@@ -974,6 +976,7 @@
|
||||
5698AD151DAAD16F0056AF8C /* FTS5Tokenizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5Tokenizer.swift; sourceTree = "<group>"; };
|
||||
5698AD201DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5WrapperTokenizer.swift; sourceTree = "<group>"; };
|
||||
5698AD341DABAF4A0056AF8C /* FTS5CustomTokenizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5CustomTokenizer.swift; sourceTree = "<group>"; };
|
||||
569B7FA6201C904C0069DE70 /* Swift4.1.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Swift4.1.swift; sourceTree = "<group>"; };
|
||||
569C1EB11CF07DDD0042627B /* SchedulingWatchdogTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SchedulingWatchdogTests.swift; sourceTree = "<group>"; };
|
||||
569EF0E8200D387000A9FA45 /* DatabaseRegion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseRegion.swift; sourceTree = "<group>"; };
|
||||
56A238131B9C74A90082EB20 /* DatabaseTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseTests.swift; sourceTree = "<group>"; };
|
||||
@@ -1607,6 +1610,7 @@
|
||||
56E06F051E859064008AE2A4 /* Fixits-0.102.0.swift */,
|
||||
56D121591ED34978001347D2 /* Fixits-0.109.0.swift */,
|
||||
56873BEB1F2CB400004D24B4 /* Fixits-1.2.swift */,
|
||||
569B7FA6201C904C0069DE70 /* Swift4.1.swift */,
|
||||
);
|
||||
path = Legacy;
|
||||
sourceTree = "<group>";
|
||||
@@ -2013,6 +2017,7 @@
|
||||
5698AC381D9E5A590056AF8C /* FTS3Pattern.swift in Sources */,
|
||||
564F9C2F1F07611400877A00 /* DatabaseFunction.swift in Sources */,
|
||||
5659F4991EA8D989004A4992 /* Pool.swift in Sources */,
|
||||
569B7FA8201C904C0069DE70 /* Swift4.1.swift in Sources */,
|
||||
5674A6FA1F307F600095F066 /* Persistable+Encodable.swift in Sources */,
|
||||
56CEB54D1EAA359A00BFAF62 /* SQLExpressible.swift in Sources */,
|
||||
5664759B1D97D8A000FF74B8 /* SQLCollection.swift in Sources */,
|
||||
@@ -2407,6 +2412,7 @@
|
||||
5698AC3B1D9E5A590056AF8C /* FTS3Pattern.swift in Sources */,
|
||||
564F9C321F07611700877A00 /* DatabaseFunction.swift in Sources */,
|
||||
5659F49C1EA8D989004A4992 /* Pool.swift in Sources */,
|
||||
569B7FA9201C904C0069DE70 /* Swift4.1.swift in Sources */,
|
||||
5674A6F71F307F600095F066 /* Persistable+Encodable.swift in Sources */,
|
||||
56CEB5501EAA359A00BFAF62 /* SQLExpressible.swift in Sources */,
|
||||
5664759E1D97D8A000FF74B8 /* SQLCollection.swift in Sources */,
|
||||
|
||||
@@ -189,6 +189,8 @@
|
||||
5698AD261DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AD201DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift */; };
|
||||
5698AD371DABAF4A0056AF8C /* FTS5CustomTokenizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AD341DABAF4A0056AF8C /* FTS5CustomTokenizer.swift */; };
|
||||
5698AD3A1DABAF4A0056AF8C /* FTS5CustomTokenizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5698AD341DABAF4A0056AF8C /* FTS5CustomTokenizer.swift */; };
|
||||
569B7FA4201C90430069DE70 /* Swift4.1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569B7FA2201C90430069DE70 /* Swift4.1.swift */; };
|
||||
569B7FA5201C90430069DE70 /* Swift4.1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569B7FA2201C90430069DE70 /* Swift4.1.swift */; };
|
||||
569EF0E6200D37FD00A9FA45 /* DatabaseRegion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569EF0E5200D37FC00A9FA45 /* DatabaseRegion.swift */; };
|
||||
569EF0E7200D37FD00A9FA45 /* DatabaseRegion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569EF0E5200D37FC00A9FA45 /* DatabaseRegion.swift */; };
|
||||
56A4CDB31D4234B200B1A9B9 /* SQLExpressionLiteralTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A4CDAF1D4234B200B1A9B9 /* SQLExpressionLiteralTests.swift */; };
|
||||
@@ -667,6 +669,7 @@
|
||||
5698AD151DAAD16F0056AF8C /* FTS5Tokenizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5Tokenizer.swift; sourceTree = "<group>"; };
|
||||
5698AD201DABAEFA0056AF8C /* FTS5WrapperTokenizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5WrapperTokenizer.swift; sourceTree = "<group>"; };
|
||||
5698AD341DABAF4A0056AF8C /* FTS5CustomTokenizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5CustomTokenizer.swift; sourceTree = "<group>"; };
|
||||
569B7FA2201C90430069DE70 /* Swift4.1.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Swift4.1.swift; sourceTree = "<group>"; };
|
||||
569C1EB11CF07DDD0042627B /* SchedulingWatchdogTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SchedulingWatchdogTests.swift; sourceTree = "<group>"; };
|
||||
569EF0E5200D37FC00A9FA45 /* DatabaseRegion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseRegion.swift; sourceTree = "<group>"; };
|
||||
56A238131B9C74A90082EB20 /* DatabaseTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseTests.swift; sourceTree = "<group>"; };
|
||||
@@ -1279,6 +1282,7 @@
|
||||
56E06F051E859064008AE2A4 /* Fixits-0.102.0.swift */,
|
||||
56D121591ED34978001347D2 /* Fixits-0.109.0.swift */,
|
||||
56873BEB1F2CB400004D24B4 /* Fixits-1.2.swift */,
|
||||
569B7FA2201C90430069DE70 /* Swift4.1.swift */,
|
||||
);
|
||||
path = Legacy;
|
||||
sourceTree = "<group>";
|
||||
@@ -1714,6 +1718,7 @@
|
||||
F3BA80101CFB2876003DC1BA /* DatabaseReader.swift in Sources */,
|
||||
564F9C331F07611800877A00 /* DatabaseFunction.swift in Sources */,
|
||||
5659F49D1EA8D989004A4992 /* Pool.swift in Sources */,
|
||||
569B7FA5201C90430069DE70 /* Swift4.1.swift in Sources */,
|
||||
5674A6F61F307F600095F066 /* Persistable+Encodable.swift in Sources */,
|
||||
56CEB5511EAA359A00BFAF62 /* SQLExpressible.swift in Sources */,
|
||||
5698AC3C1D9E5A590056AF8C /* FTS3Pattern.swift in Sources */,
|
||||
@@ -1960,6 +1965,7 @@
|
||||
F3BA806C1CFB2E55003DC1BA /* DatabaseReader.swift in Sources */,
|
||||
564F9C301F07611500877A00 /* DatabaseFunction.swift in Sources */,
|
||||
5659F49A1EA8D989004A4992 /* Pool.swift in Sources */,
|
||||
569B7FA4201C90430069DE70 /* Swift4.1.swift in Sources */,
|
||||
5674A6F51F307F600095F066 /* Persistable+Encodable.swift in Sources */,
|
||||
56CEB54E1EAA359A00BFAF62 /* SQLExpressible.swift in Sources */,
|
||||
5698AC391D9E5A590056AF8C /* FTS3Pattern.swift in Sources */,
|
||||
|
||||
@@ -295,7 +295,11 @@ class DatabaseAggregateTests: GRDBTestCase {
|
||||
struct Aggregate : DatabaseAggregate {
|
||||
var result: DatabaseValueConvertible?
|
||||
mutating func step(_ dbValues: [DatabaseValue]) {
|
||||
#if swift(>=4.1)
|
||||
let ints = dbValues.compactMap { Int.fromDatabaseValue($0) }
|
||||
#else
|
||||
let ints = dbValues.flatMap { Int.fromDatabaseValue($0) }
|
||||
#endif
|
||||
result = ints.reduce(0, +)
|
||||
}
|
||||
func finalize() -> DatabaseValueConvertible? {
|
||||
|
||||
@@ -250,7 +250,11 @@ class DatabaseFunctionTests: GRDBTestCase {
|
||||
func testFunctionOfTwoArguments() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
let fn = DatabaseFunction("f", argumentCount: 2) { dbValues in
|
||||
#if swift(>=4.1)
|
||||
let ints = dbValues.compactMap { Int.fromDatabaseValue($0) }
|
||||
#else
|
||||
let ints = dbValues.flatMap { Int.fromDatabaseValue($0) }
|
||||
#endif
|
||||
return ints.reduce(0, +)
|
||||
}
|
||||
dbQueue.add(function: fn)
|
||||
|
||||
@@ -31,7 +31,11 @@ class QueryInterfaceExpressionsTests: GRDBTestCase {
|
||||
dbWriter.add(collation: collation)
|
||||
|
||||
customFunction = DatabaseFunction("avgOf", pure: true) { dbValues in
|
||||
#if swift(>=4.1)
|
||||
let sum = dbValues.compactMap { Int.fromDatabaseValue($0) }.reduce(0, +)
|
||||
#else
|
||||
let sum = dbValues.flatMap { Int.fromDatabaseValue($0) }.reduce(0, +)
|
||||
#endif
|
||||
return Double(sum) / Double(dbValues.count)
|
||||
}
|
||||
dbWriter.add(function: self.customFunction)
|
||||
|
||||
Reference in new issue
Block a user