From 9da2e66e464776260016e27aac21f8ef961dafc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 7 Nov 2021 14:56:51 +0100 Subject: [PATCH 1/6] Fix flaky test --- Tests/GRDBTests/SharedValueObservationTests.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Tests/GRDBTests/SharedValueObservationTests.swift b/Tests/GRDBTests/SharedValueObservationTests.swift index 8d24ccd2d..7ea72f443 100644 --- a/Tests/GRDBTests/SharedValueObservationTests.swift +++ b/Tests/GRDBTests/SharedValueObservationTests.swift @@ -357,10 +357,9 @@ class SharedValueObservationTests: GRDBTestCase { }) wait(for: [exp], timeout: 1) - log.flush() // Ignore eventual notification of value: 3 - + cancellable.cancel() - XCTAssertEqual(log.flush(), ["cancel"]) + XCTAssertTrue(log.flush().contains("cancel")) // Ignore eventual notification of value: 3 } #if canImport(Combine) From 2b5d3f1d72337ef1b15b8a06f3533437b59502e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 7 Nov 2021 15:35:41 +0100 Subject: [PATCH 2/6] Upgrade Realm version in performance tests --- .../xcshareddata/swiftpm/Package.resolved | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/Performance/GRDBPerformance/GRDBPerformance.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Tests/Performance/GRDBPerformance/GRDBPerformance.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index ef77a0749..604f254f6 100644 --- a/Tests/Performance/GRDBPerformance/GRDBPerformance.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Tests/Performance/GRDBPerformance/GRDBPerformance.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -15,8 +15,8 @@ "repositoryURL": "https://github.com/realm/realm-cocoa.git", "state": { "branch": null, - "revision": "7a3e25994d4d917efe30fa4496775d3f024b71b6", - "version": "10.13.0" + "revision": "328425bfc372ce77ec1f4f2701f61ececbb97d84", + "version": "10.19.0" } }, { @@ -24,8 +24,8 @@ "repositoryURL": "https://github.com/realm/realm-core", "state": { "branch": null, - "revision": "9a7d09994e85b7eda8e3553b444bcfef6ec3f9ea", - "version": "11.3.0" + "revision": "b170db6a47789ff5f2fbc3eeed0220b4b0a3f6b7", + "version": "11.6.0" } }, { From 0c9de25a8ca899f8abe1def71e259920de338bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 7 Nov 2021 15:36:03 +0100 Subject: [PATCH 3/6] Bump number of operations performed by performance tests Apple Silicon and SSD are too fast, and we need to display higher numbers --- .../FetchNamedValuesTests.swift | 2 +- .../FetchPositionalValuesTests.swift | 2 +- .../FetchRecordClassTests.swift | 2 +- .../FetchRecordDecodableTests.swift | 2 +- .../FetchRecordOptimizedTests.swift | 2 +- .../FetchRecordStructTests.swift | 2 +- .../InsertNamedValuesTests.swift | 2 +- .../InsertPositionalValuesTests.swift | 2 +- .../InsertRecordClassTests.swift | 2 +- .../InsertRecordEncodableTests.swift | 2 +- .../InsertRecordOptimizedTests.swift | 2 +- .../InsertRecordStructTests.swift | 2 +- Tests/generatePerformanceReport.rb | 20 +++++++++---------- 13 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Tests/Performance/GRDBPerformance/FetchNamedValuesTests.swift b/Tests/Performance/GRDBPerformance/FetchNamedValuesTests.swift index 31accf5c2..91edbada0 100644 --- a/Tests/Performance/GRDBPerformance/FetchNamedValuesTests.swift +++ b/Tests/Performance/GRDBPerformance/FetchNamedValuesTests.swift @@ -4,7 +4,7 @@ import GRDB import SQLite #endif -private let expectedRowCount = 100_000 +private let expectedRowCount = 200_000 /// Here we test the extraction of row values by column name. class FetchNamedValuesTests: XCTestCase { diff --git a/Tests/Performance/GRDBPerformance/FetchPositionalValuesTests.swift b/Tests/Performance/GRDBPerformance/FetchPositionalValuesTests.swift index 216a4e07c..90f39ded9 100644 --- a/Tests/Performance/GRDBPerformance/FetchPositionalValuesTests.swift +++ b/Tests/Performance/GRDBPerformance/FetchPositionalValuesTests.swift @@ -4,7 +4,7 @@ import GRDB import SQLite #endif -private let expectedRowCount = 100_000 +private let expectedRowCount = 200_000 /// Here we test the extraction of row values by column index. class FetchPositionalValuesTests: XCTestCase { diff --git a/Tests/Performance/GRDBPerformance/FetchRecordClassTests.swift b/Tests/Performance/GRDBPerformance/FetchRecordClassTests.swift index 96257b0d6..b2a13dbdb 100644 --- a/Tests/Performance/GRDBPerformance/FetchRecordClassTests.swift +++ b/Tests/Performance/GRDBPerformance/FetchRecordClassTests.swift @@ -5,7 +5,7 @@ import CoreData import RealmSwift #endif -private let expectedRowCount = 100_000 +private let expectedRowCount = 200_000 /// Here we test the extraction of model objects able to tell if they were /// modified since last fetched from the database. diff --git a/Tests/Performance/GRDBPerformance/FetchRecordDecodableTests.swift b/Tests/Performance/GRDBPerformance/FetchRecordDecodableTests.swift index 1deb6f675..03e9c7aaa 100644 --- a/Tests/Performance/GRDBPerformance/FetchRecordDecodableTests.swift +++ b/Tests/Performance/GRDBPerformance/FetchRecordDecodableTests.swift @@ -1,7 +1,7 @@ import XCTest import GRDB -private let expectedRowCount = 100_000 +private let expectedRowCount = 200_000 /// Here we test the extraction of Decodable GRDB records. class FetchRecordDecodableTests: XCTestCase { diff --git a/Tests/Performance/GRDBPerformance/FetchRecordOptimizedTests.swift b/Tests/Performance/GRDBPerformance/FetchRecordOptimizedTests.swift index db6d4c14d..9921c19d8 100644 --- a/Tests/Performance/GRDBPerformance/FetchRecordOptimizedTests.swift +++ b/Tests/Performance/GRDBPerformance/FetchRecordOptimizedTests.swift @@ -1,7 +1,7 @@ import XCTest import GRDB -private let expectedRowCount = 100_000 +private let expectedRowCount = 200_000 /// A record optimized for fetching performance private struct Item: Codable, FetchableRecord, PersistableRecord { diff --git a/Tests/Performance/GRDBPerformance/FetchRecordStructTests.swift b/Tests/Performance/GRDBPerformance/FetchRecordStructTests.swift index 7b78b61b7..a8b734954 100644 --- a/Tests/Performance/GRDBPerformance/FetchRecordStructTests.swift +++ b/Tests/Performance/GRDBPerformance/FetchRecordStructTests.swift @@ -4,7 +4,7 @@ import GRDB import SQLite #endif -private let expectedRowCount = 100_000 +private let expectedRowCount = 200_000 private struct Item { var i0: Int diff --git a/Tests/Performance/GRDBPerformance/InsertNamedValuesTests.swift b/Tests/Performance/GRDBPerformance/InsertNamedValuesTests.swift index b0e321b7b..bb607db7c 100644 --- a/Tests/Performance/GRDBPerformance/InsertNamedValuesTests.swift +++ b/Tests/Performance/GRDBPerformance/InsertNamedValuesTests.swift @@ -4,7 +4,7 @@ import GRDB import SQLite #endif -private let insertedRowCount = 20_000 +private let insertedRowCount = 50_000 // Here we insert rows, referencing statement arguments by name. class InsertNamedValuesTests: XCTestCase { diff --git a/Tests/Performance/GRDBPerformance/InsertPositionalValuesTests.swift b/Tests/Performance/GRDBPerformance/InsertPositionalValuesTests.swift index e3bd97873..382c6b516 100644 --- a/Tests/Performance/GRDBPerformance/InsertPositionalValuesTests.swift +++ b/Tests/Performance/GRDBPerformance/InsertPositionalValuesTests.swift @@ -4,7 +4,7 @@ import GRDB import SQLite #endif -private let insertedRowCount = 20_000 +private let insertedRowCount = 50_000 // Here we insert rows, referencing statement arguments by index. class InsertPositionalValuesTests: XCTestCase { diff --git a/Tests/Performance/GRDBPerformance/InsertRecordClassTests.swift b/Tests/Performance/GRDBPerformance/InsertRecordClassTests.swift index a936c8838..1bd3349c6 100644 --- a/Tests/Performance/GRDBPerformance/InsertRecordClassTests.swift +++ b/Tests/Performance/GRDBPerformance/InsertRecordClassTests.swift @@ -5,7 +5,7 @@ import CoreData import RealmSwift #endif -private let insertedRowCount = 20_000 +private let insertedRowCount = 50_000 // Here we insert record classes. class InsertRecordClassTests: XCTestCase { diff --git a/Tests/Performance/GRDBPerformance/InsertRecordEncodableTests.swift b/Tests/Performance/GRDBPerformance/InsertRecordEncodableTests.swift index 7879f133a..479b966af 100644 --- a/Tests/Performance/GRDBPerformance/InsertRecordEncodableTests.swift +++ b/Tests/Performance/GRDBPerformance/InsertRecordEncodableTests.swift @@ -1,7 +1,7 @@ import XCTest import GRDB -private let insertedRowCount = 20_000 +private let insertedRowCount = 50_000 // Here we insert records. class InsertRecordEncodableTests: XCTestCase { diff --git a/Tests/Performance/GRDBPerformance/InsertRecordOptimizedTests.swift b/Tests/Performance/GRDBPerformance/InsertRecordOptimizedTests.swift index 9735b512c..b0bf10bce 100644 --- a/Tests/Performance/GRDBPerformance/InsertRecordOptimizedTests.swift +++ b/Tests/Performance/GRDBPerformance/InsertRecordOptimizedTests.swift @@ -1,7 +1,7 @@ import XCTest import GRDB -private let insertedRowCount = 20_000 +private let insertedRowCount = 50_000 /// A record optimized for batch insert performance private struct Item: Codable, FetchableRecord, PersistableRecord { diff --git a/Tests/Performance/GRDBPerformance/InsertRecordStructTests.swift b/Tests/Performance/GRDBPerformance/InsertRecordStructTests.swift index 3a055537d..b94e2d584 100644 --- a/Tests/Performance/GRDBPerformance/InsertRecordStructTests.swift +++ b/Tests/Performance/GRDBPerformance/InsertRecordStructTests.swift @@ -1,7 +1,7 @@ import XCTest import GRDB -private let insertedRowCount = 20_000 +private let insertedRowCount = 50_000 // Here we insert records. class InsertRecordStructTests: XCTestCase { diff --git a/Tests/generatePerformanceReport.rb b/Tests/generatePerformanceReport.rb index 1dcb8cd83..0b542aed2 100755 --- a/Tests/generatePerformanceReport.rb +++ b/Tests/generatePerformanceReport.rb @@ -115,13 +115,13 @@ As a bottom line, the raw SQLite C API is used as efficiently as possible, witho - **Fetch** ([source](https://github.com/groue/GRDB.swift/blob/master/Tests/Performance/GRDBPerformance/FetchPositionalValuesTests.swift)) - This test fetches 100000 rows of 10 ints and extracts each int given its position in the row. + This test fetches 200000 rows of 10 ints and extracts each int given its position in the row. It uses FMDB's `-[FMResultSet longForColumnIndex:]`, GRDB's `Row.value(atIndex:)`, and the low-level SQL API of SQLite.swift. - **Insert** ([source](https://github.com/groue/GRDB.swift/blob/master/Tests/Performance/GRDBPerformance/InsertPositionalValuesTests.swift)) - This test inserts 20000 rows of 10 ints, by setting query arguments given their position. + This test inserts 50000 rows of 10 ints, by setting query arguments given their position. It uses FMDB's `-[FMDatabase executeUpdate:withArgumentsInArray:]` with statement caching, GRDB's `UpdateStatement.execute(arguments:Array)`, and the low-level SQL API of SQLite.swift. @@ -129,13 +129,13 @@ As a bottom line, the raw SQLite C API is used as efficiently as possible, witho - **Fetch** ([source](https://github.com/groue/GRDB.swift/blob/master/Tests/Performance/GRDBPerformance/FetchNamedValuesTests.swift)) - This test fetches 100000 rows of 10 ints and extracts each int given its column name. + This test fetches 200000 rows of 10 ints and extracts each int given its column name. It uses FMDB's `-[FMResultSet longForColumn:]`, GRDB's `Row.value(named:)`, and the high-level query builder of SQLite.swift. - **Insert** ([source](https://github.com/groue/GRDB.swift/blob/master/Tests/Performance/GRDBPerformance/InsertNamedValuesTests.swift)) - This test inserts 20000 rows of 10 ints, by setting query arguments given their argument name. + This test inserts 50000 rows of 10 ints, by setting query arguments given their argument name. It uses FMDB's `-[FMDatabase executeUpdate:withParameterDictionary:]` with statement caching, GRDB's `UpdateStatement.execute(arguments:Dictionary)`, and the high-level query builder of SQLite.swift. @@ -143,25 +143,25 @@ As a bottom line, the raw SQLite C API is used as efficiently as possible, witho - **Fetch** ([source](https://github.com/groue/GRDB.swift/blob/master/Tests/Performance/GRDBPerformance/FetchRecordStructTests.swift)) - This test fetches an array of 100000 record objects initiated from rows of 10 ints. + This test fetches an array of 200000 record objects initiated from rows of 10 ints. It builds records from FMDB's `-[FMResultSet resultDictionary]`, GRDB's built-in [FetchableRecord](https://github.com/groue/GRDB.swift/blob/master/README.md#fetchablerecord-protocol) protocol, and the values returned by the high-level query builder of SQLite.swift. - **Insert** ([source](https://github.com/groue/GRDB.swift/blob/master/Tests/Performance/GRDBPerformance/InsertRecordStructTests.swift)) - This tests inserts 20000 records with the persistence method provided by GRDB's [PersistableRecord](https://github.com/groue/GRDB.swift/blob/master/README.md#persistablerecord-protocol) protocol. + This tests inserts 50000 records with the persistence method provided by GRDB's [PersistableRecord](https://github.com/groue/GRDB.swift/blob/master/README.md#persistablerecord-protocol) protocol. - **Codable Records**: - **Fetch** ([source](https://github.com/groue/GRDB.swift/blob/master/Tests/Performance/GRDBPerformance/FetchRecordDecodableTests.swift)) - This test fetches an array of 100000 record objects initiated from rows of 10 ints. + This test fetches an array of 200000 record objects initiated from rows of 10 ints. It builds records from GRDB's built-in support for the [Decodable standard protocols](https://github.com/groue/GRDB.swift/blob/master/README.md#codable-records). - **Insert** ([source](https://github.com/groue/GRDB.swift/blob/master/Tests/Performance/GRDBPerformance/InsertRecordEncodableTests.swift)) - This tests inserts 20000 records with the persistence method provided by GRDB's built-in support for the [Encodable standard protocols](https://github.com/groue/GRDB.swift/blob/master/README.md#codable-records). + This tests inserts 50000 records with the persistence method provided by GRDB's built-in support for the [Encodable standard protocols](https://github.com/groue/GRDB.swift/blob/master/README.md#codable-records). - **Optimized Records**: @@ -177,11 +177,11 @@ As a bottom line, the raw SQLite C API is used as efficiently as possible, witho - **Fetch** ([source](https://github.com/groue/GRDB.swift/blob/master/Tests/Performance/GRDBPerformance/FetchRecordClassTests.swift)) - This test fetches an array of 100000 record objects initiated from rows of 10 ints. + This test fetches an array of 200000 record objects initiated from rows of 10 ints. It builds records from FMDB's `-[FMResultSet resultDictionary]`, GRDB's built-in [Record](https://github.com/groue/GRDB.swift/blob/master/README.md#record-class) class. - **Insert** ([source](https://github.com/groue/GRDB.swift/blob/master/Tests/Performance/GRDBPerformance/InsertRecordClassTests.swift)) - This tests inserts 20000 records with the persistence method provided by GRDB's [Record](https://github.com/groue/GRDB.swift/blob/master/README.md#record-class) class. + This tests inserts 50000 records with the persistence method provided by GRDB's [Record](https://github.com/groue/GRDB.swift/blob/master/README.md#record-class) class. REPORT From fe32981e0ebdb31eea8e7ee1cb5a3ab3a9d2d1dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 7 Nov 2021 16:04:58 +0100 Subject: [PATCH 4/6] Performance report: fallback for hardware name The https://apple.stackexchange.com/a/98089 technique does not work on my mac --- Tests/generatePerformanceReport.rb | 43 ++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/Tests/generatePerformanceReport.rb b/Tests/generatePerformanceReport.rb index 0b542aed2..ec8ae5286 100755 --- a/Tests/generatePerformanceReport.rb +++ b/Tests/generatePerformanceReport.rb @@ -51,18 +51,33 @@ DERIVED_DATA = tmp SPM_CHECKOUTS = File.join(DERIVED_DATA, 'SourcePackages', 'checkouts') # Extract versions -grdb_version = info_plist_version('Support/Info.plist') -fmdb_version = info_plist_version("#{SPM_CHECKOUTS}/fmdb/src/fmdb/Info.plist") -sqlite_swift_version = git_tag_version("#{SPM_CHECKOUTS}/SQLite.swift") -realm_version = git_tag_version("#{SPM_CHECKOUTS}/realm-cocoa") -`xcodebuild -version` =~ /Xcode (.*)$/; xcode_version = $1 -`curl -s https://support-sp.apple.com/sp/product?cc=$(system_profiler SPHardwareDataType | awk '/Serial/ {print $4}' | cut -c 9-)` =~ /(.*)<\/configCode>/; hardware = $1 -STDERR.puts "GRDB #{grdb_version}" -STDERR.puts "FMDB #{fmdb_version}" -STDERR.puts "SQLite.swift #{sqlite_swift_version}" -STDERR.puts "Realm #{realm_version}" -STDERR.puts "Xcode #{xcode_version}" -STDERR.puts "Hardware #{hardware}" +GRDB_VERSION = info_plist_version('Support/Info.plist') +FMDB_VERSION = info_plist_version("#{SPM_CHECKOUTS}/fmdb/src/fmdb/Info.plist") +SQLITE_SWIFT_VERSION = git_tag_version("#{SPM_CHECKOUTS}/SQLite.swift") +REALM_VERSION = git_tag_version("#{SPM_CHECKOUTS}/realm-cocoa") + +`xcodebuild -version` =~ /Xcode (.*)$/ +XCODE_VERSION = $1 + +# Hardware name: https://apple.stackexchange.com/a/98089 +`curl -s https://support-sp.apple.com/sp/product?cc=$( + system_profiler SPHardwareDataType \ + | awk '/Serial/ {print $4}' \ + | cut -c 9-)` =~ /(.*)<\/configCode>/ +hardware = $1 +if hardware + HARDWARE = hardware +else + # in case the previous technique does not work + HARDWARE = `system_profiler SPHardwareDataType | awk '/Model Identifier/ {print $3}'`.chomp +end + +STDERR.puts "GRDB_VERSION: #{GRDB_VERSION}" +STDERR.puts "FMDB_VERSION: #{FMDB_VERSION}" +STDERR.puts "SQLITE_SWIFT_VERSION: #{SQLITE_SWIFT_VERSION}" +STDERR.puts "REALM_VERSION: #{REALM_VERSION}" +STDERR.puts "XCODE_VERSION: #{XCODE_VERSION}" +STDERR.puts "HARDWARE: #{HARDWARE}" # Generate puts <<-REPORT @@ -70,9 +85,9 @@ puts <<-REPORT *Last updated #{Date.today.strftime('%B %-d, %Y')}* -Below are performance benchmarks made on for [GRDB #{grdb_version}](https://github.com/groue/GRDB.swift), [FMDB #{fmdb_version}](https://github.com/ccgus/fmdb), and [SQLite.swift #{sqlite_swift_version}](https://github.com/stephencelis/SQLite.swift). They are compared to Core Data, [Realm #{realm_version}](https://realm.io) and the raw use of the SQLite C API from Swift. +Below are performance benchmarks made on for [GRDB #{GRDB_VERSION}](https://github.com/groue/GRDB.swift), [FMDB #{FMDB_VERSION}](https://github.com/ccgus/fmdb), and [SQLite.swift #{SQLITE_SWIFT_VERSION}](https://github.com/stephencelis/SQLite.swift). They are compared to Core Data, [Realm #{REALM_VERSION}](https://realm.io) and the raw use of the SQLite C API from Swift. -This report was generated on a #{hardware}, with Xcode #{xcode_version}, by running the following command: +This report was generated on a #{HARDWARE}, with Xcode #{XCODE_VERSION}, by running the following command: ```sh make test_performance | Tests/parsePerformanceTests.rb | Tests/generatePerformanceReport.rb From 42eeb54d6f48ad8b8e56fbe447a91659ee1fee2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 7 Nov 2021 14:53:42 +0100 Subject: [PATCH 5/6] v5.13.0 --- CHANGELOG.md | 5 +++- Documentation/FullTextSearch.md | 4 ++-- Documentation/Migrations.md | 2 +- GRDB.swift.podspec | 2 +- Makefile | 6 ++--- README.md | 42 ++++++++++++++++----------------- Support/Info.plist | 2 +- 7 files changed, 33 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3c0a4e63..bafd7f8a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception: #### 5.x Releases +- `5.13.x` Releases - [5.13.0](#5130) - `5.12.x` Releases - [5.12.0](#5120) - `5.11.x` Releases - [5.11.0](#5110) - `5.10.x` Releases - [5.10.0](#5100) @@ -79,7 +80,9 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception: --- -## Next Release +## 5.13.0 + +Released November 7, 2021 • [diff](https://github.com/groue/GRDB.swift/compare/v5.12.0...v5.13.0) - **Breaking Change**: [#1076](https://github.com/groue/GRDB.swift/pull/1076) by [@groue](https://github.com/groue): Require Swift 5.3 and Xcode 12 - **New**: :star: [#1088](https://github.com/groue/GRDB.swift/pull/1088) by [@groue](https://github.com/groue): Shared ValueObservation diff --git a/Documentation/FullTextSearch.md b/Documentation/FullTextSearch.md index 9233f4ed7..45f214571 100644 --- a/Documentation/FullTextSearch.md +++ b/Documentation/FullTextSearch.md @@ -304,7 +304,7 @@ let pattern = FTS3Pattern(matchingAnyTokenIn: "") // nil let pattern = FTS3Pattern(matchingAnyTokenIn: "*") // nil ``` -FTS3Pattern are regular [values](../README.md#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/5.12/Structs/StatementArguments.html): +FTS3Pattern are regular [values](../README.md#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/5.13/Structs/StatementArguments.html): ```swift let documents = try Document.fetchAll(db, @@ -587,7 +587,7 @@ let pattern = FTS5Pattern(matchingAnyTokenIn: "") // nil let pattern = FTS5Pattern(matchingAnyTokenIn: "*") // nil ``` -FTS5Pattern are regular [values](../README.md#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/5.12/Structs/StatementArguments.html): +FTS5Pattern are regular [values](../README.md#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/5.13/Structs/StatementArguments.html): ```swift let documents = try Document.fetchAll(db, diff --git a/Documentation/Migrations.md b/Documentation/Migrations.md index 5a1450486..abee19b36 100644 --- a/Documentation/Migrations.md +++ b/Documentation/Migrations.md @@ -77,7 +77,7 @@ try dbQueue.read { db in } ``` -See the [DatabaseMigrator reference](http://groue.github.io/GRDB.swift/docs/5.12/Structs/DatabaseMigrator.html) for more migrator methods. +See the [DatabaseMigrator reference](http://groue.github.io/GRDB.swift/docs/5.13/Structs/DatabaseMigrator.html) for more migrator methods. ## The `eraseDatabaseOnSchemaChange` Option diff --git a/GRDB.swift.podspec b/GRDB.swift.podspec index a9f143c6a..9a551333e 100644 --- a/GRDB.swift.podspec +++ b/GRDB.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'GRDB.swift' - s.version = '5.12.0' + s.version = '5.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 e5360088d..9b2bf4a4f 100644 --- a/Makefile +++ b/Makefile @@ -488,10 +488,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/v5.12.0 \ - --module-version 5.12.0 \ + --github-file-prefix https://github.com/groue/GRDB.swift/tree/v5.13.0 \ + --module-version 5.13.0 \ --module GRDB \ - --root-url http://groue.github.io/GRDB.swift/docs/5.12/ \ + --root-url http://groue.github.io/GRDB.swift/docs/5.13/ \ --output Documentation/Reference \ --xcodebuild-arguments -project,GRDB.xcodeproj,-scheme,GRDBiOS else diff --git a/README.md b/README.md index 9ed964f56..7a183b65d 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ --- -**Latest release**: September 25, 2021 • version 5.12.0 • [CHANGELOG](CHANGELOG.md) • [Migrating From GRDB 4 to GRDB 5](Documentation/GRDB5MigrationGuide.md) +**Latest release**: November 7, 2021 • version 5.13.0 • [CHANGELOG](CHANGELOG.md) • [Migrating From GRDB 4 to GRDB 5](Documentation/GRDB5MigrationGuide.md) **Requirements**: iOS 11.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+ • SQLite 3.8.5+ • Swift 5.3+ / Xcode 12+ @@ -317,7 +317,7 @@ Documentation #### Reference -- [GRDB Reference](http://groue.github.io/GRDB.swift/docs/5.12/index.html) (generated by [Jazzy](https://github.com/realm/jazzy)) +- [GRDB Reference](http://groue.github.io/GRDB.swift/docs/5.13/index.html) (generated by [Jazzy](https://github.com/realm/jazzy)) #### Getting Started @@ -511,7 +511,7 @@ let dbQueue = try DatabaseQueue( configuration: config) ``` -See [Configuration](http://groue.github.io/GRDB.swift/docs/5.12/Structs/Configuration.html) for more details. +See [Configuration](http://groue.github.io/GRDB.swift/docs/5.13/Structs/Configuration.html) for more details. ## Database Pools @@ -591,7 +591,7 @@ let dbPool = try DatabasePool( configuration: config) ``` -See [Configuration](http://groue.github.io/GRDB.swift/docs/5.12/Structs/Configuration.html) for more details. +See [Configuration](http://groue.github.io/GRDB.swift/docs/5.13/Structs/Configuration.html) for more details. Database pools are more memory-hungry than database queues. See [Memory Management](#memory-management) for more information. @@ -651,7 +651,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/5.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/5.13/Structs/StatementArguments.html) for a detailed documentation of SQLite arguments. You can also embed query arguments right into your SQL queries, with the `literal` argument label, as in the example below. See [SQL Interpolation] for more details. @@ -909,7 +909,7 @@ try dbQueue.read { db in let dictionary = try Dictionary(uniqueKeysWithValues: cursor) ``` -- **Cursors adopt the [Cursor](http://groue.github.io/GRDB.swift/docs/5.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/5.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 @@ -988,7 +988,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/5.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/5.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: @@ -1273,7 +1273,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/5.12/Structs/StatementArguments.html): +Values can be used as [statement arguments](http://groue.github.io/GRDB.swift/docs/5.13/Structs/StatementArguments.html): ```swift let url: URL = ... @@ -1720,7 +1720,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/5.12/Structs/Configuration.html) configuration flag: +Transactions can't be left opened unless you set the [allowsUnsafeTransactions](http://groue.github.io/GRDB.swift/docs/5.13/Structs/Configuration.html) configuration flag: ```swift // fatal error: A transaction has been left opened at the end of a database access @@ -1832,7 +1832,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/5.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/5.13/Structs/StatementArguments.html), which happens to adopt the ExpressibleByArrayLiteral and ExpressibleByDictionaryLiteral protocols). ```swift insertStatement.arguments = ["name": "Arthur", "score": 1000] @@ -1915,7 +1915,7 @@ See also `Database.execute(sql:)` in the [Executing Updates](#executing-updates) > :point_up: **Note**: it is a programmer error to reuse a prepared statement that has failed: GRDB may crash if you do so. -For more information about prepared statements, see the [Statement reference](http://groue.github.io/GRDB.swift/docs/5.12/Classes/Statement.html). +For more information about prepared statements, see the [Statement reference](http://groue.github.io/GRDB.swift/docs/5.13/Classes/Statement.html). ### Prepared Statements Cache @@ -2658,7 +2658,7 @@ try Place.fetchSet(db, sql: "SELECT ...", arguments:...) // Set try Place.fetchOne(db, sql: "SELECT ...", arguments:...) // Place? ``` -See [fetching methods](#fetching-methods) for information about the `fetchCursor`, `fetchAll`, `fetchSet` and `fetchOne` methods. See [StatementArguments](http://groue.github.io/GRDB.swift/docs/5.12/Structs/StatementArguments.html) for more information about the query arguments. +See [fetching methods](#fetching-methods) for information about the `fetchCursor`, `fetchAll`, `fetchSet` and `fetchOne` methods. See [StatementArguments](http://groue.github.io/GRDB.swift/docs/5.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()`. @@ -3098,7 +3098,7 @@ protocol EncodableRecord { } ``` -See [DatabaseColumnDecodingStrategy](https://groue.github.io/GRDB.swift/docs/5.12/Enums/DatabaseColumnDecodingStrategy.html) and [DatabaseColumnEncodingStrategy](https://groue.github.io/GRDB.swift/docs/5.12/Enums/DatabaseColumnEncodingStrategy.html) to learn about all available strategies. +See [DatabaseColumnDecodingStrategy](https://groue.github.io/GRDB.swift/docs/5.13/Enums/DatabaseColumnDecodingStrategy.html) and [DatabaseColumnEncodingStrategy](https://groue.github.io/GRDB.swift/docs/5.13/Enums/DatabaseColumnEncodingStrategy.html) to learn about all available strategies. ### Date and UUID Coding Strategies @@ -3120,7 +3120,7 @@ protocol EncodableRecord { } ``` -See [DatabaseDateDecodingStrategy](https://groue.github.io/GRDB.swift/docs/5.12/Enums/DatabaseDateDecodingStrategy.html), [DatabaseDateEncodingStrategy](https://groue.github.io/GRDB.swift/docs/5.12/Enums/DatabaseDateEncodingStrategy.html), and [DatabaseUUIDEncodingStrategy](https://groue.github.io/GRDB.swift/docs/5.12/Enums/DatabaseUUIDEncodingStrategy.html) to learn about all available strategies. +See [DatabaseDateDecodingStrategy](https://groue.github.io/GRDB.swift/docs/5.13/Enums/DatabaseDateDecodingStrategy.html), [DatabaseDateEncodingStrategy](https://groue.github.io/GRDB.swift/docs/5.13/Enums/DatabaseDateEncodingStrategy.html), and [DatabaseUUIDEncodingStrategy](https://groue.github.io/GRDB.swift/docs/5.13/Enums/DatabaseUUIDEncodingStrategy.html) to learn about all available strategies. There is no customization of uuid decoding, because UUID can already decode all its encoded variants (16-bytes blobs and uuid strings, both uppercase and lowercase). @@ -4642,7 +4642,7 @@ Player // SELECT * FROM player ``` -Raw SQL snippets are also accepted, with eventual [arguments](http://groue.github.io/GRDB.swift/docs/5.12/Structs/StatementArguments.html): +Raw SQL snippets are also accepted, with eventual [arguments](http://groue.github.io/GRDB.swift/docs/5.13/Structs/StatementArguments.html): ```swift // SELECT DATE(creationDate), COUNT(*) FROM player WHERE name = 'Arthur' GROUP BY date(creationDate) @@ -5410,7 +5410,7 @@ try Player.customRequest().fetchAll(db) // [Player] - 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/5.12/Structs/AnyFetchRequest.html): a type-erased request. +- [AnyFetchRequest](http://groue.github.io/GRDB.swift/docs/5.13/Structs/AnyFetchRequest.html): a type-erased request. ## Joined Queries Support @@ -6665,7 +6665,7 @@ After `stopObservingDatabaseChangesUntilNextTransaction()`, the `databaseDidChan ### DatabaseRegion -**[DatabaseRegion](https://groue.github.io/GRDB.swift/docs/5.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/5.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. @@ -6675,7 +6675,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/5.12/Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV10isModified2bySbAA0B5EventV_tF). +For more details, see the [reference](http://groue.github.io/GRDB.swift/docs/5.13/Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV10isModified2bySbAA0B5EventV_tF). #### The DatabaseRegionConvertible Protocol @@ -7943,7 +7943,7 @@ When this is the case, there are two possible explanations: try db.execute(sql: "UPDATE player SET name = ?", arguments: [name]) ``` -For more information, see [Double-quoted String Literals Are Accepted](https://sqlite.org/quirks.html#dblquote), and [Configuration.acceptsDoubleQuotedStringLiterals](http://groue.github.io/GRDB.swift/docs/5.12/Structs/Configuration.html#/s:4GRDB13ConfigurationV33acceptsDoubleQuotedStringLiteralsSbvp). +For more information, see [Double-quoted String Literals Are Accepted](https://sqlite.org/quirks.html#dblquote), and [Configuration.acceptsDoubleQuotedStringLiterals](http://groue.github.io/GRDB.swift/docs/5.13/Structs/Configuration.html#/s:4GRDB13ConfigurationV33acceptsDoubleQuotedStringLiteralsSbvp). @@ -8084,7 +8084,7 @@ This chapter has [moved](Documentation/Concurrency.md#database-snapshots). #### DatabaseWriter and DatabaseReader Protocols -This chapter was removed. See the references of [DatabaseReader](http://groue.github.io/GRDB.swift/docs/5.12/Protocols/DatabaseReader.html) and [DatabaseWriter](http://groue.github.io/GRDB.swift/docs/5.12/Protocols/DatabaseWriter.html). +This chapter was removed. See the references of [DatabaseReader](http://groue.github.io/GRDB.swift/docs/5.13/Protocols/DatabaseReader.html) and [DatabaseWriter](http://groue.github.io/GRDB.swift/docs/5.13/Protocols/DatabaseWriter.html). #### Asynchronous APIs @@ -8132,7 +8132,7 @@ This chapter has [moved](Documentation/Concurrency.md#safe-and-unsafe-database-a [Sharing a Database]: Documentation/SharingADatabase.md [FAQ]: #faq [Database Observation]: #database-changes-observation -[SQLRequest]: http://groue.github.io/GRDB.swift/docs/5.12/Structs/SQLRequest.html +[SQLRequest]: http://groue.github.io/GRDB.swift/docs/5.13/Structs/SQLRequest.html [SQL literal]: Documentation/SQLInterpolation.md#sql-literal [Identifiable]: https://developer.apple.com/documentation/swift/identifiable [Query Interface Organization]: Documentation/QueryInterfaceOrganization.md diff --git a/Support/Info.plist b/Support/Info.plist index 6aa6195ad..927c076bd 100644 --- a/Support/Info.plist +++ b/Support/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 5.12.0 + 5.13.0 CFBundleSignature ???? CFBundleVersion From 59f9482aa7f4a4fcc60a46e42eac2cce79821437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 7 Nov 2021 16:29:17 +0100 Subject: [PATCH 6/6] Fix links to documentation images --- Documentation/Concurrency.md | 8 ++++---- Documentation/QueryInterfaceOrganization.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation/Concurrency.md b/Documentation/Concurrency.md index 9f27bdf5f..da6d59b5f 100644 --- a/Documentation/Concurrency.md +++ b/Documentation/Concurrency.md @@ -321,11 +321,11 @@ Despite the common [guarantees](#safe-and-unsafe-database-accesses) and [rules]( [DatabaseQueue] opens a single database connection, and serializes all database accesses, reads, and writes. There is never more than one thread that uses the database. In the image below, we see how three threads can see the database as time passes: -![DatabaseQueueScheduling](https://cdn.rawgit.com/groue/GRDB.swift/development/Documentation/Images/DatabaseQueueScheduling.svg) +![DatabaseQueueScheduling](https://cdn.rawgit.com/groue/GRDB.swift/master/Documentation/Images/DatabaseQueueScheduling.svg) [DatabasePool] manages a pool of several database connections, and allows concurrent reads and writes thanks to the [WAL mode](https://www.sqlite.org/wal.html). A database pool serializes all writes (the [Serialized Writes] guarantee). Reads are isolated so that they don't see changes performed by other threads (the [Isolated Reads] guarantee). This gives a very different picture: -![DatabasePoolScheduling](https://cdn.rawgit.com/groue/GRDB.swift/development/Documentation/Images/DatabasePoolScheduling.svg) +![DatabasePoolScheduling](https://cdn.rawgit.com/groue/GRDB.swift/master/Documentation/Images/DatabasePoolScheduling.svg) See how, with database pools, two reads can see different database states at the same time. This may look scary! Please see the next [Concurrent Thinking] chapter below for a relief. @@ -345,7 +345,7 @@ All you need is a little "concurrent thinking", based on those two basic facts: - Whenever you extract some data from a database access, immediately consider it as _stale_. It is stale, whether you use a database queue or a database pool. It is stale because nothing prevents other application threads or processes from overwriting the value you have just fetched: - + ```swift // or dbQueue.write, for that matter @@ -434,7 +434,7 @@ try dbPool.writeWithoutTransaction { db in In the illustration below, the striped band shows the delay needed for the reading thread to acquire isolation. Until then, no other thread can write: -![DatabasePoolConcurrentRead](https://cdn.rawgit.com/groue/GRDB.swift/development/Documentation/Images/DatabasePoolConcurrentRead.svg) +![DatabasePoolConcurrentRead](https://cdn.rawgit.com/groue/GRDB.swift/master/Documentation/Images/DatabasePoolConcurrentRead.svg) [Transaction Observers](../README.md#transactionobserver-protocol) can also use those methods in their `databaseDidCommit` method, in order to process database changes without blocking other threads that want to write into the database. diff --git a/Documentation/QueryInterfaceOrganization.md b/Documentation/QueryInterfaceOrganization.md index 7f6a6ddec..8e257db2e 100644 --- a/Documentation/QueryInterfaceOrganization.md +++ b/Documentation/QueryInterfaceOrganization.md @@ -7,7 +7,7 @@ This document exposes its inner organization, so that you can leverage the most In the diagram below, protocols are pale blue and have rounded corners, and standard types are grey rectangles. Solid arrows read "inherits from", and dashed arrows read "produces". Generic types are marked as such, as well as "PATs" (protocols with associated types). - + Diagram items are described below: