From c62ccf1de779adbe5ab210d15a4e3fb763c87df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Mon, 13 Apr 2020 11:31:03 +0200 Subject: [PATCH 01/15] Make sure Inflections.default is lazily loaded, even in optimized release builds This commit addresses #755 --- GRDB/Utils/Inflections.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/GRDB/Utils/Inflections.swift b/GRDB/Utils/Inflections.swift index da6c5b176..01051b2d6 100644 --- a/GRDB/Utils/Inflections.swift +++ b/GRDB/Utils/Inflections.swift @@ -9,14 +9,20 @@ extension String { return String(first).uppercased() + dropFirst() } + // Never inline this property, in order to make sure Inflections.default + // is lazily loaded. See https://github.com/groue/GRDB.swift/issues/755#issuecomment-612418053 /// "player" -> "players" /// "players" -> "players" + @inline(never) var pluralized: String { return Inflections.default.pluralize(self) } + // Never inline this property, in order to make sure Inflections.default + // is lazily loaded. See https://github.com/groue/GRDB.swift/issues/755#issuecomment-612418053 /// "player" -> "player" /// "players" -> "player" + @inline(never) var singularized: String { return Inflections.default.singularize(self) } From 94d34a744deaae1413b02e82426d461cb4d1038d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Mon, 13 Apr 2020 11:51:28 +0200 Subject: [PATCH 02/15] v4.12.2 --- CHANGELOG.md | 11 ++++++++++- GRDB.swift.podspec | 2 +- Makefile | 4 ++-- README.md | 6 +++--- Support/Info.plist | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ad9cf8a0..cfb5cd254 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception: #### 4.x Releases -- `4.12.x` Releases - [4.12.0](#4120) | [4.12.1](#4121) +- `4.12.x` Releases - [4.12.0](#4120) | [4.12.1](#4121) | [4.12.2](#4122) - `4.11.x` Releases - [4.11.0](#4110) - `4.10.x` Releases - [4.10.0](#4100) - `4.9.x` Releases - [4.9.0](#490) @@ -69,6 +69,15 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception: ## Next Release --> +## 4.12.2 + +Released April 13, 2020 • [diff](https://github.com/groue/GRDB.swift/compare/v4.12.1...v4.12.2) + +**Fixed** + +- [#757](https://github.com/groue/GRDB.swift/pull/757): Don't load association inflections unless necessary + + ## 4.12.1 Released March 29, 2020 • [diff](https://github.com/groue/GRDB.swift/compare/v4.12.0...v4.12.1) diff --git a/GRDB.swift.podspec b/GRDB.swift.podspec index 268f42377..9b1b9de84 100644 --- a/GRDB.swift.podspec +++ b/GRDB.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'GRDB.swift' - s.version = '4.12.1' + s.version = '4.12.2' s.license = { :type => 'MIT', :file => 'LICENSE' } s.summary = 'A toolkit for SQLite databases, with a focus on application development.' diff --git a/Makefile b/Makefile index 0da9e8e91..b3089021c 100644 --- a/Makefile +++ b/Makefile @@ -466,8 +466,8 @@ ifdef JAZZY --author 'Gwendal Roué' \ --author_url https://github.com/groue \ --github_url https://github.com/groue/GRDB.swift \ - --github-file-prefix https://github.com/groue/GRDB.swift/tree/v4.12.1 \ - --module-version 4.12.1 \ + --github-file-prefix https://github.com/groue/GRDB.swift/tree/v4.12.2 \ + --module-version 4.12.2 \ --module GRDB \ --root-url http://groue.github.io/GRDB.swift/docs/4.12/ \ --output Documentation/Reference \ diff --git a/README.md b/README.md index 7cda20812..36ee6fbbb 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,14 @@ --- -**Latest release**: March 29, 2020 • version 4.12.1 • [CHANGELOG](CHANGELOG.md) • [Migrating From GRDB 3 to GRDB 4](Documentation/GRDB3MigrationGuide.md) +**Latest release**: April 13, 2020 • version 4.12.2 • [CHANGELOG](CHANGELOG.md) • [Migrating From GRDB 3 to GRDB 4](Documentation/GRDB3MigrationGuide.md) **Requirements**: iOS 9.0+ / macOS 10.9+ / tvOS 9.0+ / watchOS 2.0+ • Swift 4.2+ / Xcode 10.0+ | Swift version | GRDB version | | ------------- | ----------------------------------------------------------- | -| **Swift 5** | **v4.12.1** | -| **Swift 4.2** | **v4.12.1** | +| **Swift 5** | **v4.12.2** | +| **Swift 4.2** | **v4.12.2** | | Swift 4.1 | [v3.7.0](https://github.com/groue/GRDB.swift/tree/v3.7.0) | | Swift 4 | [v2.10.0](https://github.com/groue/GRDB.swift/tree/v2.10.0) | | Swift 3.2 | [v1.3.0](https://github.com/groue/GRDB.swift/tree/v1.3.0) | diff --git a/Support/Info.plist b/Support/Info.plist index 0d1771ddc..0bb59a4ea 100644 --- a/Support/Info.plist +++ b/Support/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 4.12.1 + 4.12.2 CFBundleSignature ???? CFBundleVersion From b182a2675917648fc2862e0ecc958b09e519d141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 14 Apr 2020 12:14:25 +0200 Subject: [PATCH 03/15] Fix compilation error with Xcode 10.1 --- GRDB/Utils/Inflections.swift | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/GRDB/Utils/Inflections.swift b/GRDB/Utils/Inflections.swift index 01051b2d6..8221f3224 100644 --- a/GRDB/Utils/Inflections.swift +++ b/GRDB/Utils/Inflections.swift @@ -9,8 +9,13 @@ extension String { return String(first).uppercased() + dropFirst() } - // Never inline this property, in order to make sure Inflections.default - // is lazily loaded. See https://github.com/groue/GRDB.swift/issues/755#issuecomment-612418053 + #if compiler(>=5.0) + // Prevent inlining of functions that use `Inflections.default`, in order to + // make sure this global is lazily loaded, even in release builds. + // See https://github.com/groue/GRDB.swift/issues/755#issuecomment-612418053 + // TODO: remove `@inline(never)` when this PR is shipped in the compiler: + // https://github.com/apple/swift/pull/30445 + /// "player" -> "players" /// "players" -> "players" @inline(never) @@ -18,14 +23,25 @@ extension String { return Inflections.default.pluralize(self) } - // Never inline this property, in order to make sure Inflections.default - // is lazily loaded. See https://github.com/groue/GRDB.swift/issues/755#issuecomment-612418053 /// "player" -> "player" /// "players" -> "player" @inline(never) var singularized: String { return Inflections.default.singularize(self) } + #else + /// "player" -> "players" + /// "players" -> "players" + var pluralized: String { + return Inflections.default.pluralize(self) + } + + /// "player" -> "player" + /// "players" -> "player" + var singularized: String { + return Inflections.default.singularize(self) + } + #endif /// "bar" -> "bar" /// "foo12" -> "foo" From c352ca70b2bc0695c048387aa2c6c977e9ee1c0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 14 Apr 2020 12:07:02 +0200 Subject: [PATCH 04/15] A new kind tweet :-) --- BRAG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/BRAG.md b/BRAG.md index 989b2fb0d..8e778f235 100644 --- a/BRAG.md +++ b/BRAG.md @@ -4,6 +4,12 @@ Here is a list of people who were happy to meet GRDB :-) --- +https://twitter.com/layoutsubviews/status/1249940744929816582 + +> Mixing SQLite / GRDB with Combine is my whole world right now, and it is delightful. + +--- + https://twitter.com/steipete/status/1231105339954802694 > It [Core Data] gets the job done, but folks made some really amazing Swift native sqlite wrappers. From f4e2645e1360f5071aa9e9967eac7d809f981eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 14 Apr 2020 12:47:00 +0200 Subject: [PATCH 05/15] CHANGELOG --- CHANGELOG.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfb5cd254..9317dc5a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,7 @@ All notable changes to this project will be documented in this file. GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception: APIs flagged [**:fire: EXPERIMENTAL**](README.md#what-are-experimental-features). Those are unstable, and may break between any two minor releases of the library. - #### 4.x Releases @@ -65,9 +63,13 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception: - [0.110.0](#01100), ... - + +**Fixed** + +- Restored support for Xcode 10.0 and Xcode 10.1 +- [#759](https://github.com/groue/GRDB.swift/pull/759): Fix batch updates of complex requests + ## 4.12.2 From 07609e8a3f2444f9f436ed2d890a71ccece3b2a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 14 Apr 2020 12:34:25 +0200 Subject: [PATCH 06/15] Failing test for #758 --- .../MutablePersistableRecordUpdateTests.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Tests/GRDBTests/MutablePersistableRecordUpdateTests.swift b/Tests/GRDBTests/MutablePersistableRecordUpdateTests.swift index b024d590d..8abe118c6 100644 --- a/Tests/GRDBTests/MutablePersistableRecordUpdateTests.swift +++ b/Tests/GRDBTests/MutablePersistableRecordUpdateTests.swift @@ -432,6 +432,16 @@ class MutablePersistableRecordUpdateTests: GRDBTestCase { JOIN "team" ON "team"."id" = "player"."teamId") """) } + do { + // Regression test for https://github.com/groue/GRDB.swift/issues/758 + try Player.including(required: Player.team.filter(Column("active") == 1)).updateAll(db, Column("score") <- 0) + XCTAssertEqual(self.lastSQLQuery, """ + UPDATE "player" SET "score" = 0 WHERE rowid IN (\ + SELECT "player"."rowid" \ + FROM "player" \ + JOIN "team" ON ("team"."id" = "player"."teamId") AND ("team"."active" = 1)) + """) + } do { let alias = TableAlias(name: "p") try Player.aliased(alias).including(required: Player.team).updateAll(db, Column("score") <- 0) From d35ad59f9cacf4f1a1d6cbb004795213cd2dc0dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 14 Apr 2020 12:36:01 +0200 Subject: [PATCH 07/15] Fix failing test for #758 --- .../SQLGeneration/SQLQueryGenerator.swift | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/GRDB/QueryInterface/SQLGeneration/SQLQueryGenerator.swift b/GRDB/QueryInterface/SQLGeneration/SQLQueryGenerator.swift index bc017284a..2f8c7d6b3 100644 --- a/GRDB/QueryInterface/SQLGeneration/SQLQueryGenerator.swift +++ b/GRDB/QueryInterface/SQLGeneration/SQLQueryGenerator.swift @@ -279,24 +279,23 @@ struct SQLQueryGenerator { var context = SQLGenerationContext.queryContext(aliases: relation.allAliases) - // SELECT rowid FROM table ... - var generator = self - generator.relation = generator.relation.selectOnly([Column.rowID]) - let selectSQL = try generator.sql(db, &context) - + // UPDATE table... var sql = "UPDATE " - if conflictResolution != .abort { sql += "OR \(conflictResolution.rawValue) " } - sql += tableName.quotedDatabaseIdentifier + // SET column = value... let assignmentsSQL = assignments .map { $0.sql(&context) } .joined(separator: ", ") sql += " SET " + assignmentsSQL - sql += " WHERE rowid IN (\(selectSQL))" + + // WHERE rowid IN (SELECT rowid FROM ...) + var generator = self + generator.relation = generator.relation.selectOnly([Column.rowID]) + sql += try " WHERE rowid IN (\(generator.sql(db, &context)))" let statement = try db.makeUpdateStatement(sql: sql) statement.arguments = context.arguments From e4addc4243587155067263f6f00de9dd6683bda5 Mon Sep 17 00:00:00 2001 From: Andreas Schmitz Date: Tue, 14 Apr 2020 17:18:27 +0200 Subject: [PATCH 08/15] Fixes typos --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 36ee6fbbb..5101d2fdb 100644 --- a/README.md +++ b/README.md @@ -3441,7 +3441,7 @@ extension Place: MutablePersistableRecord {
Define a plain struct optimized for fetching performance -This struct derives is persistence methpds from the standard Encodable protocol (see [Codable Records]), but performs optimized row decoding by accessing database columns with numeric indexes. +This struct derives its persistence methods from the standard Encodable protocol (see [Codable Records]), but performs optimized row decoding by accessing database columns with numeric indexes. See the [Record Protocols Overview](#record-protocols-overview) for more information. From d17866d3fd4ca97a214ec483e39bb8b070f58ee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 14 Apr 2020 18:29:30 +0200 Subject: [PATCH 09/15] Update Realm path --- Makefile | 4 ++-- .../GRDBPerformance.xcodeproj/project.pbxproj | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index b3089021c..7127c3f73 100644 --- a/Makefile +++ b/Makefile @@ -422,10 +422,10 @@ test_performance: Realm FMDB SQLite.swift -scheme GRDBOSXPerformanceComparisonTests \ build-for-testing test-without-building -Realm: Tests/Performance/Realm/build/osx/swift-11.3/RealmSwift.framework +Realm: Tests/Performance/Realm/build/osx/swift-11.4/RealmSwift.framework # Makes sure the Tests/Performance/Realm submodule has been downloaded, and Realm framework has been built. -Tests/Performance/Realm/build/osx/swift-11.3/RealmSwift.framework: +Tests/Performance/Realm/build/osx/swift-11.4/RealmSwift.framework: $(GIT) submodule update --init --recursive Tests/Performance/Realm cd Tests/Performance/Realm && sh build.sh osx-swift diff --git a/Tests/Performance/GRDBPerformance/GRDBPerformance.xcodeproj/project.pbxproj b/Tests/Performance/GRDBPerformance/GRDBPerformance.xcodeproj/project.pbxproj index 622ba2f2d..5fba4b02c 100755 --- a/Tests/Performance/GRDBPerformance/GRDBPerformance.xcodeproj/project.pbxproj +++ b/Tests/Performance/GRDBPerformance/GRDBPerformance.xcodeproj/project.pbxproj @@ -201,8 +201,8 @@ 567986AD23A378CD0076902D /* GRDB.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = GRDB.xcodeproj; path = ../../../GRDB.xcodeproj; 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 = ""; }; - 56B8C2401CA1758F00510325 /* Realm.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Realm.framework; path = "../Realm/build/osx/swift-11.3/Realm.framework"; sourceTree = SOURCE_ROOT; }; - 56B8C2411CA1758F00510325 /* RealmSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RealmSwift.framework; path = "../Realm/build/osx/swift-11.3/RealmSwift.framework"; sourceTree = SOURCE_ROOT; }; + 56B8C2401CA1758F00510325 /* Realm.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Realm.framework; path = "../Realm/build/osx/swift-11.4/Realm.framework"; sourceTree = SOURCE_ROOT; }; + 56B8C2411CA1758F00510325 /* RealmSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RealmSwift.framework; path = "../Realm/build/osx/swift-11.4/RealmSwift.framework"; sourceTree = SOURCE_ROOT; }; 56BB86111BA9886D001F9168 /* PerformanceTests.sqlite */ = {isa = PBXFileReference; lastKnownFileType = file; path = PerformanceTests.sqlite; sourceTree = ""; }; 56BB86121BA9886D001F9168 /* InsertRecordClassTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InsertRecordClassTests.swift; sourceTree = ""; }; 56BB86181BA988F2001F9168 /* FMDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabase.h; sourceTree = ""; }; @@ -689,7 +689,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/../Realm/build/osx/swift-11.3", + "$(PROJECT_DIR)/../Realm/build/osx/swift-11.4", ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = Info.plist; @@ -712,7 +712,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/../Realm/build/osx/swift-11.3", + "$(PROJECT_DIR)/../Realm/build/osx/swift-11.4", ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = Info.plist; From 0569b95a5aba01861818126dd251cf9d3ad4ffda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 5 Apr 2020 16:25:18 +0200 Subject: [PATCH 10/15] Operator <- was ill-advised # Conflicts: # GRDB/QueryInterface/Request/QueryInterfaceRequest.swift --- .../Request/QueryInterfaceRequest.swift | 54 ++++++++++----- GRDB/Record/PersistableRecord.swift | 4 +- .../MutablePersistableRecordUpdateTests.swift | 67 +++++++++++-------- 3 files changed, 77 insertions(+), 48 deletions(-) diff --git a/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift b/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift index 1bb0fcd03..c266a7171 100644 --- a/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift +++ b/GRDB/QueryInterface/Request/QueryInterfaceRequest.swift @@ -483,7 +483,7 @@ extension QueryInterfaceRequest where T: MutablePersistableRecord { /// /// try dbQueue.write { db in /// // UPDATE player SET score = 0 - /// try Player.all().updateAll(db, [Column("score") <- 0]) + /// try Player.all().updateAll(db, [Column("score").set(to: 0)]) /// } /// /// - parameter db: A database connection. @@ -517,7 +517,7 @@ extension QueryInterfaceRequest where T: MutablePersistableRecord { /// /// try dbQueue.write { db in /// // UPDATE player SET score = 0 - /// try Player.all().updateAll(db, Column("score") <- 0) + /// try Player.all().updateAll(db, Column("score").set(to: 0)) /// } /// /// - parameter db: A database connection. @@ -624,22 +624,14 @@ extension Row { // MARK: - ColumnAssignment -precedencegroup ColumnAssignment { - associativity: left - assignment: true - lowerThan: AssignmentPrecedence -} - -infix operator <- : ColumnAssignment - /// A ColumnAssignment can update rows in the database. /// -/// You create an assignment from a column and an assignment operator, such as -/// `<-` or `+=`: +/// You create an assignment from a column and an assignment method or operator, +/// such as `set(to:)` or `+=`: /// /// try dbQueue.write { db in /// // UPDATE player SET score = 0 -/// let assignment = Column("score") <- 0 +/// let assignment = Column("score").set(to: 0) /// try Player.updateAll(db, assignment) /// } public struct ColumnAssignment { @@ -658,6 +650,14 @@ public struct ColumnAssignment { } } +precedencegroup ColumnAssignment { + associativity: left + assignment: true + lowerThan: AssignmentPrecedence +} + +infix operator <- : ColumnAssignment + /// Creates an assignment to a value. /// /// Column("valid") <- true @@ -669,8 +669,26 @@ public struct ColumnAssignment { /// // UPDATE player SET score = 0 /// try Player.updateAll(db, Column("score") <- 0) /// } +@available(*, deprecated, message: "Use column.set(to: value) instead") public func <- (column: ColumnExpression, value: SQLExpressible?) -> ColumnAssignment { - return ColumnAssignment(column: column, value: value) + return column.set(to: value) +} + +extension ColumnExpression { + /// Creates an assignment to a value. + /// + /// Column("valid").set(to: true) + /// Column("score").set(to: 0) + /// Column("score").set(to: nil) + /// Column("score").set(to: Column("score") + Column("bonus")) + /// + /// try dbQueue.write { db in + /// // UPDATE player SET score = 0 + /// try Player.updateAll(db, Column("score").set(to: 0)) + /// } + public func set(to value: SQLExpressible?) -> ColumnAssignment { + return ColumnAssignment(column: self, value: value) + } } /// Creates an assignment that adds a value @@ -683,7 +701,7 @@ public func <- (column: ColumnExpression, value: SQLExpressible?) -> ColumnAssig /// try Player.updateAll(db, Column("score") += 1) /// } public func += (column: ColumnExpression, value: SQLExpressible) -> ColumnAssignment { - return column <- column + value + return column.set(to: column + value) } /// Creates an assignment that subtracts a value @@ -696,7 +714,7 @@ public func += (column: ColumnExpression, value: SQLExpressible) -> ColumnAssign /// try Player.updateAll(db, Column("score") -= 1) /// } public func -= (column: ColumnExpression, value: SQLExpressible) -> ColumnAssignment { - return column <- column - value + return column.set(to: column - value) } /// Creates an assignment that multiplies by a value @@ -709,7 +727,7 @@ public func -= (column: ColumnExpression, value: SQLExpressible) -> ColumnAssign /// try Player.updateAll(db, Column("score") *= 2) /// } public func *= (column: ColumnExpression, value: SQLExpressible) -> ColumnAssignment { - return column <- column * value + return column.set(to: column * value) } /// Creates an assignment that divides by a value @@ -722,5 +740,5 @@ public func *= (column: ColumnExpression, value: SQLExpressible) -> ColumnAssign /// try Player.updateAll(db, Column("score") /= 2) /// } public func /= (column: ColumnExpression, value: SQLExpressible) -> ColumnAssignment { - return column <- column / value + return column.set(to: column / value) } diff --git a/GRDB/Record/PersistableRecord.swift b/GRDB/Record/PersistableRecord.swift index aba8604a6..376fbb92f 100644 --- a/GRDB/Record/PersistableRecord.swift +++ b/GRDB/Record/PersistableRecord.swift @@ -526,7 +526,7 @@ extension MutablePersistableRecord { /// /// try dbQueue.write { db in /// // UPDATE player SET score = 0 - /// try Player.updateAll(db, [Column("score") <- 0]) + /// try Player.updateAll(db, [Column("score").set(to: 0)]) /// } /// /// - parameter db: A database connection. @@ -551,7 +551,7 @@ extension MutablePersistableRecord { /// /// try dbQueue.write { db in /// // UPDATE player SET score = 0 - /// try Player.updateAll(db, Column("score") <- 0) + /// try Player.updateAll(db, Column("score").set(to: 0)) /// } /// /// - parameter db: A database connection. diff --git a/Tests/GRDBTests/MutablePersistableRecordUpdateTests.swift b/Tests/GRDBTests/MutablePersistableRecordUpdateTests.swift index 8abe118c6..a989b2971 100644 --- a/Tests/GRDBTests/MutablePersistableRecordUpdateTests.swift +++ b/Tests/GRDBTests/MutablePersistableRecordUpdateTests.swift @@ -35,7 +35,7 @@ class MutablePersistableRecordUpdateTests: GRDBTestCase { func testRequestUpdateAll() throws { try makeDatabaseQueue().write { db in try Player.createTable(db) - let assignment = Columns.score <- 0 + let assignment = Columns.score.set(to: 0) try Player.updateAll(db, assignment) XCTAssertEqual(self.lastSQLQuery, """ @@ -106,11 +106,22 @@ class MutablePersistableRecordUpdateTests: GRDBTestCase { } } + func testDeprecatedOperator() throws { + try makeDatabaseQueue().write { db in + try Player.createTable(db) + + try Player.updateAll(db, Columns.score <- 0) + XCTAssertEqual(self.lastSQLQuery, """ + UPDATE "player" SET "score" = 0 + """) + } + } + func testNilAssignment() throws { try makeDatabaseQueue().write { db in try Player.createTable(db) - try Player.updateAll(db, Columns.score <- nil) + try Player.updateAll(db, Columns.score.set(to: nil)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "player" SET "score" = NULL """) @@ -121,7 +132,7 @@ class MutablePersistableRecordUpdateTests: GRDBTestCase { try makeDatabaseQueue().write { db in try Player.createTable(db) - try Player.updateAll(db, Columns.score <- Columns.score * (Columns.bonus + 1)) + try Player.updateAll(db, Columns.score.set(to: Columns.score * (Columns.bonus + 1))) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "player" SET "score" = "score" * ("bonus" + 1) """) @@ -236,22 +247,22 @@ class MutablePersistableRecordUpdateTests: GRDBTestCase { try makeDatabaseQueue().write { db in try Player.createTable(db) - try Player.updateAll(db, Columns.score <- 0, Columns.bonus <- 1) + try Player.updateAll(db, Columns.score.set(to: 0), Columns.bonus.set(to: 1)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "player" SET "score" = 0, "bonus" = 1 """) - try Player.updateAll(db, [Columns.score <- 0, Columns.bonus <- 1]) + try Player.updateAll(db, [Columns.score.set(to: 0), Columns.bonus.set(to: 1)]) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "player" SET "score" = 0, "bonus" = 1 """) - try Player.all().updateAll(db, Columns.score <- 0, Columns.bonus <- 1) + try Player.all().updateAll(db, Columns.score.set(to: 0), Columns.bonus.set(to: 1)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "player" SET "score" = 0, "bonus" = 1 """) - try Player.all().updateAll(db, [Columns.score <- 0, Columns.bonus <- 1]) + try Player.all().updateAll(db, [Columns.score.set(to: 0), Columns.bonus.set(to: 1)]) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "player" SET "score" = 0, "bonus" = 1 """) @@ -316,22 +327,22 @@ class MutablePersistableRecordUpdateTests: GRDBTestCase { try makeDatabaseQueue().write { db in try Player.createTable(db) - try AbortPlayer.updateAll(db, Column("score") <- 0) + try AbortPlayer.updateAll(db, Column("score").set(to: 0)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "player" SET "score" = 0 """) - try AbortPlayer.updateAll(db, [Column("score") <- 0]) + try AbortPlayer.updateAll(db, [Column("score").set(to: 0)]) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "player" SET "score" = 0 """) - try AbortPlayer.all().updateAll(db, Column("score") <- 0) + try AbortPlayer.all().updateAll(db, Column("score").set(to: 0)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "player" SET "score" = 0 """) - try AbortPlayer.all().updateAll(db, [Column("score") <- 0]) + try AbortPlayer.all().updateAll(db, [Column("score").set(to: 0)]) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "player" SET "score" = 0 """) @@ -347,22 +358,22 @@ class MutablePersistableRecordUpdateTests: GRDBTestCase { try makeDatabaseQueue().write { db in try Player.createTable(db) - try IgnorePlayer.updateAll(db, Column("score") <- 0) + try IgnorePlayer.updateAll(db, Column("score").set(to: 0)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE OR IGNORE "player" SET "score" = 0 """) - try IgnorePlayer.updateAll(db, [Column("score") <- 0]) + try IgnorePlayer.updateAll(db, [Column("score").set(to: 0)]) XCTAssertEqual(self.lastSQLQuery, """ UPDATE OR IGNORE "player" SET "score" = 0 """) - try IgnorePlayer.all().updateAll(db, Column("score") <- 0) + try IgnorePlayer.all().updateAll(db, Column("score").set(to: 0)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE OR IGNORE "player" SET "score" = 0 """) - try IgnorePlayer.all().updateAll(db, [Column("score") <- 0]) + try IgnorePlayer.all().updateAll(db, [Column("score").set(to: 0)]) XCTAssertEqual(self.lastSQLQuery, """ UPDATE OR IGNORE "player" SET "score" = 0 """) @@ -373,27 +384,27 @@ class MutablePersistableRecordUpdateTests: GRDBTestCase { try makeDatabaseQueue().write { db in try Player.createTable(db) - try Player.updateAll(db, Column("score") <- 0) + try Player.updateAll(db, Column("score").set(to: 0)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "player" SET "score" = 0 """) - try Player.updateAll(db, onConflict: .ignore, Column("score") <- 0) + try Player.updateAll(db, onConflict: .ignore, Column("score").set(to: 0)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE OR IGNORE "player" SET "score" = 0 """) - try Player.updateAll(db, onConflict: .ignore, [Column("score") <- 0]) + try Player.updateAll(db, onConflict: .ignore, [Column("score").set(to: 0)]) XCTAssertEqual(self.lastSQLQuery, """ UPDATE OR IGNORE "player" SET "score" = 0 """) - try Player.all().updateAll(db, onConflict: .ignore, Column("score") <- 0) + try Player.all().updateAll(db, onConflict: .ignore, Column("score").set(to: 0)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE OR IGNORE "player" SET "score" = 0 """) - try Player.all().updateAll(db, onConflict: .ignore, [Column("score") <- 0]) + try Player.all().updateAll(db, onConflict: .ignore, [Column("score").set(to: 0)]) XCTAssertEqual(self.lastSQLQuery, """ UPDATE OR IGNORE "player" SET "score" = 0 """) @@ -424,7 +435,7 @@ class MutablePersistableRecordUpdateTests: GRDBTestCase { } do { - try Player.including(required: Player.team).updateAll(db, Column("score") <- 0) + try Player.including(required: Player.team).updateAll(db, Column("score").set(to: 0)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "player" SET "score" = 0 WHERE rowid IN (\ SELECT "player"."rowid" \ @@ -444,7 +455,7 @@ class MutablePersistableRecordUpdateTests: GRDBTestCase { } do { let alias = TableAlias(name: "p") - try Player.aliased(alias).including(required: Player.team).updateAll(db, Column("score") <- 0) + try Player.aliased(alias).including(required: Player.team).updateAll(db, Column("score").set(to: 0)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "player" SET "score" = 0 WHERE rowid IN (\ SELECT "p"."rowid" \ @@ -453,7 +464,7 @@ class MutablePersistableRecordUpdateTests: GRDBTestCase { """) } do { - try Team.having(Team.players.isEmpty).updateAll(db, Column("active") <- false) + try Team.having(Team.players.isEmpty).updateAll(db, Column("active").set(to: false)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "team" SET "active" = 0 WHERE rowid IN (\ SELECT "team"."rowid" \ @@ -464,7 +475,7 @@ class MutablePersistableRecordUpdateTests: GRDBTestCase { """) } do { - try Team.including(all: Team.players).updateAll(db, Column("active") <- false) + try Team.including(all: Team.players).updateAll(db, Column("active").set(to: false)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "team" SET "active" = 0 """) @@ -491,7 +502,7 @@ class MutablePersistableRecordUpdateTests: GRDBTestCase { t.primaryKey(["countryCode", "citizenId"]) } do { - try Player.all().groupByPrimaryKey().updateAll(db, Column("score") <- 0) + try Player.all().groupByPrimaryKey().updateAll(db, Column("score").set(to: 0)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "player" SET "score" = 0 WHERE rowid IN (\ SELECT "rowid" \ @@ -500,7 +511,7 @@ class MutablePersistableRecordUpdateTests: GRDBTestCase { """) } do { - try Player.all().group(Column.rowID).updateAll(db, Column("score") <- 0) + try Player.all().group(Column.rowID).updateAll(db, Column("score").set(to: 0)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "player" SET "score" = 0 WHERE rowid IN (\ SELECT "rowid" \ @@ -509,7 +520,7 @@ class MutablePersistableRecordUpdateTests: GRDBTestCase { """) } do { - try Passport.all().groupByPrimaryKey().updateAll(db, Column("active") <- true) + try Passport.all().groupByPrimaryKey().updateAll(db, Column("active").set(to: true)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "passport" SET "active" = 1 WHERE rowid IN (\ SELECT "rowid" \ @@ -518,7 +529,7 @@ class MutablePersistableRecordUpdateTests: GRDBTestCase { """) } do { - try Passport.all().group(Column.rowID).updateAll(db, Column("active") <- true) + try Passport.all().group(Column.rowID).updateAll(db, Column("active").set(to: true)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "passport" SET "active" = 1 WHERE rowid IN (\ SELECT "rowid" \ From a065926fb1824ef22f16307507364d80d2b7dfba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 5 Apr 2020 16:26:29 +0200 Subject: [PATCH 11/15] Update documentation --- README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5101d2fdb..2be5a035e 100644 --- a/README.md +++ b/README.md @@ -4696,29 +4696,32 @@ Player.deleteOne(db, key: ["email": "arthur@example.com"]) ## Update Requests -**Requests can batch update records**. The `updateAll()` method accepts *column assignments* defined with the `<-` operator: +**Requests can batch update records**. The `updateAll()` method accepts *column assignments* defined with the `set(to:)` method: ```swift // UPDATE player SET score = 0, isHealthy = 1, bonus = NULL -try Player.updateAll(db, scoreColumn <- 0, isHealthyColumn <- true, bonus <- nil) +try Player.updateAll(db, + scoreColumn.set(to: 0), + isHealthyColumn.set(to: true), + bonus.set(to: nil)) // UPDATE player SET score = 0 WHERE team = 'red' try Player .filter(teamColumn == "red") - .updateAll(db, scoreColumn <- 0) + .updateAll(db, scoreColumn.set(to: 0)) // UPDATE player SET top = 1 ORDER BY score DESC LIMIT 10 try Player .order(scoreColumn.desc) .limit(10) - .updateAll(db, topColumn <- true) + .updateAll(db, topColumn.set(to: true)) ``` Column assignments accept any expression: ```swift // UPDATE player SET score = score + (bonus * 2) -try Player.updateAll(db, scoreColumn <- scoreColumn + bonusColumn * 2) +try Player.updateAll(db, scoreColumn.set(to: scoreColumn + bonusColumn * 2)) ``` As a convenience, you can also use the `+=`, `-=`, `*=`, or `/=` operators: From 6918bda82d6233550101e30a574d37f91764cbe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 14 Apr 2020 18:44:52 +0200 Subject: [PATCH 12/15] CHANGELOG --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9317dc5a6..6a7d028fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,9 +67,13 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception: **Fixed** -- Restored support for Xcode 10.0 and Xcode 10.1 +- Restored support for Xcode 10.0 and Xcode 10.1, broken in 4.12.2 - [#759](https://github.com/groue/GRDB.swift/pull/759): Fix batch updates of complex requests +**New** + +- Deprecate the batch update `<-` operator + ## 4.12.2 From a98350d206287de735601eefb68f3b1afbe9e25b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 14 Apr 2020 18:55:40 +0200 Subject: [PATCH 13/15] CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a7d028fb..00b34e537 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,7 +72,7 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception: **New** -- Deprecate the batch update `<-` operator +- [#761](https://github.com/groue/GRDB.swift/pull/761): Deprecate the batch update `<-` operator ## 4.12.2 From 2d30f06f549047f76e5f7afd8bd8632e30273fd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 14 Apr 2020 19:01:42 +0200 Subject: [PATCH 14/15] Update regression test introduced after commit cherry-picked from #750 --- Tests/GRDBTests/MutablePersistableRecordUpdateTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/GRDBTests/MutablePersistableRecordUpdateTests.swift b/Tests/GRDBTests/MutablePersistableRecordUpdateTests.swift index a989b2971..86a9137b1 100644 --- a/Tests/GRDBTests/MutablePersistableRecordUpdateTests.swift +++ b/Tests/GRDBTests/MutablePersistableRecordUpdateTests.swift @@ -445,7 +445,7 @@ class MutablePersistableRecordUpdateTests: GRDBTestCase { } do { // Regression test for https://github.com/groue/GRDB.swift/issues/758 - try Player.including(required: Player.team.filter(Column("active") == 1)).updateAll(db, Column("score") <- 0) + try Player.including(required: Player.team.filter(Column("active") == 1)).updateAll(db, Column("score").set(to: 0)) XCTAssertEqual(self.lastSQLQuery, """ UPDATE "player" SET "score" = 0 WHERE rowid IN (\ SELECT "player"."rowid" \ From 0200f64e6c386a46a4a67a8a6f95a2599044858d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 14 Apr 2020 19:11:28 +0200 Subject: [PATCH 15/15] v4.13.0 --- CHANGELOG.md | 9 +++++++++ GRDB.swift.podspec | 2 +- Makefile | 6 +++--- README.md | 42 +++++++++++++++++++++--------------------- Support/Info.plist | 2 +- 5 files changed, 35 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00b34e537..f8d821657 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,14 @@ All notable changes to this project will be documented in this file. GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception: APIs flagged [**:fire: EXPERIMENTAL**](README.md#what-are-experimental-features). Those are unstable, and may break between any two minor releases of the library. + #### 4.x Releases +- `4.13.x` Releases - [4.13.0](#4130) - `4.12.x` Releases - [4.12.0](#4120) | [4.12.1](#4121) | [4.12.2](#4122) - `4.11.x` Releases - [4.11.0](#4110) - `4.10.x` Releases - [4.10.0](#4100) @@ -63,7 +66,13 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception: - [0.110.0](#01100), ... + + +## 4.13.0 + +Released April 15, 2020 • [diff](https://github.com/groue/GRDB.swift/compare/v4.12.2...v4.13.0) **Fixed** diff --git a/GRDB.swift.podspec b/GRDB.swift.podspec index 9b1b9de84..f7934f5ec 100644 --- a/GRDB.swift.podspec +++ b/GRDB.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'GRDB.swift' - s.version = '4.12.2' + s.version = '4.13.0' s.license = { :type => 'MIT', :file => 'LICENSE' } s.summary = 'A toolkit for SQLite databases, with a focus on application development.' diff --git a/Makefile b/Makefile index 7127c3f73..96044008a 100644 --- a/Makefile +++ b/Makefile @@ -466,10 +466,10 @@ ifdef JAZZY --author 'Gwendal Roué' \ --author_url https://github.com/groue \ --github_url https://github.com/groue/GRDB.swift \ - --github-file-prefix https://github.com/groue/GRDB.swift/tree/v4.12.2 \ - --module-version 4.12.2 \ + --github-file-prefix https://github.com/groue/GRDB.swift/tree/v4.13.0 \ + --module-version 4.13.0 \ --module GRDB \ - --root-url http://groue.github.io/GRDB.swift/docs/4.12/ \ + --root-url http://groue.github.io/GRDB.swift/docs/4.13/ \ --output Documentation/Reference \ --xcodebuild-arguments -project,GRDB.xcodeproj,-scheme,GRDBiOS else diff --git a/README.md b/README.md index 2be5a035e..91e5408e3 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,14 @@ --- -**Latest release**: April 13, 2020 • version 4.12.2 • [CHANGELOG](CHANGELOG.md) • [Migrating From GRDB 3 to GRDB 4](Documentation/GRDB3MigrationGuide.md) +**Latest release**: April 15, 2020 • version 4.13.0 • [CHANGELOG](CHANGELOG.md) • [Migrating From GRDB 3 to GRDB 4](Documentation/GRDB3MigrationGuide.md) **Requirements**: iOS 9.0+ / macOS 10.9+ / tvOS 9.0+ / watchOS 2.0+ • Swift 4.2+ / Xcode 10.0+ | Swift version | GRDB version | | ------------- | ----------------------------------------------------------- | -| **Swift 5** | **v4.12.2** | -| **Swift 4.2** | **v4.12.2** | +| **Swift 5** | **v4.13.0** | +| **Swift 4.2** | **v4.13.0** | | Swift 4.1 | [v3.7.0](https://github.com/groue/GRDB.swift/tree/v3.7.0) | | Swift 4 | [v2.10.0](https://github.com/groue/GRDB.swift/tree/v2.10.0) | | Swift 3.2 | [v1.3.0](https://github.com/groue/GRDB.swift/tree/v1.3.0) | @@ -263,7 +263,7 @@ Documentation #### Reference -- [GRDB Reference](http://groue.github.io/GRDB.swift/docs/4.12/index.html) (generated by [Jazzy](https://github.com/realm/jazzy)) +- [GRDB Reference](http://groue.github.io/GRDB.swift/docs/4.13/index.html) (generated by [Jazzy](https://github.com/realm/jazzy)) #### Getting Started @@ -478,7 +478,7 @@ let dbQueue = try DatabaseQueue( configuration: config) ``` -See [Configuration](http://groue.github.io/GRDB.swift/docs/4.12/Structs/Configuration.html) for more details. +See [Configuration](http://groue.github.io/GRDB.swift/docs/4.13/Structs/Configuration.html) for more details. ## Database Pools @@ -559,7 +559,7 @@ let dbPool = try DatabasePool( configuration: config) ``` -See [Configuration](http://groue.github.io/GRDB.swift/docs/4.12/Structs/Configuration.html) for more details. +See [Configuration](http://groue.github.io/GRDB.swift/docs/4.13/Structs/Configuration.html) for more details. Database pools are more memory-hungry than database queues. See [Memory Management](#memory-management) for more information. @@ -619,7 +619,7 @@ try dbQueue.write { db in } ``` -The `?` and colon-prefixed keys like `:score` in the SQL query are the **statements arguments**. You pass arguments with arrays or dictionaries, as in the example above. See [Values](#values) for more information on supported arguments types (Bool, Int, String, Date, Swift enums, etc.), and [StatementArguments](http://groue.github.io/GRDB.swift/docs/4.12/Structs/StatementArguments.html) for a detailed documentation of SQLite arguments. +The `?` and colon-prefixed keys like `:score` in the SQL query are the **statements arguments**. You pass arguments with arrays or dictionaries, as in the example above. See [Values](#values) for more information on supported arguments types (Bool, Int, String, Date, Swift enums, etc.), and [StatementArguments](http://groue.github.io/GRDB.swift/docs/4.13/Structs/StatementArguments.html) for a detailed documentation of SQLite arguments. In Swift 5, you can embed query arguments right into your SQL queries, with the `literal` argument label, as in the example below. See [SQL Interpolation] for more details. @@ -820,7 +820,7 @@ Both arrays and cursors can iterate over database results. How do you choose one - **Cursors are granted with direct access to SQLite,** unlike arrays that have to take the time to copy database values. If you look after extra performance, you may prefer cursors over arrays. -- **Cursors adopt the [Cursor](http://groue.github.io/GRDB.swift/docs/4.12/Protocols/Cursor.html) protocol, which looks a lot like standard [lazy sequences](https://developer.apple.com/reference/swift/lazysequenceprotocol) of Swift.** As such, cursors come with many convenience methods: `compactMap`, `contains`, `dropFirst`, `dropLast`, `drop(while:)`, `enumerated`, `filter`, `first`, `flatMap`, `forEach`, `joined`, `joined(separator:)`, `max`, `max(by:)`, `min`, `min(by:)`, `map`, `prefix`, `prefix(while:)`, `reduce`, `reduce(into:)`, `suffix`: +- **Cursors adopt the [Cursor](http://groue.github.io/GRDB.swift/docs/4.13/Protocols/Cursor.html) protocol, which looks a lot like standard [lazy sequences](https://developer.apple.com/reference/swift/lazysequenceprotocol) of Swift.** As such, cursors come with many convenience methods: `compactMap`, `contains`, `dropFirst`, `dropLast`, `drop(while:)`, `enumerated`, `filter`, `first`, `flatMap`, `forEach`, `joined`, `joined(separator:)`, `max`, `max(by:)`, `min`, `min(by:)`, `map`, `prefix`, `prefix(while:)`, `reduce`, `reduce(into:)`, `suffix`: ```swift // Prints all Github links @@ -902,7 +902,7 @@ let rows = try Row.fetchAll(db, arguments: ["name": "Arthur"]) ``` -See [Values](#values) for more information on supported arguments types (Bool, Int, String, Date, Swift enums, etc.), and [StatementArguments](http://groue.github.io/GRDB.swift/docs/4.12/Structs/StatementArguments.html) for a detailed documentation of SQLite arguments. +See [Values](#values) for more information on supported arguments types (Bool, Int, String, Date, Swift enums, etc.), and [StatementArguments](http://groue.github.io/GRDB.swift/docs/4.13/Structs/StatementArguments.html) for a detailed documentation of SQLite arguments. Unlike row arrays that contain copies of the database rows, row cursors are close to the SQLite metal, and require a little care: @@ -1185,7 +1185,7 @@ GRDB ships with built-in support for the following value types: - Generally speaking, all types that adopt the [DatabaseValueConvertible](#custom-value-types) protocol. -Values can be used as [statement arguments](http://groue.github.io/GRDB.swift/docs/4.12/Structs/StatementArguments.html): +Values can be used as [statement arguments](http://groue.github.io/GRDB.swift/docs/4.13/Structs/StatementArguments.html): ```swift let url: URL = ... @@ -1592,7 +1592,7 @@ try dbQueue.inDatabase { db in // or dbPool.writeWithoutTransaction } ``` -Transactions can't be left opened unless you set the [allowsUnsafeTransactions](http://groue.github.io/GRDB.swift/docs/4.12/Structs/Configuration.html) configuration flag: +Transactions can't be left opened unless you set the [allowsUnsafeTransactions](http://groue.github.io/GRDB.swift/docs/4.13/Structs/Configuration.html) configuration flag: ```swift // fatal error: A transaction has been left opened at the end of a database access @@ -1706,7 +1706,7 @@ try dbQueue.write { db in } ``` -The `?` and colon-prefixed keys like `:name` in the SQL query are the statement arguments. You set them with arrays or dictionaries (arguments are actually of type [StatementArguments](http://groue.github.io/GRDB.swift/docs/4.12/Structs/StatementArguments.html), which happens to adopt the ExpressibleByArrayLiteral and ExpressibleByDictionaryLiteral protocols). +The `?` and colon-prefixed keys like `:name` in the SQL query are the statement arguments. You set them with arrays or dictionaries (arguments are actually of type [StatementArguments](http://groue.github.io/GRDB.swift/docs/4.13/Structs/StatementArguments.html), which happens to adopt the ExpressibleByArrayLiteral and ExpressibleByDictionaryLiteral protocols). ```swift updateStatement.arguments = ["name": "Arthur", "score": 1000] @@ -1965,7 +1965,7 @@ row["consumed"] // "Hello" row["produced"] // nil ``` -Row adapters are values that adopt the [RowAdapter](http://groue.github.io/GRDB.swift/docs/4.12/Protocols/RowAdapter.html) protocol. You can implement your own custom adapters ([**:fire: EXPERIMENTAL**](#what-are-experimental-features)), or use one of the four built-in adapters, described below. +Row adapters are values that adopt the [RowAdapter](http://groue.github.io/GRDB.swift/docs/4.13/Protocols/RowAdapter.html) protocol. You can implement your own custom adapters ([**:fire: EXPERIMENTAL**](#what-are-experimental-features)), or use one of the four built-in adapters, described below. To see how row adapters can be used, see [Joined Queries Support](#joined-queries-support). @@ -2427,7 +2427,7 @@ try Place.fetchAll(db, sql: "SELECT ...", arguments:...) // [Place] try Place.fetchOne(db, sql: "SELECT ...", arguments:...) // Place? ``` -See [fetching methods](#fetching-methods) for information about the `fetchCursor`, `fetchAll` and `fetchOne` methods. See [StatementArguments](http://groue.github.io/GRDB.swift/docs/4.12/Structs/StatementArguments.html) for more information about the query arguments. +See [fetching methods](#fetching-methods) for information about the `fetchCursor`, `fetchAll` and `fetchOne` methods. See [StatementArguments](http://groue.github.io/GRDB.swift/docs/4.13/Structs/StatementArguments.html) for more information about the query arguments. > :point_up: **Note**: for performance reasons, the same row argument to `init(row:)` is reused during the iteration of a fetch query. If you want to keep the row for later use, make sure to store a copy: `self.row = row.copy()`. @@ -2808,7 +2808,7 @@ protocol EncodableRecord { } ``` -See [DatabaseDateDecodingStrategy](https://groue.github.io/GRDB.swift/docs/4.12/Enums/DatabaseDateDecodingStrategy.html), [DatabaseDateEncodingStrategy](https://groue.github.io/GRDB.swift/docs/4.12/Enums/DatabaseDateEncodingStrategy.html), and [DatabaseUUIDEncodingStrategy](https://groue.github.io/GRDB.swift/docs/4.12/Enums/DatabaseUUIDEncodingStrategy.html) to learn about all available strategies. +See [DatabaseDateDecodingStrategy](https://groue.github.io/GRDB.swift/docs/4.13/Enums/DatabaseDateDecodingStrategy.html), [DatabaseDateEncodingStrategy](https://groue.github.io/GRDB.swift/docs/4.13/Enums/DatabaseDateEncodingStrategy.html), and [DatabaseUUIDEncodingStrategy](https://groue.github.io/GRDB.swift/docs/4.13/Enums/DatabaseUUIDEncodingStrategy.html) to learn about all available strategies. > :point_up: **Note**: there is no customization of uuid decoding, because UUID can already decode all its encoded variants (16-bytes blobs, and uuid strings). @@ -4197,7 +4197,7 @@ Player // SELECT * FROM player ``` -Raw SQL snippets are also accepted, with eventual [arguments](http://groue.github.io/GRDB.swift/docs/4.12/Structs/StatementArguments.html): +Raw SQL snippets are also accepted, with eventual [arguments](http://groue.github.io/GRDB.swift/docs/4.13/Structs/StatementArguments.html): ```swift // SELECT DATE(creationDate), COUNT(*) FROM player WHERE name = 'Arthur' GROUP BY date(creationDate) @@ -4815,7 +4815,7 @@ let request = Player.all() **To build custom requests**, you can use one of the built-in requests, derive requests from other requests, or create your own request type that adopts the [FetchRequest](#fetchrequest-protocol) protocol. -- [SQLRequest](http://groue.github.io/GRDB.swift/docs/4.12/Structs/SQLRequest.html) is a fetch request built from raw SQL. For example: +- [SQLRequest](http://groue.github.io/GRDB.swift/docs/4.13/Structs/SQLRequest.html) is a fetch request built from raw SQL. For example: ```swift extension Player { @@ -4859,7 +4859,7 @@ let request = Player.all() - The `adapted(_:)` method eases the consumption of complex rows with [row adapters](#row-adapters). See [Joined Queries Support](#joined-queries-support) for some sample code that uses this method. -- [AnyFetchRequest](http://groue.github.io/GRDB.swift/docs/4.12/Structs/AnyFetchRequest.html): a [type-erased](http://chris.eidhof.nl/post/type-erasers-in-swift/) request. +- [AnyFetchRequest](http://groue.github.io/GRDB.swift/docs/4.13/Structs/AnyFetchRequest.html): a [type-erased](http://chris.eidhof.nl/post/type-erasers-in-swift/) request. ### Fetching From Custom Requests @@ -6404,7 +6404,7 @@ After `stopObservingDatabaseChangesUntilNextTransaction()`, the `databaseDidChan ### DatabaseRegion -**[DatabaseRegion](https://groue.github.io/GRDB.swift/docs/4.12/Structs/DatabaseRegion.html) is a type that helps observing changes in the results of a database [request](#requests)**. +**[DatabaseRegion](https://groue.github.io/GRDB.swift/docs/4.13/Structs/DatabaseRegion.html) is a type that helps observing changes in the results of a database [request](#requests)**. A request knows which database modifications can impact its results. It can communicate this information to [transaction observers](#transactionobserver-protocol) by the way of a DatabaseRegion. @@ -6414,7 +6414,7 @@ DatabaseRegion fuels, for example, [ValueObservation and DatabaseRegionObservati For example, if you observe the region of `Player.select(max(Column("score")))`, then you'll get be notified of all changes performed on the `score` column of the `player` table (updates, insertions and deletions), even if they do not modify the value of the maximum score. However, you will not get any notification for changes performed on other database tables, or updates to other columns of the player table. -For more details, see the [reference](http://groue.github.io/GRDB.swift/docs/4.12/Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV10isModified2bySbAA0B5EventV_tF). +For more details, see the [reference](http://groue.github.io/GRDB.swift/docs/4.13/Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV10isModified2bySbAA0B5EventV_tF). #### The DatabaseRegionConvertible Protocol @@ -7512,7 +7512,7 @@ try snapshot2.read { db in ### DatabaseWriter and DatabaseReader Protocols -Both DatabaseQueue and DatabasePool adopt the [DatabaseReader](http://groue.github.io/GRDB.swift/docs/4.12/Protocols/DatabaseReader.html) and [DatabaseWriter](http://groue.github.io/GRDB.swift/docs/4.12/Protocols/DatabaseWriter.html) protocols. DatabaseSnapshot adopts DatabaseReader only. +Both DatabaseQueue and DatabasePool adopt the [DatabaseReader](http://groue.github.io/GRDB.swift/docs/4.13/Protocols/DatabaseReader.html) and [DatabaseWriter](http://groue.github.io/GRDB.swift/docs/4.13/Protocols/DatabaseWriter.html) protocols. DatabaseSnapshot adopts DatabaseReader only. These protocols provide a unified API that let you write generic code that targets all concurrency modes. They fuel, for example: diff --git a/Support/Info.plist b/Support/Info.plist index 0bb59a4ea..b8315a49b 100644 --- a/Support/Info.plist +++ b/Support/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 4.12.2 + 4.13.0 CFBundleSignature ???? CFBundleVersion