mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-25 04:07:47 +00:00
Merge branch 'master' of github.com:groue/GRDB.swift into Swift3bis
Conflicts: GRDB/Core/Database.swift GRDB/FetchRequest/SQLSelectQuery.swift GRDB/Record/FetchedRecordsController.swift GRDB/Record/TableMapping.swift Tests/Public/Core/Persistable/MutablePersistableTests.swift Tests/Public/Core/Persistable/PersistableTests.swift Tests/Public/Core/Savepoint/SavepointTests.swift Tests/Public/Core/TransactionObserver/TransactionObserverSavepointsTests.swift Tests/Public/Core/TransactionObserver/TransactionObserverTests.swift
This commit is contained in:
commit
e11673d15c
10 files changed
+844
-16
No files matched your search
@@ -454,9 +454,11 @@ public indirect enum _SQLExpression {
|
||||
|
||||
///
|
||||
func sql(_ db: Database, _ bindings: inout [DatabaseValueConvertible?]) throws -> String {
|
||||
// TODO: this method is slow to compile
|
||||
// NOTE: this method *was* slow to compile
|
||||
// https://medium.com/swift-programming/speeding-up-slow-swift-build-times-922feeba5780#.s77wmh4h0
|
||||
// 10746.4ms /Users/groue/Documents/git/groue/GRDB.swift/GRDB/FetchRequest/SQLSelectQuery.swift:439:10 func sql(_ db: Database, _ bindings: inout [DatabaseValueConvertible?]) throws -> String
|
||||
// 10746.4ms /Users/groue/Documents/git/groue/GRDB.swift/GRDB/FetchRequest/SQLSelectQuery.swift:439:10 func sql(db: Database, inout _ bindings: [DatabaseValueConvertible?]) throws -> String
|
||||
// Fixes are marked with "## Slow Compile Fix (Swift 2.2.x):"
|
||||
//
|
||||
switch self {
|
||||
case .SQLLiteral(let sql):
|
||||
return sql
|
||||
@@ -493,7 +495,10 @@ public indirect enum _SQLExpression {
|
||||
if expressions.isEmpty {
|
||||
return "1"
|
||||
} else {
|
||||
return try "(" + expression.sql(db, &bindings) + " NOT IN (" + expressions.map { try $0.sql(db, &bindings) }.joined(separator: ", ") + "))"
|
||||
// ## Slow Compile Fix (Swift 2.2.x):
|
||||
// TODO: Check if Swift 3 compiler fixes this line's slow compilation time:
|
||||
//return try "(" + expression.sql(db, &bindings) + " NOT IN (" + expressions.map { try $0.sql(db, &bindings) }.joinWithSeparator(", ") + "))" // Original, Slow To Compile
|
||||
return try "(" + expression.sql(db, &bindings) + " NOT IN (" + (expressions.map { try $0.sql(db, &bindings) } as [String]).joined(separator: ", ") + "))"
|
||||
}
|
||||
|
||||
case .inSubQuery(let subQuery, let expression):
|
||||
@@ -574,7 +579,10 @@ public indirect enum _SQLExpression {
|
||||
guard !expressions.isEmpty else {
|
||||
return "0"
|
||||
}
|
||||
return try "(" + expression.sql(db, &bindings) + " IN (" + expressions.map { try $0.sql(db, &bindings) }.joined(separator: ", ") + "))"
|
||||
// ## Slow Compile Fix (Swift 2.2.x):
|
||||
// TODO: Check if Swift 3 compiler fixes this line's slow compilation time:
|
||||
//return try "(" + expression.sql(db, &bindings) + " IN (" + expressions.map { try $0.sql(db, &bindings) }.joinWithSeparator(", ") + "))" // Original, Slow To Compile
|
||||
return try "(" + expression.sql(db, &bindings) + " IN (" + (expressions.map { try $0.sql(db, &bindings) } as [String]).joined(separator: ", ") + "))"
|
||||
|
||||
case .inSubQuery(let subQuery, let expression):
|
||||
return try "(" + expression.sql(db, &bindings) + " IN (" + subQuery.sql(db, &bindings) + "))"
|
||||
@@ -586,7 +594,10 @@ public indirect enum _SQLExpression {
|
||||
return try "(" + value.sql(db, &bindings) + " BETWEEN " + min.sql(db, &bindings) + " AND " + max.sql(db, &bindings) + ")"
|
||||
|
||||
case .function(let functionName, let functionArguments):
|
||||
return try functionName + "(" + functionArguments.map { try $0.sql(db, &bindings) }.joined(separator: ", ") + ")"
|
||||
// ## Slow Compile Fix (Swift 2.2.x):
|
||||
// TODO: Check if Swift 3 compiler fixes this line's slow compilation time:
|
||||
//return try functionName + "(" + functionArguments.map { try $0.sql(db, &bindings) }.joinWithSeparator(", ") + ")" // Original, Slow To Compile
|
||||
return try functionName + "(" + (functionArguments.map { try $0.sql(db, &bindings) } as [String]).joined(separator: ", ") + ")"
|
||||
|
||||
case .count(let counted):
|
||||
return try "COUNT(" + counted.countedSQL(db, &bindings) + ")"
|
||||
|
||||
Reference in new issue
Block a user