diff --git a/CHANGELOG.md b/CHANGELOG.md index 33c757cf0..41da8c04d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -160,6 +160,20 @@ Release Notes ``` +## 2.10.0 + +Released March 30, 2018 • [diff](https://github.com/groue/GRDB.swift/compare/v2.9.0...v2.10.0) + +### New + +- Support for Swift 4.1 and Xcode 9.3 +- Added `Cursor.compactMap` ([SE-0187](https://github.com/apple/swift-evolution/blob/master/proposals/0187-introduce-filtermap.md)) + +### Deprecated + +- `Cursor.flatMap` is deprecated. Use `compactMap` instead. + + ## 2.9.0 Released February 25, 2018 • [diff](https://github.com/groue/GRDB.swift/compare/v2.8.0...v2.9.0) diff --git a/Documentation/CustomSQLiteBuilds.md b/Documentation/CustomSQLiteBuilds.md index e43d8cdec..c9f525457 100644 --- a/Documentation/CustomSQLiteBuilds.md +++ b/Documentation/CustomSQLiteBuilds.md @@ -15,7 +15,7 @@ GRDB builds SQLite with [swiftlyfalling/SQLiteLib](https://github.com/swiftlyfal ```sh cd [GRDB directory] - git checkout v2.9.0 + git checkout v2.10.0 git submodule update --init SQLiteCustom/src ```` diff --git a/GRDB.swift.podspec b/GRDB.swift.podspec index a72ea51e9..ec712b7d5 100644 --- a/GRDB.swift.podspec +++ b/GRDB.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'GRDB.swift' - s.version = '2.9.0' + s.version = '2.10.0' s.license = { :type => 'MIT', :file => 'LICENSE' } s.summary = 'A Swift application toolkit for SQLite databases.' diff --git a/GRDB.xcodeproj/project.pbxproj b/GRDB.xcodeproj/project.pbxproj index 3735d08d1..22486938e 100755 --- a/GRDB.xcodeproj/project.pbxproj +++ b/GRDB.xcodeproj/project.pbxproj @@ -940,8 +940,8 @@ 56B1C3CC201C8D0E001938DA /* Swift4.1.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Swift4.1.swift; sourceTree = ""; }; 56B7F4291BE14A1900E39BBF /* CGFloatTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGFloatTests.swift; sourceTree = ""; }; 56B7F4391BEB42D500E39BBF /* Migration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Migration.swift; sourceTree = ""; }; - 56B8C2401CA1758F00510325 /* Realm.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Realm.framework; path = "Realm/build/osx/swift-4.0.3/Realm.framework"; sourceTree = ""; }; - 56B8C2411CA1758F00510325 /* RealmSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RealmSwift.framework; path = "Realm/build/osx/swift-4.0.3/RealmSwift.framework"; sourceTree = ""; }; + 56B8C2401CA1758F00510325 /* Realm.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Realm.framework; path = "Realm/build/osx/swift-4.1/Realm.framework"; sourceTree = ""; }; + 56B8C2411CA1758F00510325 /* RealmSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RealmSwift.framework; path = "Realm/build/osx/swift-4.1/RealmSwift.framework"; sourceTree = ""; }; 56B8F49A1B4E2F3600C24296 /* GRDB.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = GRDB.xcconfig; sourceTree = ""; }; 56B9649C1DA51B4C0002DA19 /* FTS5.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5.swift; sourceTree = ""; }; 56B964B01DA51D010002DA19 /* FTS5TokenizerDescriptor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FTS5TokenizerDescriptor.swift; sourceTree = ""; }; @@ -2848,7 +2848,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Tests/Performance/Realm/build/osx/swift-4.0.3", + "$(PROJECT_DIR)/Tests/Performance/Realm/build/osx/swift-4.1", ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = Tests/Info.plist; @@ -2871,7 +2871,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/Tests/Performance/Realm/build/osx/swift-4.0.3", + "$(PROJECT_DIR)/Tests/Performance/Realm/build/osx/swift-4.1", ); GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = Tests/Info.plist; diff --git a/GRDB.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/GRDB.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/GRDB.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/GRDB/Core/Database.swift b/GRDB/Core/Database.swift index 0e0097db7..ad48f304e 100644 --- a/GRDB/Core/Database.swift +++ b/GRDB/Core/Database.swift @@ -841,8 +841,7 @@ extension Database { self.rawValue = rawValue } - #if swift(>=4.1) - #else + #if !swift(>=4.1) /// The hash value /// :nodoc: public var hashValue: Int { @@ -881,8 +880,7 @@ extension Database { self.rawValue = rawValue } - #if swift(>=4.1) - #else + #if !swift(>=4.1) /// The hash value /// :nodoc: public var hashValue: Int { diff --git a/GRDB/Core/DatabaseError.swift b/GRDB/Core/DatabaseError.swift index 4c6b39256..afa6cb5d9 100644 --- a/GRDB/Core/DatabaseError.swift +++ b/GRDB/Core/DatabaseError.swift @@ -139,8 +139,7 @@ public struct ResultCode : RawRepresentable, Equatable, CustomStringConvertible public static let SQLITE_OK_LOAD_PERMANENTLY = ResultCode(rawValue: (SQLITE_OK.rawValue | (1<<8))) } -#if swift(>=4.1) -#else +#if !swift(>=4.1) // Equatable extension ResultCode { /// :nodoc: diff --git a/GRDB/Core/DatabaseFunction.swift b/GRDB/Core/DatabaseFunction.swift index 702913cf7..873a3e922 100644 --- a/GRDB/Core/DatabaseFunction.swift +++ b/GRDB/Core/DatabaseFunction.swift @@ -11,8 +11,7 @@ public final class DatabaseFunction: Hashable { let name: String let nArg: Int32 // -1 for variadic functions - #if swift(>=4.1) - #else + #if !swift(>=4.1) var hashValue: Int { return name.hashValue ^ nArg.hashValue } diff --git a/GRDB/Core/DatabaseRegion.swift b/GRDB/Core/DatabaseRegion.swift index 8d4b140ad..678144fbf 100644 --- a/GRDB/Core/DatabaseRegion.swift +++ b/GRDB/Core/DatabaseRegion.swift @@ -255,8 +255,7 @@ private struct TableRegion: Equatable { return false } - #if swift(>=4.1) - #else + #if !swift(>=4.1) static func == (lhs: TableRegion, rhs: TableRegion) -> Bool { if lhs.columns != rhs.columns { return false } if lhs.rowIds != rhs.rowIds { return false } diff --git a/GRDB/Core/Statement.swift b/GRDB/Core/Statement.swift index 38873941d..b5bfa0dc1 100644 --- a/GRDB/Core/Statement.swift +++ b/GRDB/Core/Statement.swift @@ -903,8 +903,7 @@ extension StatementArguments { } } -#if swift(>=4.1) -#else +#if !swift(>=4.1) // Equatable extension StatementArguments { /// :nodoc: diff --git a/GRDB/Legacy/Swift4.1.swift b/GRDB/Legacy/Swift4.1.swift index 418865e83..c1adaac2f 100644 --- a/GRDB/Legacy/Swift4.1.swift +++ b/GRDB/Legacy/Swift4.1.swift @@ -1,7 +1,6 @@ // Compatibility layer for Swift < 4.1 -#if swift(>=4.1) -#else +#if !swift(>=4.1) extension Sequence { // From future import SE-0187 func compactMap(_ transform: (Self.Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult] { diff --git a/GRDB/QueryInterface/SQLExpression+QueryInterface.swift b/GRDB/QueryInterface/SQLExpression+QueryInterface.swift index 825774fde..ce34318f3 100644 --- a/GRDB/QueryInterface/SQLExpression+QueryInterface.swift +++ b/GRDB/QueryInterface/SQLExpression+QueryInterface.swift @@ -486,8 +486,7 @@ public struct SQLFunctionName : Hashable { self.sql = sql } - #if swift(>=4.1) - #else + #if !swift(>=4.1) /// The hash value /// /// :nodoc: diff --git a/GRDB/Record/PersistableRecord.swift b/GRDB/Record/PersistableRecord.swift index 067d65a14..bceff2f7a 100644 --- a/GRDB/Record/PersistableRecord.swift +++ b/GRDB/Record/PersistableRecord.swift @@ -985,8 +985,7 @@ private struct InsertQuery: Hashable { // Not generated by Swift 4.1 var hashValue: Int { return tableName.hashValue } - #if swift(>=4.1) - #else + #if !swift(>=4.1) static func == (lhs: InsertQuery, rhs: InsertQuery) -> Bool { if lhs.tableName != rhs.tableName { return false } if lhs.onConflict != rhs.onConflict { return false } @@ -1027,8 +1026,7 @@ private struct UpdateQuery: Hashable { // Not generated by Swift 4.1 var hashValue: Int { return tableName.hashValue } - #if swift(>=4.1) - #else + #if !swift(>=4.1) static func == (lhs: UpdateQuery, rhs: UpdateQuery) -> Bool { if lhs.tableName != rhs.tableName { return false } if lhs.onConflict != rhs.onConflict { return false } diff --git a/GRDBCipher.podspec b/GRDBCipher.podspec index cba39bfca..d63ad4227 100644 --- a/GRDBCipher.podspec +++ b/GRDBCipher.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'GRDBCipher' - s.version = '2.9.0' + s.version = '2.10.0' s.license = { :type => 'MIT', :file => 'LICENSE' } s.summary = 'A Swift application toolkit for SQLite databases.' diff --git a/GRDBCipher.xcodeproj/project.pbxproj b/GRDBCipher.xcodeproj/project.pbxproj index 9e732ebec..0018216b0 100755 --- a/GRDBCipher.xcodeproj/project.pbxproj +++ b/GRDBCipher.xcodeproj/project.pbxproj @@ -2827,6 +2827,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; @@ -2863,6 +2864,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCipherOSXTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; @@ -2899,6 +2901,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCipherOSXTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; @@ -2949,6 +2952,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SDKROOT = iphoneos; SKIP_INSTALL = YES; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -2986,6 +2990,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCipheriOSTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; @@ -3022,6 +3027,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCipheriOSEncryptedTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; @@ -3121,6 +3127,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MTL_ENABLE_DEBUG_INFO = NO; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_VERSION = 4.0; VALIDATE_PRODUCT = YES; diff --git a/GRDBCustom.xcodeproj/project.pbxproj b/GRDBCustom.xcodeproj/project.pbxproj index 92a5115ac..ec5d7b610 100755 --- a/GRDBCustom.xcodeproj/project.pbxproj +++ b/GRDBCustom.xcodeproj/project.pbxproj @@ -2287,6 +2287,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MTL_ENABLE_DEBUG_INFO = NO; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_VERSION = 4.0; VALIDATE_PRODUCT = YES; @@ -2343,6 +2344,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SDKROOT = iphoneos; SKIP_INSTALL = YES; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -2380,6 +2382,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCustomSQLite.GRDBCustomSQLiteiOSTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; @@ -2428,6 +2431,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; SKIP_INSTALL = YES; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; @@ -2466,6 +2470,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCustomSQLiteOSXTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; diff --git a/Makefile b/Makefile index 6f17fe493..847fc35ac 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,10 @@ TEST_ACTIONS = clean build build-for-testing test-without-building # xcodebuild destination to run tests on iOS 8.1 (requires a pre-installed simulator) MIN_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 4s,OS=8.1" -ifeq ($(XCODEVERSION),9.2) +# When adding support for an Xcode version, look for available devices with `instruments -s devices` +ifeq ($(XCODEVERSION),9.3) + MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 8,OS=11.3" +else ifeq ($(XCODEVERSION),9.2) MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 8,OS=11.2" else ifeq ($(XCODEVERSION),9.1) MAX_IOS_DESTINATION = "platform=iOS Simulator,name=iPhone 8,OS=11.1" @@ -251,10 +254,10 @@ test_performance: Realm FMDB SQLite.swift -scheme GRDBOSXPerformanceComparisonTests \ build-for-testing test-without-building -Realm: Tests/Performance/Realm/build/osx/swift-4.0.3/RealmSwift.framework +Realm: Tests/Performance/Realm/build/osx/swift-4.1/RealmSwift.framework # Makes sure the Tests/Performance/Realm submodule has been downloaded, and Realm framework has been built. -Tests/Performance/Realm/build/osx/swift-4.0.3/RealmSwift.framework: +Tests/Performance/Realm/build/osx/swift-4.1/RealmSwift.framework: $(GIT) submodule update --init --recursive Tests/Performance/Realm cd Tests/Performance/Realm && sh build.sh osx-swift @@ -303,10 +306,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/v2.9.0 \ - --module-version 2.9 \ + --github-file-prefix https://github.com/groue/GRDB.swift/tree/v2.10.0 \ + --module-version 2.10 \ --module GRDB \ - --root-url http://groue.github.io/GRDB.swift/docs/2.9/ \ + --root-url http://groue.github.io/GRDB.swift/docs/2.10/ \ --output Documentation/Reference \ --podspec GRDB.swift.podspec else diff --git a/README.md b/README.md index 448db7e93..fcf8263f5 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,13 @@ GRDB 2 [![Swift](https://img.shields.io/badge/swift-4-orange.svg?style=flat)](ht ### A toolkit for SQLite databases, with a focus on application development -**Latest release**: February 25, 2018 • version 2.9.0 • [CHANGELOG](CHANGELOG.md) +**Latest release**: March 30, 2018 • version 2.10.0 • [CHANGELOG](CHANGELOG.md) **Requirements**: iOS 8.0+ / OSX 10.9+ / watchOS 2.0+ • Swift 4+ / Xcode 9+ | Swift version | GRDB version | | ------------- | ----------------------------------------------------------- | -| **Swift 4** | **v2.9.0** | +| **Swift 4+** | **v2.10.0** | | Swift 3.2 | [v1.3.0](https://github.com/groue/GRDB.swift/tree/v1.3.0) | | Swift 3.1 | [v1.3.0](https://github.com/groue/GRDB.swift/tree/v1.3.0) | | Swift 3 | [v1.0](https://github.com/groue/GRDB.swift/tree/v1.0) | @@ -197,7 +197,7 @@ Documentation **Reference** -- [GRDB Reference](http://groue.github.io/GRDB.swift/docs/2.9/index.html) (generated by [Jazzy](https://github.com/realm/jazzy)) +- [GRDB Reference](http://groue.github.io/GRDB.swift/docs/2.10/index.html) (generated by [Jazzy](https://github.com/realm/jazzy)) **Getting Started** @@ -265,7 +265,7 @@ The [Swift Package Manager](https://swift.org/package-manager/) automates the di ```swift let package = Package( dependencies: [ - .package(url: "https://github.com/groue/GRDB.swift.git", from: "2.9.0") + .package(url: "https://github.com/groue/GRDB.swift.git", from: "2.10.0") ] ) ``` @@ -282,7 +282,7 @@ If you decide to use Carthage despite this warning, and get any Carthage-related ## Manually -1. [Download](https://github.com/groue/GRDB.swift/releases/tag/v2.9.0) a copy of GRDB, or clone its repository and make sure you use the latest tagged version with the `git checkout v2.9.0` command. +1. [Download](https://github.com/groue/GRDB.swift/releases/tag/v2.10.0) a copy of GRDB, or clone its repository and make sure you use the latest tagged version with the `git checkout v2.10.0` command. 2. Embed the `GRDB.xcodeproj` project in your own project. @@ -379,7 +379,7 @@ let dbQueue = try DatabaseQueue( configuration: config) ``` -See [Configuration](http://groue.github.io/GRDB.swift/docs/2.9/Structs/Configuration.html) for more details. +See [Configuration](http://groue.github.io/GRDB.swift/docs/2.10/Structs/Configuration.html) for more details. ## Database Pools @@ -462,7 +462,7 @@ let dbPool = try DatabasePool( configuration: config) ``` -See [Configuration](http://groue.github.io/GRDB.swift/docs/2.9/Structs/Configuration.html) for more details. +See [Configuration](http://groue.github.io/GRDB.swift/docs/2.10/Structs/Configuration.html) for more details. Database pools are more memory-hungry than database queues. See [Memory Management](#memory-management) for more information. @@ -646,7 +646,16 @@ try dbQueue.inDatabase { db in Both arrays and cursors can iterate over database results. How do you choose one or the other? Look at the differences: -- **Cursors can not be used on any thread**: you must consume a cursor on the dispatch queue it was created in. Arrays may be consumed on any thread. +- **Cursors can not be used on any thread**: you must consume a cursor on the dispatch queue it was created in, and you must not extract it. Arrays may be consumed on any thread: + + ```swift + // Wrong + let cursor = try dbQueue.inDatabase { try Player.fetchCursor($0, ...) } + + // OK + let array = try dbQueue.inDatabase { try Player.fetchAll($0, ...) } + ``` + - **Cursors can be iterated only one time.** Arrays can be iterated many times. - **Cursors iterate database results in a lazy fashion**, and don't consume much memory. Arrays contain copies of database values, and may take a lot of memory when there are many fetched results. - **Cursors are granted with direct access to SQLite,** unlike arrays that have to take the time to copy database values. When you really care about performance, you may want to deal with cursors of raw rows at the lowest possible level: `Row.fetchCursor(...)`. @@ -666,7 +675,7 @@ Both arrays and cursors can iterate over database results. How do you choose one If you don't see, or don't care about the difference, use arrays. If you care about memory and performance, use cursors when appropriate. -**All GRDB cursors adopt the [Cursor](http://groue.github.io/GRDB.swift/docs/2.9/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`: +**All GRDB cursors adopt the [Cursor](http://groue.github.io/GRDB.swift/docs/2.10/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 // All URL hosts @@ -739,7 +748,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/2.9/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/2.10/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: @@ -1010,7 +1019,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/2.9/Structs/StatementArguments.html): +Values can be used as [statement arguments](http://groue.github.io/GRDB.swift/docs/2.10/Structs/StatementArguments.html): ```swift let url: URL = ... @@ -1404,7 +1413,7 @@ try dbQueue.inDatabase { 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/2.9/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/2.10/Structs/StatementArguments.html), which happens to adopt the ExpressibleByArrayLiteral and ExpressibleByDictionaryLiteral protocols). ```swift updateStatement.arguments = ["name": "Arthur", "score": 1000] @@ -1668,7 +1677,7 @@ row["consumed"] // "Hello" row["produced"] // nil ``` -Row adapters are values that adopt the [RowAdapter](http://groue.github.io/GRDB.swift/docs/2.9/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/2.10/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). @@ -1811,8 +1820,8 @@ Before jumping in the low-level wagon, here is the list of all SQLite APIs used - `sqlite3_aggregate_context`, `sqlite3_create_function_v2`, `sqlite3_result_blob`, `sqlite3_result_double`, `sqlite3_result_error`, `sqlite3_result_error_code`, `sqlite3_result_int64`, `sqlite3_result_null`, `sqlite3_result_text`, `sqlite3_user_data`, `sqlite3_value_blob`, `sqlite3_value_bytes`, `sqlite3_value_double`, `sqlite3_value_int64`, `sqlite3_value_text`, `sqlite3_value_type`: see [Custom SQL Functions and Aggregates](#custom-sql-functions-and-aggregates) - `sqlite3_backup_finish`, `sqlite3_backup_init`, `sqlite3_backup_step`: see [Backup](#backup) - `sqlite3_bind_blob`, `sqlite3_bind_double`, `sqlite3_bind_int64`, `sqlite3_bind_null`, `sqlite3_bind_parameter_count`, `sqlite3_bind_parameter_name`, `sqlite3_bind_text`, `sqlite3_clear_bindings`, `sqlite3_column_blob`, `sqlite3_column_bytes`, `sqlite3_column_count`, `sqlite3_column_double`, `sqlite3_column_int64`, `sqlite3_column_name`, `sqlite3_column_text`, `sqlite3_column_type`, `sqlite3_exec`, `sqlite3_finalize`, `sqlite3_prepare_v2`, `sqlite3_reset`, `sqlite3_step`: see [Executing Updates](#executing-updates), [Fetch Queries](#fetch-queries), [Prepared Statements](#prepared-statements), [Values](#values) -- `sqlite3_busy_handler`, `sqlite3_busy_timeout`: see [Configuration.busyMode](http://groue.github.io/GRDB.swift/docs/2.9/Structs/Configuration.html) -- `sqlite3_changes`, `sqlite3_total_changes`: see [Database.changesCount and Database.totalChangesCount](http://groue.github.io/GRDB.swift/docs/2.9/Classes/Database.html) +- `sqlite3_busy_handler`, `sqlite3_busy_timeout`: see [Configuration.busyMode](http://groue.github.io/GRDB.swift/docs/2.10/Structs/Configuration.html) +- `sqlite3_changes`, `sqlite3_total_changes`: see [Database.changesCount and Database.totalChangesCount](http://groue.github.io/GRDB.swift/docs/2.10/Classes/Database.html) - `sqlite3_close`, `sqlite3_close_v2`, `sqlite3_next_stmt`, `sqlite3_open_v2`: see [Database Connections](#database-connections) - `sqlite3_commit_hook`, `sqlite3_rollback_hook`, `sqlite3_update_hook`: see [TransactionObserver Protocol](#transactionobserver-protocol), [FetchedRecordsController](#fetchedrecordscontroller) - `sqlite3_config`: see [Error Log](#error-log) @@ -1823,9 +1832,9 @@ Before jumping in the low-level wagon, here is the list of all SQLite APIs used - `sqlite3_last_insert_rowid`: see [Executing Updates](#executing-updates) - `sqlite3_preupdate_count`, `sqlite3_preupdate_depth`, `sqlite3_preupdate_hook`, `sqlite3_preupdate_new`, `sqlite3_preupdate_old`: see [Support for SQLite Pre-Update Hooks](#support-for-sqlite-pre-update-hooks) - `sqlite3_set_authorizer`: **reserved by GRDB** -- `sqlite3_sql`: see [Statement.sql](http://groue.github.io/GRDB.swift/docs/2.9/Classes/Statement.html) -- `sqlite3_trace`: see [Configuration.trace](http://groue.github.io/GRDB.swift/docs/2.9/Structs/Configuration.html) -- `sqlite3_wal_checkpoint_v2`: see [DatabasePool.checkpoint](http://groue.github.io/GRDB.swift/docs/2.9/Classes/DatabasePool.html) +- `sqlite3_sql`: see [Statement.sql](http://groue.github.io/GRDB.swift/docs/2.10/Classes/Statement.html) +- `sqlite3_trace`: see [Configuration.trace](http://groue.github.io/GRDB.swift/docs/2.10/Structs/Configuration.html) +- `sqlite3_wal_checkpoint_v2`: see [DatabasePool.checkpoint](http://groue.github.io/GRDB.swift/docs/2.10/Classes/DatabasePool.html) Records @@ -1912,7 +1921,7 @@ See [fetching methods](#fetching-methods), and the [query interface](#the-query- ```swift let player = try Player.fetchOne(db, key: 1)! -player.name = "Arthur" +player.score = 1000 try player.update(db) ``` @@ -1920,8 +1929,8 @@ It is possible to [avoid useless updates](#record-comparison): ```swift let player = try Player.fetchOne(db, key: 1)! -player.name = "Arthur" -try player.updateChanges(db) +player.score = 1000 +try player.updateChanges(db) // does nothing if score has not changed ``` For batch updates, execute an [SQL query](#executing-updates): @@ -2042,7 +2051,7 @@ Details follow: ``` A persistable record can also [compare](#record-comparison) itself against other records, and avoid useless database updates. - + ## FetchableRecord Protocol @@ -2110,7 +2119,7 @@ try Place.fetchAll(db, "SELECT ...", arguments:...) // [Place] try Place.fetchOne(db, "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/2.9/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/2.10/Structs/StatementArguments.html) for more information about the query arguments. ## TableRecord Protocol @@ -3236,7 +3245,7 @@ Player // SELECT * FROM players ``` -Raw SQL snippets are also accepted, with eventual [arguments](http://groue.github.io/GRDB.swift/docs/2.9/Structs/StatementArguments.html): +Raw SQL snippets are also accepted, with eventual [arguments](http://groue.github.io/GRDB.swift/docs/2.10/Structs/StatementArguments.html): ```swift // SELECT DATE(creationDate), COUNT(*) FROM players WHERE name = 'Arthur' GROUP BY date(creationDate) @@ -3736,7 +3745,7 @@ The `fetchedRegion` method helps [transaction observers](#transactionobserver-pr **To build custom requests**, you can create your own type that adopts the [FetchRequest](#fetchrequest-protocol) protocol, derive requests from other requests, or use one of the built-in concrete types: -- [SQLRequest](http://groue.github.io/GRDB.swift/docs/2.9/Structs/SQLRequest.html) is a fetch request built from raw SQL. For example: +- [SQLRequest](http://groue.github.io/GRDB.swift/docs/2.10/Structs/SQLRequest.html) is a fetch request built from raw SQL. For example: ```swift extension Player { @@ -3762,7 +3771,7 @@ The `fetchedRegion` method helps [transaction observers](#transactionobserver-pr - 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/2.9/Structs/AnyFetchRequest.html): a [type-erased](http://chris.eidhof.nl/post/type-erasers-in-swift/) request. +- [AnyFetchRequest](http://groue.github.io/GRDB.swift/docs/2.10/Structs/AnyFetchRequest.html): a [type-erased](http://chris.eidhof.nl/post/type-erasers-in-swift/) request. ### Fetching From Custom Requests @@ -4167,7 +4176,7 @@ let pattern = FTS3Pattern(matchingAnyTokenIn: "") // nil let pattern = FTS3Pattern(matchingAnyTokenIn: "*") // nil ``` -FTS3Pattern are regular [values](#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/2.9/Structs/StatementArguments.html): +FTS3Pattern are regular [values](#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/2.10/Structs/StatementArguments.html): ```swift let documents = try Document.fetchAll(db, @@ -4382,7 +4391,7 @@ let pattern = FTS5Pattern(matchingAnyTokenIn: "") // nil let pattern = FTS5Pattern(matchingAnyTokenIn: "*") // nil ``` -FTS5Pattern are regular [values](#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/2.9/Structs/StatementArguments.html): +FTS5Pattern are regular [values](#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/2.10/Structs/StatementArguments.html): ```swift let documents = try Document.fetchAll(db, @@ -5617,7 +5626,7 @@ Alternatively, perform a manual installation of GRDB and SQLCipher: ```sh cd [GRDB directory] - git checkout v2.9.0 + git checkout v2.10.0 git submodule update --init SQLCipher/src ``` @@ -5724,7 +5733,7 @@ DROP TABLE students; --' WHERE id = 1 ``` -To avoid those problems, **never embed raw values in your SQL queries**. The only correct technique is to provide [arguments](http://groue.github.io/GRDB.swift/docs/2.9/Structs/StatementArguments.html) to your SQL queries: +To avoid those problems, **never embed raw values in your SQL queries**. The only correct technique is to provide [arguments](http://groue.github.io/GRDB.swift/docs/2.10/Structs/StatementArguments.html) to your SQL queries: ```swift // Good @@ -6386,7 +6395,7 @@ try snapshot2.read { db in ### DatabaseWriter and DatabaseReader Protocols -Both DatabaseQueue and DatabasePool adopt the [DatabaseReader](http://groue.github.io/GRDB.swift/docs/2.9/Protocols/DatabaseReader.html) and [DatabaseWriter](http://groue.github.io/GRDB.swift/docs/2.9/Protocols/DatabaseWriter.html) protocols. DatabaseSnapshot adopts DatabaseReader only. +Both DatabaseQueue and DatabasePool adopt the [DatabaseReader](http://groue.github.io/GRDB.swift/docs/2.10/Protocols/DatabaseReader.html) and [DatabaseWriter](http://groue.github.io/GRDB.swift/docs/2.10/Protocols/DatabaseWriter.html) protocols. DatabaseSnapshot adopts DatabaseReader only. These protocols provide a unified API that lets you write safe concurrent code that targets all three concurrency modes. @@ -6480,7 +6489,7 @@ If you absolutely need multiple connections, then: - Read about [isolation in SQLite](https://www.sqlite.org/isolation.html) - Learn about [locks and transactions](https://www.sqlite.org/lang_transaction.html) - Become a master of the [WAL mode](https://www.sqlite.org/wal.html) -- Prepare to setup a [busy handler](https://www.sqlite.org/c3ref/busy_handler.html) with [Configuration.busyMode](http://groue.github.io/GRDB.swift/docs/2.9/Structs/Configuration.html) +- Prepare to setup a [busy handler](https://www.sqlite.org/c3ref/busy_handler.html) with [Configuration.busyMode](http://groue.github.io/GRDB.swift/docs/2.10/Structs/Configuration.html) - [Ask questions](https://github.com/groue/GRDB.swift/issues) diff --git a/Support/Info.plist b/Support/Info.plist index 5d9392735..19f6efcfe 100644 --- a/Support/Info.plist +++ b/Support/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.9.0 + 2.10.0 CFBundleSignature ???? CFBundleVersion