Compare commits

...
74 Commits
Author SHA1 Message Date
Gwendal Roué aa9bdf3635 Add test targets for various Swift 6 flavors 2026-12-03 14:25:52 +01:00
Gwendal Roué 2883935476 Delete GRDBProfiling project
We can profile tests directly
2026-12-03 13:13:15 +01:00
Gwendal Roué c50b2835cd Rename the folder of Swift 5 tests 2026-12-03 13:13:15 +01:00
Gwendal Roué 1d183eafd0 Fix compiler warning 2026-12-03 13:12:52 +01:00
Gwendal Roué 21f7cf3c0a Merge pull request #1905 from groue/dev/refactor-statement-cache
Refactor the statement cache
2026-12-02 20:52:17 +01:00
Gwendal Roué bd4c917a99 Update migration guide 2026-12-02 17:56:10 +01:00
Gwendal Roué 92253eaa19 Delete outdated comment 2026-12-02 17:55:37 +01:00
Gwendal Roué 26543b80ff Refactor the statement cache
The new cache prevents undesired statement reuse
2026-12-02 17:47:40 +01:00
Gwendal Roué e89d26f919 Clear the schema cache when needed, at the beginning of transactions
This helps the user who might forget to clear the cache. This also fixes an issue with database observation, which used to miss changes performed through the new schema.
2026-12-02 17:47:40 +01:00
Gwendal Roué dfa49c3da0 GRDB8MigrationGuide.md 2026-12-02 15:28:49 +01:00
Gwendal Roué 172a42cda0 Remove deprecated APIs, add fixits 2026-12-02 15:17:56 +01:00
Gwendal Roué 9a9443ea35 Drop fixits of GRDB 7 2026-12-02 15:10:28 +01:00
Gwendal Roué 911ea0421b Update declarations of JSON user info 2026-12-02 15:09:37 +01:00
Gwendal Roué cb76351660 Enable tests for well-behaved usage of LibDispatch with SPM 2026-12-02 14:52:04 +01:00
Gwendal Roué 70a63cd3f2 Simplify Package.swift 2026-12-02 14:48:55 +01:00
Gwendal Roué a12bbe80a5 Fix a broken file reference 2026-12-02 14:42:56 +01:00
Gwendal Roué d8835ca48c Move GRDB to the Sources directory 2026-12-02 14:40:45 +01:00
Gwendal Roué 340344f09b Move images 2026-12-02 14:37:55 +01:00
Gwendal Roué 4d349f81e5 Build the universal framework in the build folder
So that it doesn't pollute the Test folder
2026-12-02 14:29:28 +01:00
Gwendal Roué 70b2e160e2 Test that the universal framework can run 2026-12-02 14:23:45 +01:00
Gwendal Roué a33c25e471 Delete the playground 2026-12-02 14:18:55 +01:00
Gwendal Roué 89b4466c69 Merge pull request #1903 from groue/dev/drop-cocoapods
Drop CocoaPods support
2026-12-02 12:25:07 +01:00
Gwendal Roué 0ff4a1f3c6 Restore SQLCipher tests on CI
Those were removed in #1901, and not restored in #1902.
2026-12-02 12:07:41 +01:00
Gwendal Roué e65b19f787 CHANGELOG 2026-12-02 12:04:21 +01:00
Gwendal Roué ac37647acf Drop mentions of CocoaPods 2026-12-02 12:03:28 +01:00
Gwendal Roué b744a5efa8 The import boilerplate no longer mentions CocoaPods 2026-12-02 12:01:54 +01:00
Gwendal Roué f013569c13 🪦 Delete GRDB.swift.podspec 2026-12-02 12:01:54 +01:00
Gwendal Roué 8b16aae185 Stop testing CocoaPods integration 2026-12-02 12:01:54 +01:00
Gwendal Roué fad1e845e2 Stop documenting support for CocoaPods and Carthage 2026-12-02 12:01:54 +01:00
Gwendal Roué 7a831220cf Merge pull request #1902 from groue/feature/sqlcipher-trait
Create SQLCipher trait
2026-12-02 11:47:31 +01:00
Gwendal Roué 89c05222a3 The SQLCipher SPM trait is experimental 2026-12-02 10:39:18 +01:00
Gwendal Roué 9f27e0755f Don't import the system SQLite when testing SQLCipher 2026-12-02 10:38:34 +01:00
Gwendal Roué e83cfd6b2b Update link to PR 2026-12-02 10:29:28 +01:00
Gwendal Roué 1b0e71a35e Update instructions for accessing SQLite C functions 2026-12-02 08:50:29 +01:00
Gwendal Roué 8013add96d Test that SQLCipher trait does not link SQLite 2026-12-02 08:50:29 +01:00
Gwendal Roué c7b9fa5233 Delete unused SQLCipher test app 2026-12-01 23:19:46 +01:00
Gwendal Roué 7e62cbba2d SQLCipher tests no longer require CocoaPods 2026-12-01 23:19:46 +01:00
Gwendal Roué 650102d77d Update GRDBDemo around the lack of ENABLE_UPDATE_DELETE_LIMIT in SQLCipher
SQLCipher won't accept DELETE … ORDER BY … LIMIT
2026-12-01 23:19:46 +01:00
Gwendal Roué 5decd4abeb CHANGELOG 2026-12-01 23:19:46 +01:00
Gwendal Roué 9ef0ed35e6 Update instructions for enabling SQLCipher with SPM 2026-12-01 23:19:46 +01:00
Gwendal Roué 1ae6d258c0 Ignore Package.resolved 2026-12-01 22:37:19 +01:00
Gwendal Roué 2c89599471 Update URL of sqlcipher/SQLCipher 2026-12-01 22:37:19 +01:00
Gwendal Roué 6b118c1736 Update the import boilerplate for traits 2026-12-01 22:37:18 +01:00
Gwendal Roué 0adc2ed6bc Rename the default trait to SystemSQLite 2026-12-01 22:33:42 +01:00
George Elsham bb18a7e065 Merge branch 'GRDB8' into feature/sqlcipher-trait 2026-12-01 15:55:11 +00:00
Gwendal Roué adb95a7282 Merge pull request #1901 from groue/dev/xcode-27-compatibility
Xcode 27 compatibility
2026-12-01 16:42:53 +01:00
Gwendal Roué 0da1e0df41 Fix flaky test 2026-12-01 16:21:15 +01:00
Gwendal Roué 0a95314e3a Update CI.yml for Xcode 27 2026-12-01 16:02:27 +01:00
Gwendal Roué d2a0c65120 Fix performance tests for Xcode 27 2026-12-01 15:54:16 +01:00
Gwendal Roué 9454f37128 SE-0470 2026-12-01 15:54:16 +01:00
Gwendal Roué 660e06bca6 SE-0496 2026-12-01 15:54:16 +01:00
Gwendal Roué 43955406fb Modernize GRDBDemo 2026-12-01 15:54:16 +01:00
Gwendal Roué 41f4b8121d SE-0421, SE-0461 2026-12-01 15:54:16 +01:00
Gwendal Roué 5b61a48679 DatabaseValue.Storage is a regular Sendable value 2026-12-01 15:51:49 +01:00
Gwendal Roué 79935aaf6a Remove workaround for SR-15150, no longer needed 2026-12-01 15:51:49 +01:00
Gwendal Roué 3374769e3b CHANGELOG 2026-12-01 15:51:49 +01:00
Gwendal Roué b59ded7175 Delete obsolete Travis configuration 2026-12-01 15:51:49 +01:00
Gwendal Roué 4facbdd057 Fix typos 2026-12-01 15:51:49 +01:00
Gwendal Roué 801146f3ae Remove watchOS from SQLite 3.38 availability checks
This is safe because watchOS 9.0 ships with SQLite 3.39
2026-12-01 15:51:49 +01:00
Gwendal Roué 68fc25c2d1 Remove watchOS from SQLite 3.37 availability checks
This is safe because watchOS 9.0 ships with SQLite 3.39
2026-12-01 15:51:22 +01:00
Gwendal Roué 9227658da6 Fix module warning
grdb_config.h does not really contain public symbols, but it's OK since they are underscored.
2026-12-01 15:51:21 +01:00
Gwendal Roué 9c433f91b0 Fix Swiftlint warnings 2026-12-01 15:51:21 +01:00
Gwendal Roué ba517ad22f Fix Xcode 27.2 warnings 2026-12-01 15:51:21 +01:00
Gwendal Roué fe462708c1 Raise minimum SQLite version to 3.36.0 2026-12-01 15:51:21 +01:00
Gwendal Roué 54c9b505d7 Drop GRDBSendableMetatype, no longer needed for Swift 6.4+ 2026-12-01 13:23:47 +01:00
Gwendal Roué f185101c94 Raise minimum Swift version to 6.4 2026-12-01 13:23:47 +01:00
Gwendal Roué f7ae8e61a3 Switch to https://github.com/groue/SQLiteLib, SQLite 3.54.1
Had to switch the repository because the maintenance of https://github.com/swiftlyfalling/SQLiteLib is no longer possible: see https://github.com/swiftlyfalling/SQLiteLib/pull/69
2026-12-01 13:23:47 +01:00
Gwendal Roué 903ba97b03 Raise deployment targets for Xcode 27 compatibility 2026-12-01 13:23:47 +01:00
George Elsham 736fc0cdf5 Change SwiftPM instructions for SQLCipher 2026-09-23 22:47:41 +01:00
George Elsham 4a09a2d795 Fix SQLCipher link in readme 2026-09-23 22:47:16 +01:00
George Elsham a05abbfb3f Delete Package.resolved 2026-09-23 22:19:44 +01:00
George Elsham 07ff8109b6 Conditionally add SQLCipher dependency 2026-09-23 22:19:37 +01:00
George Elsham f1cfe81e8f Add traits to package 2026-09-22 22:46:11 +01:00
George Elsham e5bdfbc615 Create trait 2026-09-22 22:08:12 +01:00
612 changed files with 4473 additions and 13860 deletions

No files matched your search

+2 -3
View File
@@ -18,12 +18,11 @@ Please fill out this template when filing an issue.
### Environment
**GRDB flavor(s):** (GRDB, SQLCipher, Custom SQLite build?)
**GRDB version:**
**Installation method:** (CocoaPods, SPM, manual?)
**Enabled SwiftPM traits:**
**Xcode version:**
**Swift version:**
**Platform(s) running GRDB:** (iOS, macOS, watchOS?)
**Platform(s) running GRDB:**
**macOS version running Xcode:**
### Demo Project
+24 -41
View File
@@ -1,4 +1,4 @@
# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md
# https://github.com/actions/runner-images/blob/main/images/macos/xcode-27-arm64-Readme.md
name: "GRDB CI"
@@ -8,7 +8,7 @@ on:
- master
- development
paths:
- 'GRDB/**'
- 'Sources/**'
- 'Tests/**'
- '.github/workflows/**'
- 'Makefile'
@@ -16,7 +16,7 @@ on:
- 'SQLiteCustom/src'
pull_request:
paths:
- 'GRDB/**'
- 'Sources/**'
- 'Tests/**'
- '.github/workflows/**'
- 'Makefile'
@@ -40,17 +40,17 @@ jobs:
fail-fast: false
matrix:
include:
- xcode: "Xcode_16.4.app"
runsOn: macOS-15
- xcode: "Xcode_27.2.app"
runsOn: xcode-27
destination: "platform=macOS"
name: "macOS"
- xcode: "Xcode_16.4.app"
runsOn: macOS-15
destination: "OS=18.5,name=iPhone 16 Pro"
- xcode: "Xcode_27.2.app"
runsOn: xcode-27
destination: "OS=27.2,name=iPhone 17"
name: "iOS"
- xcode: "Xcode_16.4.app"
runsOn: macOS-15
destination: "OS=18.5,name=Apple TV"
- xcode: "Xcode_27.2.app"
runsOn: xcode-27
destination: "OS=27.2,name=Apple TV 4K (4th generation)"
name: "tvOS"
steps:
- uses: actions/checkout@v5
@@ -66,30 +66,13 @@ jobs:
fail-fast: false
matrix:
include:
- xcode: "Xcode_16.4.app"
runsOn: macOS-15
name: "Xcode 16.4"
- xcode: "Xcode_27.2.app"
runsOn: xcode-27
name: "Xcode 27.2"
steps:
- uses: actions/checkout@v5
- name: ${{ matrix.name }}
run: make test_SPM test_install_SPM
SQLCipher3:
name: SQLCipher3
runs-on: ${{ matrix.runsOn }}
env:
DEVELOPER_DIR: "/Applications/${{ matrix.xcode }}/Contents/Developer"
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- xcode: "Xcode_16.4.app"
runsOn: macOS-15
name: "Xcode 16.4"
steps:
- uses: actions/checkout@v5
- name: ${{ matrix.name }}
run: make test_framework_SQLCipher3Encrypted
SQLCipher4:
name: SQLCipher4
runs-on: ${{ matrix.runsOn }}
@@ -100,13 +83,13 @@ jobs:
fail-fast: false
matrix:
include:
- xcode: "Xcode_16.4.app"
runsOn: macOS-15
name: "Xcode 16.4"
- xcode: "Xcode_27.2.app"
runsOn: xcode-27
name: "Xcode 27.2"
steps:
- uses: actions/checkout@v5
- name: ${{ matrix.name }}
run: make test_framework_SQLCipher4Encrypted
run: make test_SPM_SQLCipherEncrypted
# CustomSQLite:
# name: CustomSQLite
# runs-on: ${{ matrix.runsOn }}
@@ -117,9 +100,9 @@ jobs:
# fail-fast: false
# matrix:
# include:
# - xcode: "Xcode_16.4.app"
# runsOn: macOS-15
# name: "Xcode 16.4"
# - xcode: "Xcode_27.2.app"
# runsOn: xcode-27
# name: "Xcode 27.2"
# steps:
# - uses: actions/checkout@v5
# - name: ${{ matrix.name }}
@@ -134,9 +117,9 @@ jobs:
fail-fast: false
matrix:
include:
- xcode: "Xcode_16.4.app"
runsOn: macOS-15
name: "Xcode 16.4"
- xcode: "Xcode_27.2.app"
runsOn: xcode-27
name: "Xcode 27.2"
steps:
- uses: actions/checkout@v5
- name: ${{ matrix.name }}
+1 -6
View File
@@ -71,6 +71,7 @@ Session.vim
# Build generated
build/
DerivedData
/Package.resolved
# Various settings
*.pbxuser
@@ -100,10 +101,6 @@ xcuserdata
SQLiteCustom/GRDBCustomSQLite-USER.h
SQLiteCustom/GRDBCustomSQLite-USER.xcconfig
# CocoaPods test
Pods
Podfile.lock
# SPM
.build
GRDB.xcworkspace/xcshareddata/swiftpm
@@ -113,5 +110,3 @@ Tests/SPM/Packages
# Ruby
.ruby-version
# Test products
Tests/products
+1 -1
View File
@@ -1,3 +1,3 @@
[submodule "SQLiteCustom/src"]
path = SQLiteCustom/src
url = https://github.com/swiftlyfalling/SQLiteLib.git
url = https://github.com/groue/SQLiteLib
-161
View File
@@ -1,161 +0,0 @@
# The OS X Build Environment
# https://docs.travis-ci.com/user/reference/osx/#xcode-version
branches:
only:
- master
- development
language: objective-c
xcode_project: GRDB.xcodeproj
# Caches
cache:
- bundler
- cocoapods
# Custom CocoaPods installation so that Podfile.lock is honored
install:
- bundle install
- bundle exec pod repo update
# Disable the default Travis-CI submodule logic
# The various make commands ensure that the appropriate submodules are retrieved
git:
submodules: false
jobs:
include:
###########################################
## Test GRDB Xcode 11.4
- name: "Test GRDB Xcode 11.4 - GRDBiOS iOS maxTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode11.4
script: make test_framework_GRDBiOS_maxTarget_maxSwift
- name: "Test GRDB Xcode 11.4 - GRDBiOS iOS minTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode11.4
script: make test_framework_GRDBiOS_minTarget
###########################################
## Test GRDB Xcode 12.5
- name: "Test GRDB Xcode 12.5 - GRDBOSX - Swift 5.3"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBOSX_maxSwift
- name: "Test GRDB Xcode 12.5 - GRDBOSX - Swift 5.2"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBOSX_minSwift
- name: "Test GRDB Xcode 12.5 - GRDBWatchOS"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBWatchOS
- name: "Test GRDB Xcode 12.5 - GRDBiOS iOS maxTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBiOS_maxTarget_maxSwift
- name: "Test GRDB Xcode 12.5 - GRDBiOS iOS minTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBiOS_minTarget
- name: "Test GRDB Xcode 12.5 - GRDBtvOS maxTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBtvOS_maxTarget_maxSwift
- name: "Test GRDB Xcode 12.5 - GRDBtvOS minTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBtvOS_minTarget
- name: "Test GRDB Xcode 12.5 - SPM"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_SPM
###########################################
## Test GRDBCustom Xcode 12.5
- name: "Test GRDBCustom Xcode 12.5 - GRDBOSX"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBCustomSQLiteOSX
- name: "Test GRDBCustom Xcode 12.5 - GRDBiOS maxTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBCustomSQLiteiOS_maxTarget_maxSwift
- name: "Test GRDBCustom Xcode 12.5 - GRDBiOS minTarget"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_GRDBCustomSQLiteiOS_minTarget
###########################################
## Test SQLCipher Xcode 12.5
- name: "Test SQLCipher Xcode 12.5 - SQLCipher 3"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_SQLCipher3
- name: "Test SQLCipher Xcode 12.5 - SQLCipher 4"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_framework_SQLCipher4
###########################################
## Test Installation Xcode 12.5
# Manual Install
- name: "Test Installation Xcode 12.5 - Manual Install"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_install_manual
# Travis is much too slow, and always fail this job
# # CocoaPods Lint
# - name: "Test Installation Xcode 12.5 - CocoaPods Lint"
# gemfile: .ci/gemfiles/Gemfile.travis
# osx_image: xcode12.5
# script: make test_CocoaPodsLint_GRDB
# CocoaPods Install GRDB
- name: "Test Installation Xcode 12.5 - CocoaPods Framework"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_install_GRDB_CocoaPods_framework
# CocoaPods Install GRDB
- name: "Test Installation Xcode 12.5 - CocoaPods Static"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_install_GRDB_CocoaPods_static
# SPM Install
- name: "Test Installation Xcode 12.5 - SPM Package"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_install_SPM_Package
# SPM Install
- name: "Test Installation Xcode 12.5 - SPM Package in Xcode Project"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_install_SPM_Project
# Custom SQLite Install
- name: "Test Installation Xcode 12.5 - Custom SQLite"
gemfile: .ci/gemfiles/Gemfile.travis
osx_image: xcode12.5
script: make test_install_customSQLite
+16
View File
@@ -144,6 +144,22 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception:
---
## Unreleased
[Migrating From GRDB 7 to GRDB 8](Documentation/GRDB8MigrationGuide.md) describes how to bump the GRDB version in your application.
- **New**: Xcode 27 compatibility
- **New**: Bump custom SQLite build to version 3.54.1
- **New**: SQLCipher package trait by [@GeorgeElsham](https://github.com/GeorgeElsham) and [@groue](https://github.com/groue) in [#1902](https://github.com/groue/GRDB.swift/pull/1902)
- **New**: `sum(_:orderBy:filter:)` and `total(_:orderBy:filter:)` are available with the system SQLite, from iOS 26, macOS 26, tvOS 26, watchOS 26, and visionOS 26.
- **Breaking Change**: Raise deployment targets for Xcode 27 compatibility: iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 9.0
- **Breaking Change**: Raise minimal Swift version to 6.4 (Xcode 27.0)
- **Breaking Change**: Raise minimal SQLite version to 3.36.0
- **Breaking Change**: Raise minimal SQLCipher version to 4.5.0
- **Breaking Change**: Drop CocoaPods support
- **Breaking Change**: `FetchableRecord.databaseDecodingUserInfo` and `EncodableRecord.databaseEncodingUserInfo` are now declared as `[CodingUserInfoKey: any Sendable]`, as `JSONDecoder.userInfo` and `JSONEncoder.userInfo` are.
- **Breaking Change**: Remove deprecated APIs
## 7.12.1
Released November 30, 2026
+1 -3
View File
@@ -11,7 +11,6 @@ How you can Contribute
- For running tests:
- Ruby
- [CocoaPods](https://cocoapods.org) (gem)
- [xcpretty](https://github.com/xcpretty/xcpretty) (gem)
- For contributing code:
- [Swiftlint](https://github.com/realm/SwiftLint) (present in the `$PATH` or in `/opt/homebrew/bin/`)
@@ -28,8 +27,7 @@ How you can Contribute
- `GRDB`: GRDB sources
- `Tests`: GRDB tests
- `GRDBCustom.xcodeproj`: the project which builds GRDB with a custom SQLite build.
- `GRDBProfiling.xcodeproj`: a project which helps profile GRDB with Instruments. No code here is really precious.
- `GRDBDemoiOS.xcodeproj`, `GRDBCombineDemo.xcodeproj`, `GRDBAsyncDemo.xcodeproj`: the demo apps.
- `GRDBDemo.xcodeproj`: the demo app.
To work with `GRDBCustom.xcodeproj`:
+2 -2
View File
@@ -3,11 +3,11 @@ Custom SQLite Builds
By default, GRDB uses the version of SQLite that ships with the target operating system.
**You can build GRDB with a custom build of [SQLite 3.47.2](https://www.sqlite.org/changes.html).**
**You can build GRDB with a custom build of [SQLite 3.54.1](https://www.sqlite.org/changes.html).**
A custom SQLite build can activate extra SQLite features, and extra GRDB features as well, such as support for the [FTS5 full-text search engine](FullTextSearch.md), and [SQLite Pre-Update Hooks](https://swiftpackageindex.com/groue/GRDB.swift/documentation/grdb/transactionobserver).
GRDB builds SQLite with [swiftlyfalling/SQLiteLib](https://github.com/swiftlyfalling/SQLiteLib), which uses the same SQLite configuration as the one used by Apple in its operating systems, and lets you add extra compilation options that leverage the features you need.
GRDB builds SQLite with [groue/SQLiteLib](https://github.com/groue/SQLiteLib), which uses the same SQLite configuration as the one used by Apple in its operating systems, and lets you add extra compilation options that leverage the features you need.
> Warning: The technique described here is not compatible with the Swift Package Manager (SPM). It will create [build issues](https://github.com/groue/GRDB.swift/issues/1709) with SPM companion libraries such as [GRDBQuery](https://github.com/groue/GRDBQuery) or [GRDBSnapshotTesting](https://github.com/groue/GRDBSnapshotTesting).
@@ -287,7 +287,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.6;
IPHONEOS_DEPLOYMENT_TARGET = 26.6;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
@@ -346,7 +346,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.6;
IPHONEOS_DEPLOYMENT_TARGET = 26.6;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
@@ -381,6 +381,7 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_APPROACHABLE_CONCURRENCY = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 6.1;
TARGETED_DEVICE_FAMILY = "1,2";
@@ -410,6 +411,7 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_APPROACHABLE_CONCURRENCY = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 6.1;
TARGETED_DEVICE_FAMILY = "1,2";
@@ -426,6 +428,7 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_APPROACHABLE_CONCURRENCY = YES;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 6.1;
TARGETED_DEVICE_FAMILY = "1,2";
@@ -443,6 +446,7 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_APPROACHABLE_CONCURRENCY = YES;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 6.1;
TARGETED_DEVICE_FAMILY = "1,2";
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2600"
LastUpgradeVersion = "2720"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
@@ -141,8 +141,8 @@ extension AppDatabase {
}
// Delete a random player
if Bool.random() {
try Player.order(sql: "RANDOM()").limit(1).deleteAll(db)
if Bool.random(), let player = try Player.order(sql: "RANDOM()").fetchOne(db) {
try player.delete(db)
}
// Update some players
@@ -65,18 +65,12 @@
},
"Anonymous" : {
},
"Cancel" : {
},
"Name" : {
},
"New Player" : {
},
"Save" : {
},
"Score" : {
@@ -14,10 +14,12 @@ struct PlayerCreationSheet: View {
.navigationTitle("New Player")
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("Cancel") { dismiss() }
Button(role: .cancel) {
dismiss()
}
}
ToolbarItem(placement: .confirmationAction) {
Button("Save") {
Button(role: .confirm) {
save()
}
}
+74
View File
@@ -0,0 +1,74 @@
Migrating From GRDB 7 to GRDB 8
===============================
**This guide helps you upgrade your applications from GRDB 7 to GRDB 8.**
- [Preparing the Migration to GRDB 8](#preparing-the-migration-to-grdb-8)
- [New requirements](#new-requirements)
- [CocoaPods is no Longer Supported](#cocoapods-is-no-longer-supported)
- [SQLCipher](#sqlcipher)
- [Cached Statements](#cached-statements)
- [JSON User Info](#json-user-info)
## Preparing the Migration to GRDB 8
Before upgrading, ensure you are using the [latest GRDB 7 release](https://github.com/groue/GRDB.swift/tags) and address any deprecation warnings. Once this is done, proceed with upgrading to GRDB 8. Due to breaking changes, your application may no longer compile. Follow the fix-it suggestions, and review the specific modifications described below.
## New requirements
GRDB requirements have been bumped:
- **Swift Compiler 6.4+** (was Swift 6.1+)
- **Xcode 27.0+** (was Xcode 16.3+)
- **iOS 15.0+** (was iOS 13.0+)
- **macOS 12.0+** (was macOS 10.15+)
- **tvOS 15.0+** (was tvOS 13.0+)
- **watchOS 9.0+** (was watchOS 7.0+)
- **SQLite 3.36.0+** (was SQLite 3.20.0+)
- **SQLCipher 4.5+** (was SQLCipher 3.4+)
## CocoaPods is no Longer Supported
GRDB 8 is no longer distributed with CocoaPods. Install it with the Swift Package Manager, or manually. See [Installation](../README.md#installation).
## SQLCipher
To use GRDB with SQLCipher, enable the `SQLCipher` trait of the GRDB package. There is no longer any need to fork GRDB. See [Encryption](../README.md#encryption).
When GRDB uses SQLCipher, access SQLite C functions with `import SQLCipher` only. Importing `SQLite3` or `GRDBSQLite` can link the system SQLite next to SQLCipher, which creates undefined behavior.
## Cached Statements
The statements returned by `Database.cachedStatement(sql:)` and `Database.cachedStatement(literal:)` no longer preserve their arguments between two calls. You must set the arguments of a cached statement each time you load it from the cache:
```swift
// GRDB 7: relies on the arguments set by the first call.
try db.cachedStatement(sql: "INSERT INTO player (name) VALUES (?)")
.setArguments(["Arthur"])
try db.cachedStatement(sql: "INSERT INTO player (name) VALUES (?)")
.execute()
// GRDB 8: set arguments each time.
try db.cachedStatement(sql: "INSERT INTO player (name) VALUES (?)")
.execute(arguments: ["Arthur"])
```
Two calls with the same SQL no longer return the same statement when the first one is still in use (held by the application or by a cursor). This allows nested iterations of the same cached SQL.
## JSON User Info
The `databaseDecodingUserInfo` and `databaseEncodingUserInfo` properties of record types are now declared as `[CodingUserInfoKey: any Sendable]`, like `JSONDecoder.userInfo` and `JSONEncoder.userInfo`.
Update the declarations of these properties in your record types, as below. In the Swift 6 language mode, a property declared as `[CodingUserInfoKey: Any]` no longer matches the protocol requirement, and is ignored by GRDB. The compiler does not emit any diagnostic.
```swift
// GRDB 7
struct Player: FetchableRecord, Decodable {
static var databaseDecodingUserInfo: [CodingUserInfoKey: Any] { ... }
}
// GRDB 8
struct Player: FetchableRecord, Decodable {
static var databaseDecodingUserInfo: [CodingUserInfoKey: any Sendable] { ... }
}
```
File renamed without changes.

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 86 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 90 KiB

@@ -1,144 +0,0 @@
//: To run this playground:
//:
//: - Open GRDB.xcworkspace
//: - Select the GRDB scheme: menu Product > Scheme > GRDB
//: - Build: menu Product > Build
//: - Select the playground in the Playgrounds Group
//: - Run the playground
import GRDB
//: Open a database connection
var configuration = Configuration()
configuration.prepareDatabase { db in
db.trace { print("SQL> \($0)") }
}
let dbQueue = try DatabaseQueue(configuration: configuration)
//: Use a migrator to define the database schema
var migrator = DatabaseMigrator()
migrator.registerMigration("createLibrary") { db in
try db.create(table: "author") { t in
t.autoIncrementedPrimaryKey("id")
t.column("name", .text).notNull()
}
try db.create(table: "book") { t in
t.autoIncrementedPrimaryKey("id")
t.column("title", .text).notNull()
t.belongsTo("author", onDelete: .cascade).notNull()
}
}
try migrator.migrate(dbQueue)
//: Define Record types
struct Author: Codable, FetchableRecord, MutablePersistableRecord {
var id: Int64?
var name: String
mutating func didInsert(_ inserted: InsertionSuccess) {
id = inserted.rowID
}
}
struct Book: Codable, FetchableRecord, MutablePersistableRecord {
var id: Int64?
var authorId: Int64
var title: String
mutating func didInsert(_ inserted: InsertionSuccess) {
id = inserted.rowID
}
}
//: Define Associations
extension Author {
static let books = hasMany(Book.self)
var books: QueryInterfaceRequest<Book> { request(for: Author.books) }
}
extension Book {
static let author = belongsTo(Author.self)
var author: QueryInterfaceRequest<Author> { request(for: Book.author) }
}
//: Populate the database
print("----------")
print("Populate the database")
try dbQueue.write { db in
var melville = Author(id: nil, name: "Hermann Melville")
try melville.insert(db)
var mobyDick = Book(id: nil, authorId: melville.id!, title: "Moby-Dick")
try mobyDick.insert(db)
var genet = Author(id: nil, name: "Jean Genet")
try genet.insert(db)
var querelle = Book(id: nil, authorId: genet.id!, title: "Querelle de Brest")
try querelle.insert(db)
var lesBonnes = Book(id: nil, authorId: genet.id!, title: "Les Bonnes")
try lesBonnes.insert(db)
}
//: Fetch author information
print("----------")
print("Fetch author information")
struct AuthorInfo {
var author: Author
var books: [Book]
}
let authorId = 2
let authorInfo: AuthorInfo? = try dbQueue.read { db in
guard let author = try Author.fetchOne(db, key: authorId) else { return nil }
let books = try author.books.fetchAll(db)
return AuthorInfo(author: author, books: books)
}
if let authorInfo {
print("\(authorInfo.author.name) has written:")
for book in authorInfo.books {
print("- \(book.title)")
}
}
//: Fetch book information
print("----------")
print("Fetch book information")
struct BookInfo: FetchableRecord, Codable {
var book: Book
var author: Author
}
let bookId = 1
let bookInfo: BookInfo? = try dbQueue.read { db in
let request = Book
.filter(key: bookId)
.including(required: Book.author)
return try BookInfo.fetchOne(db, request)
}
if let bookInfo {
print("\(bookInfo.book.title) was written by \(bookInfo.author.name)")
}
//: Fetch all authorships
print("----------")
print("Fetch all authorships")
struct Authorship: Decodable, FetchableRecord {
var book: Book
var author: Author
}
let authorships: [Authorship] = try dbQueue.read { db in
let request = Book.including(required: Book.author)
return try Authorship.fetchAll(db, request)
}
for authorship in authorships {
print("\(authorship.book.title) was written by \(authorship.author.name)")
}
@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='macos' buildActiveScheme='true'>
<timeline fileName='timeline.xctimeline'/>
</playground>
@@ -1,46 +0,0 @@
// To run this playground, select and build the GRDB scheme.
import GRDB
var configuration = Configuration()
configuration.prepareDatabase { db in
db.trace { print("SQL> \($0)") }
}
let dbQueue = try DatabaseQueue(configuration: configuration)
struct Player: Codable, FetchableRecord, MutablePersistableRecord {
var id: Int64?
var name: String
var score: Int
mutating func didInsert(_ inserted: InsertionSuccess) {
id = inserted.rowID
}
}
try dbQueue.write { db in
try db.create(table: "player") { t in
t.autoIncrementedPrimaryKey("id")
t.column("name", .text).notNull()
t.column("score", .integer).notNull()
}
do {
var player = Player(id: nil, name: "Arthur", score: 100)
try player.insert(db)
player = Player(id: nil, name: "Barbara", score: 100)
try player.insert(db)
}
do {
let players = try Player.fetchAll(db)
for player in players {
print(player)
}
}
do {
let count = try Player.fetchCount(db)
print(count)
}
}
@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='macos' buildActiveScheme='true'>
<timeline fileName='timeline.xctimeline'/>
</playground>
@@ -1,141 +0,0 @@
//: To run this playground:
//:
//: - Open GRDB.xcworkspace
//: - Select the GRDB scheme: menu Product > Scheme > GRDB
//: - Build: menu Product > Build
//: - Select the playground in the Playgrounds Group
//: - Run the playground
//:
//: Tour
//: ======
//:
//: This playground is a quick tour of GRDB.
import GRDB
import CoreLocation
//: Open a connection to the database
// Open an in-memory database that logs all SQL statements
var configuration = Configuration()
configuration.prepareDatabase { db in
db.trace { print("SQL> \($0)") }
}
let dbQueue = try DatabaseQueue(configuration: configuration)
//: Execute SQL queries
try dbQueue.inDatabase { db in
try db.execute(sql: """
CREATE TABLE place (
id INTEGER PRIMARY KEY,
title TEXT,
isFavorite BOOLEAN NOT NULL,
latitude DOUBLE NOT NULL,
longitude DOUBLE NOT NULL
)
""")
try db.execute(sql: """
INSERT INTO place (title, isFavorite, latitude, longitude)
VALUES (?, ?, ?, ?)
""", arguments: ["Paris", true, 48.85341, 2.3488])
let parisId = db.lastInsertedRowID
}
//: Fetch database rows and values
try! dbQueue.inDatabase { db in
let rows = try Row.fetchCursor(db, sql: "SELECT * FROM place")
while let row = try rows.next() {
let title: String = row["title"]
let isFavorite: Bool = row["isFavorite"]
let coordinate = CLLocationCoordinate2D(
latitude: row["latitude"],
longitude: row["longitude"])
print("Fetched", title, isFavorite, coordinate)
}
let placeCount = try Int.fetchOne(db, sql: "SELECT COUNT(*) FROM place")! // Int
let placeTitles = try String.fetchAll(db, sql: "SELECT title FROM place") // [String]
}
//: Insert and fetch records
struct Place {
var id: Int64?
var title: String?
var isFavorite: Bool
var coordinate: CLLocationCoordinate2D
}
// Adopt FetchableRecord
extension Place : FetchableRecord {
init(row: Row) {
id = row[Columns.id]
title = row[Columns.title]
isFavorite = row[Columns.isFavorite]
coordinate = CLLocationCoordinate2DMake(
row[Columns.latitude],
row[Columns.longitude])
}
}
// Adopt TableRecord
extension Place : TableRecord {
static let databaseTableName = "place"
enum Columns {
static let id = Column("id")
static let title = Column("title")
static let isFavorite = Column("isFavorite")
static let latitude = Column("latitude")
static let longitude = Column("longitude")
}
}
// Adopt MutablePersistableRecord
extension Place : MutablePersistableRecord {
func encode(to container: inout PersistenceContainer) throws {
container[Columns.id] = id
container[Columns.title] = title
container[Columns.isFavorite] = isFavorite
container[Columns.latitude] = coordinate.latitude
container[Columns.longitude] = coordinate.longitude
}
mutating func didInsert(_ inserted: InsertionSuccess) {
id = inserted.rowID
}
}
try dbQueue.inDatabase { db in
var berlin = Place(
id: nil,
title: "Berlin",
isFavorite: false,
coordinate: CLLocationCoordinate2DMake(52.52437, 13.41053))
try berlin.insert(db)
berlin.id // some value
berlin.isFavorite = true
try berlin.update(db)
// Fetch from SQL
let places = try Place.fetchAll(db, sql: "SELECT * FROM place") // [Place]
//: Avoid SQL with the query interface:
berlin = try Place.filter { $0.title == "Berlin" }.fetchOne(db)! // Place
let paris = try Place.fetchOne(db, key: 1) // Place?
let favoritePlaces = try Place // [Place]
.filter { $0.isFavorite == true }
.order { $0.title }
.fetchAll(db)
}
@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='osx' display-mode='raw' buildActiveScheme='true'>
<timeline fileName='timeline.xctimeline'/>
</playground>
@@ -1,84 +0,0 @@
//: To run this playground:
//:
//: - Open GRDB.xcworkspace
//: - Select the GRDB scheme: menu Product > Scheme > GRDB
//: - Build: menu Product > Build
//: - Select the playground in the Playgrounds Group
//: - Run the playground
import GRDB
// Create the database
let dbQueue = try DatabaseQueue() // Memory database
var migrator = DatabaseMigrator()
migrator.registerMigration("createPerson") { db in
try db.create(table: "person") { t in
t.autoIncrementedPrimaryKey("id")
t.column("name", .text).notNull()
}
}
migrator.registerMigration("createPet") { db in
try db.create(table: "pet") { t in
t.autoIncrementedPrimaryKey("id")
t.column("name", .text).notNull()
t.belongsTo("owner", inTable: "person", onDelete: .cascade)
}
}
try! migrator.migrate(dbQueue)
//
class TableChangeObserver : NSObject, TransactionObserver {
private var changedTableNames: Set<String> = []
func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool { true }
func databaseDidChange(with event: DatabaseEvent) {
changedTableNames.insert(event.tableName)
}
func databaseDidCommit(_ db: Database) {
print("Changed table(s): \(changedTableNames.joined(separator: ", "))")
changedTableNames = []
}
func databaseDidRollback(_ db: Database) {
changedTableNames = []
}
}
let observer = TableChangeObserver()
dbQueue.add(transactionObserver: observer)
//
print("-- Changes without transaction")
try dbQueue.inDatabase { db in
try db.execute(sql: "INSERT INTO person (name) VALUES (?)", arguments: ["Arthur"])
let arthurId = db.lastInsertedRowID
try db.execute(sql: "INSERT INTO person (name) VALUES (?)", arguments: ["Barbara"])
try db.execute(sql: "INSERT INTO pet (ownerId, name) VALUES (?, ?)", arguments: [arthurId, "Barbara"])
try db.execute(sql: "DELETE FROM person WHERE id = ?", arguments: [arthurId])
}
print("-- Rollbacked changes")
try dbQueue.inTransaction { db in
try db.execute(sql: "INSERT INTO person (name) VALUES ('Arthur')")
try db.execute(sql: "INSERT INTO person (name) VALUES ('Barbara')")
return .rollback
}
print("-- Changes wrapped in a transaction")
try dbQueue.write { db in
try db.execute(sql: "DELETE FROM person")
try db.execute(sql: "INSERT INTO person (name) VALUES (?)", arguments: ["Arthur"])
let arthurId = db.lastInsertedRowID
try db.execute(sql: "INSERT INTO person (name) VALUES (?)", arguments: ["Barbara"])
try db.execute(sql: "INSERT INTO pet (ownerId, name) VALUES (?, ?)", arguments: [arthurId, "Barbara"])
try db.execute(sql: "DELETE FROM person WHERE id = ?", arguments: [arthurId])
}
@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='osx' display-mode='rendered' buildActiveScheme='true'>
<timeline fileName='timeline.xctimeline'/>
</playground>
-38
View File
@@ -1,38 +0,0 @@
Pod::Spec.new do |s|
s.name = 'GRDB.swift'
s.version = '7.12.1'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.summary = 'A toolkit for SQLite databases, with a focus on application development.'
s.homepage = 'https://github.com/groue/GRDB.swift'
s.author = { 'Gwendal Roué' => 'gr@pierlis.com' }
s.source = { :git => 'https://github.com/groue/GRDB.swift.git', :tag => "v#{s.version}" }
s.module_name = 'GRDB'
s.swift_versions = ['6.1']
s.ios.deployment_target = '13.0'
s.osx.deployment_target = '10.15'
s.watchos.deployment_target = '7.0'
s.tvos.deployment_target = '13.0'
s.default_subspec = 'standard'
s.subspec 'standard' do |ss|
ss.source_files = 'GRDB/**/*.swift', 'Support/grdb_config.h'
ss.framework = 'Foundation'
ss.library = 'sqlite3'
ss.xcconfig = {
'OTHER_SWIFT_FLAGS' => '$(inherited) -D SQLITE_ENABLE_FTS5 -D GRDBFRAMEWORK',
}
end
s.subspec 'SQLCipher' do |ss|
ss.source_files = 'GRDB/**/*.swift', 'Support/SQLCipher_config.h'
ss.framework = 'Foundation'
ss.dependency 'SQLCipher', '>= 3.4.2'
ss.xcconfig = {
'OTHER_SWIFT_FLAGS' => '$(inherited) -D SQLITE_HAS_CODEC -D GRDBCIPHER -D SQLITE_ENABLE_FTS5',
'OTHER_CFLAGS' => '$(inherited) -DSQLITE_HAS_CODEC -DGRDBCIPHER -DSQLITE_ENABLE_FTS5',
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) SQLITE_HAS_CODEC=1 GRDBCIPHER=1 SQLITE_ENABLE_FTS5=1'
}
end
end
+431 -54
View File
@@ -7,13 +7,23 @@
objects = {
/* Begin PBXBuildFile section */
567DAF1C1EAB61ED00FC0928 /* grdb_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 567DAF141EAB61ED00FC0928 /* grdb_config.h */; settings = {ATTRIBUTES = (Private, ); }; };
567DAF1C1EAB61ED00FC0928 /* grdb_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 567DAF141EAB61ED00FC0928 /* grdb_config.h */; settings = {ATTRIBUTES = (Public, ); }; };
56D0F20C30C17218004DBD2B /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC3773F319C8CBB3004FCF85 /* GRDB.framework */; };
56E5D7FE1B4D422E00430942 /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC3773F319C8CBB3004FCF85 /* GRDB.framework */; };
7224817BA8FC2DD2316C7703 /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC3773F319C8CBB3004FCF85 /* GRDB.framework */; };
96FB7AD736D973E8E9A30380 /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC3773F319C8CBB3004FCF85 /* GRDB.framework */; };
DC2393C81ABE35F8003FF113 /* GRDB-Bridging.h in Headers */ = {isa = PBXBuildFile; fileRef = DC2393C61ABE35F8003FF113 /* GRDB-Bridging.h */; settings = {ATTRIBUTES = (Public, ); }; };
DC3773F919C8CBB3004FCF85 /* GRDB.h in Headers */ = {isa = PBXBuildFile; fileRef = DC3773F819C8CBB3004FCF85 /* GRDB.h */; settings = {ATTRIBUTES = (Public, ); }; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
56D0F20930C17218004DBD2B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = DC3773EA19C8CBB3004FCF85 /* Project object */;
proxyType = 1;
remoteGlobalIDString = DC3773F219C8CBB3004FCF85;
remoteInfo = GRDBOSX;
};
56E5D7FF1B4D422E00430942 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = DC3773EA19C8CBB3004FCF85 /* Project object */;
@@ -21,6 +31,20 @@
remoteGlobalIDString = DC3773F219C8CBB3004FCF85;
remoteInfo = GRDBOSX;
};
829B064D4975B60C0623B1B2 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = DC3773EA19C8CBB3004FCF85 /* Project object */;
proxyType = 1;
remoteGlobalIDString = DC3773F219C8CBB3004FCF85;
remoteInfo = GRDBOSX;
};
BDA5EFE64FE73E35F6D72D75 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = DC3773EA19C8CBB3004FCF85 /* Project object */;
proxyType = 1;
remoteGlobalIDString = DC3773F219C8CBB3004FCF85;
remoteInfo = GRDBOSX;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
@@ -33,11 +57,17 @@
569530FF1C9067CC00CF1A2B /* RecordCrashTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecordCrashTests.swift; sourceTree = "<group>"; };
569531001C9067CC00CF1A2B /* StatementColumnConvertibleCrashTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementColumnConvertibleCrashTests.swift; sourceTree = "<group>"; };
569531011C9067CC00CF1A2B /* StatementCrashTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementCrashTests.swift; sourceTree = "<group>"; };
5698C1C32CA844F4001C0EB0 /* GRDBTests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = GRDBTests.xcconfig; sourceTree = "<group>"; };
5698C1C32CA844F4001C0EB0 /* GRDBSwift5Tests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = GRDBSwift5Tests.xcconfig; sourceTree = "<group>"; };
56B8F49A1B4E2F3600C24296 /* GRDB.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = GRDB.xcconfig; sourceTree = "<group>"; };
56C48E731C9A9923005DF1D9 /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
56C494401ED7255500CC72AF /* GRDBDeploymentTarget.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = GRDBDeploymentTarget.xcconfig; sourceTree = "<group>"; };
56E5D7F91B4D422D00430942 /* GRDBTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
56D0F21130C17218004DBD2B /* GRDBSwift6ApproachableConcurrencyTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBSwift6ApproachableConcurrencyTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
56D0F21230C17218004DBD2B /* GRDBSwift6ApproachableConcurrencyTests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = GRDBSwift6ApproachableConcurrencyTests.xcconfig; sourceTree = "<group>"; };
56E5D7F91B4D422D00430942 /* GRDBSwift5Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBSwift5Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
6FC1DA2A6B5CD5D73C99E20E /* GRDBSwift6Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBSwift6Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
970266BC29B4DCD6A1700E21 /* GRDBSwift6MainActorIsolationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBSwift6MainActorIsolationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
9961981D015C33AB03B08547 /* GRDBSwift6Tests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = GRDBSwift6Tests.xcconfig; sourceTree = "<group>"; };
D585450E1D4D590FFEFBE90D /* GRDBSwift6MainActorIsolationTests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = GRDBSwift6MainActorIsolationTests.xcconfig; sourceTree = "<group>"; };
DC2393C61ABE35F8003FF113 /* GRDB-Bridging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GRDB-Bridging.h"; sourceTree = "<group>"; };
DC3773F319C8CBB3004FCF85 /* GRDB.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GRDB.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DC3773F719C8CBB3004FCF85 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -56,11 +86,31 @@
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
/* Begin PBXFileSystemSynchronizedRootGroup section */
56C883812FCC65300099DE9A /* GRDB */ = {isa = PBXFileSystemSynchronizedRootGroup; exceptions = (56C8842B2FCC65300099DE9A /* PBXFileSystemSynchronizedBuildFileExceptionSet */, ); explicitFileTypes = {}; explicitFolders = (); path = GRDB; sourceTree = "<group>"; };
56C887EB2FCC6B9A0099DE9A /* GRDBTests */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = GRDBTests; sourceTree = "<group>"; };
56A1E0012FD0A00000ABCDEF /* GRDBTestSupport */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = GRDBTestSupport; sourceTree = "<group>"; };
56C883812FCC65300099DE9A /* Sources/GRDB */ = {isa = PBXFileSystemSynchronizedRootGroup; exceptions = (56C8842B2FCC65300099DE9A /* PBXFileSystemSynchronizedBuildFileExceptionSet */, ); explicitFileTypes = {}; explicitFolders = (); path = Sources/GRDB; sourceTree = "<group>"; };
56C887EB2FCC6B9A0099DE9A /* GRDBSwift5Tests */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = GRDBSwift5Tests; sourceTree = "<group>"; };
56D0F1FC30C171E0004DBD2B /* GRDBSwift6ApproachableConcurrencyTests */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = GRDBSwift6ApproachableConcurrencyTests; sourceTree = "<group>"; };
56D0F20130C171E0004DBD2B /* GRDBSwift6MainActorIsolationTests */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = GRDBSwift6MainActorIsolationTests; sourceTree = "<group>"; };
56D0F20630C171E0004DBD2B /* GRDBSwift6Tests */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = GRDBSwift6Tests; sourceTree = "<group>"; };
/* End PBXFileSystemSynchronizedRootGroup section */
/* Begin PBXFrameworksBuildPhase section */
454694034CA70B4BF5803855 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
7224817BA8FC2DD2316C7703 /* GRDB.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
56D0F20B30C17218004DBD2B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
56D0F20C30C17218004DBD2B /* GRDB.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
56E5D7F61B4D422D00430942 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -76,6 +126,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
E0FF00E7AD6E7127766C65D2 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96FB7AD736D973E8E9A30380 /* GRDB.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
@@ -98,7 +156,11 @@
isa = PBXGroup;
children = (
569530FA1C9067CC00CF1A2B /* Crash */,
56C887EB2FCC6B9A0099DE9A /* GRDBTests */,
56C887EB2FCC6B9A0099DE9A /* GRDBSwift5Tests */,
56D0F1FC30C171E0004DBD2B /* GRDBSwift6ApproachableConcurrencyTests */,
56D0F20130C171E0004DBD2B /* GRDBSwift6MainActorIsolationTests */,
56D0F20630C171E0004DBD2B /* GRDBSwift6Tests */,
56A1E0012FD0A00000ABCDEF /* GRDBTestSupport */,
DC37740319C8CBB3004FCF85 /* Supporting Files */,
);
path = Tests;
@@ -107,7 +169,7 @@
DC3773E919C8CBB3004FCF85 = {
isa = PBXGroup;
children = (
56C883812FCC65300099DE9A /* GRDB */,
56C883812FCC65300099DE9A /* Sources/GRDB */,
DC10500F19C904DD00D8CA30 /* Tests */,
DC37743319C8CFCE004FCF85 /* Supporting Files */,
DC3773F419C8CBB3004FCF85 /* Products */,
@@ -121,7 +183,10 @@
isa = PBXGroup;
children = (
DC3773F319C8CBB3004FCF85 /* GRDB.framework */,
56E5D7F91B4D422D00430942 /* GRDBTests.xctest */,
56E5D7F91B4D422D00430942 /* GRDBSwift5Tests.xctest */,
56D0F21130C17218004DBD2B /* GRDBSwift6ApproachableConcurrencyTests.xctest */,
970266BC29B4DCD6A1700E21 /* GRDBSwift6MainActorIsolationTests.xctest */,
6FC1DA2A6B5CD5D73C99E20E /* GRDBSwift6Tests.xctest */,
);
name = Products;
sourceTree = "<group>";
@@ -143,8 +208,11 @@
56C48E731C9A9923005DF1D9 /* module.modulemap */,
DC3773F719C8CBB3004FCF85 /* Info.plist */,
56B8F49A1B4E2F3600C24296 /* GRDB.xcconfig */,
5698C1C32CA844F4001C0EB0 /* GRDBTests.xcconfig */,
56C494401ED7255500CC72AF /* GRDBDeploymentTarget.xcconfig */,
5698C1C32CA844F4001C0EB0 /* GRDBSwift5Tests.xcconfig */,
56D0F21230C17218004DBD2B /* GRDBSwift6ApproachableConcurrencyTests.xcconfig */,
D585450E1D4D590FFEFBE90D /* GRDBSwift6MainActorIsolationTests.xcconfig */,
9961981D015C33AB03B08547 /* GRDBSwift6Tests.xcconfig */,
);
name = "Supporting Files";
path = Support;
@@ -166,9 +234,51 @@
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
56E5D7F81B4D422D00430942 /* GRDBTests */ = {
137ECBDAB512C64A624D7C18 /* GRDBSwift6Tests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 56E5D8011B4D422E00430942 /* Build configuration list for PBXNativeTarget "GRDBTests" */;
buildConfigurationList = 18070F9F8DFD5096561CA62F /* Build configuration list for PBXNativeTarget "GRDBSwift6Tests" */;
buildPhases = (
677B998369A0C1FAA69120B7 /* Sources */,
E0FF00E7AD6E7127766C65D2 /* Frameworks */,
4F95D7921FDFB2BFED66B471 /* Resources */,
);
buildRules = (
);
dependencies = (
064B54476CF36B181327EDFC /* PBXTargetDependency */,
);
fileSystemSynchronizedGroups = (
56D0F20630C171E0004DBD2B /* GRDBSwift6Tests */,
);
name = GRDBSwift6Tests;
productName = GRDBOSXTests;
productReference = 6FC1DA2A6B5CD5D73C99E20E /* GRDBSwift6Tests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
56D0F20730C17218004DBD2B /* GRDBSwift6ApproachableConcurrencyTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 56D0F20E30C17218004DBD2B /* Build configuration list for PBXNativeTarget "GRDBSwift6ApproachableConcurrencyTests" */;
buildPhases = (
56D0F20A30C17218004DBD2B /* Sources */,
56D0F20B30C17218004DBD2B /* Frameworks */,
56D0F20D30C17218004DBD2B /* Resources */,
);
buildRules = (
);
dependencies = (
56D0F20830C17218004DBD2B /* PBXTargetDependency */,
);
fileSystemSynchronizedGroups = (
56D0F1FC30C171E0004DBD2B /* GRDBSwift6ApproachableConcurrencyTests */,
);
name = GRDBSwift6ApproachableConcurrencyTests;
productName = GRDBOSXTests;
productReference = 56D0F21130C17218004DBD2B /* GRDBSwift6ApproachableConcurrencyTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
56E5D7F81B4D422D00430942 /* GRDBSwift5Tests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 56E5D8011B4D422E00430942 /* Build configuration list for PBXNativeTarget "GRDBSwift5Tests" */;
buildPhases = (
56E5D7F51B4D422D00430942 /* Sources */,
56E5D7F61B4D422D00430942 /* Frameworks */,
@@ -180,11 +290,33 @@
56E5D8001B4D422E00430942 /* PBXTargetDependency */,
);
fileSystemSynchronizedGroups = (
56C887EB2FCC6B9A0099DE9A /* GRDBTests */,
56A1E0012FD0A00000ABCDEF /* GRDBTestSupport */,
56C887EB2FCC6B9A0099DE9A /* GRDBSwift5Tests */,
);
name = GRDBTests;
name = GRDBSwift5Tests;
productName = GRDBOSXTests;
productReference = 56E5D7F91B4D422D00430942 /* GRDBTests.xctest */;
productReference = 56E5D7F91B4D422D00430942 /* GRDBSwift5Tests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
AF4E64BCF2E3A40030D9C72E /* GRDBSwift6MainActorIsolationTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 44F4400344672EAFB8D49AC3 /* Build configuration list for PBXNativeTarget "GRDBSwift6MainActorIsolationTests" */;
buildPhases = (
8A3253E0E6F543AF8E4071B6 /* Sources */,
454694034CA70B4BF5803855 /* Frameworks */,
B5C3BD355A31911BA9D34C68 /* Resources */,
);
buildRules = (
);
dependencies = (
F0D310A8491E14866D6C126A /* PBXTargetDependency */,
);
fileSystemSynchronizedGroups = (
56D0F20130C171E0004DBD2B /* GRDBSwift6MainActorIsolationTests */,
);
name = GRDBSwift6MainActorIsolationTests;
productName = GRDBOSXTests;
productReference = 970266BC29B4DCD6A1700E21 /* GRDBSwift6MainActorIsolationTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
DC3773F219C8CBB3004FCF85 /* GRDB */ = {
@@ -202,7 +334,7 @@
dependencies = (
);
fileSystemSynchronizedGroups = (
56C883812FCC65300099DE9A /* GRDB */,
56C883812FCC65300099DE9A /* Sources/GRDB */,
);
name = GRDB;
productName = GRDB;
@@ -217,7 +349,7 @@
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 2600;
LastUpgradeCheck = 2720;
ORGANIZATIONNAME = "Gwendal Roué";
TargetAttributes = {
56E5D7F81B4D422D00430942 = {
@@ -244,12 +376,29 @@
projectRoot = "";
targets = (
DC3773F219C8CBB3004FCF85 /* GRDB */,
56E5D7F81B4D422D00430942 /* GRDBTests */,
56E5D7F81B4D422D00430942 /* GRDBSwift5Tests */,
56D0F20730C17218004DBD2B /* GRDBSwift6ApproachableConcurrencyTests */,
AF4E64BCF2E3A40030D9C72E /* GRDBSwift6MainActorIsolationTests */,
137ECBDAB512C64A624D7C18 /* GRDBSwift6Tests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
4F95D7921FDFB2BFED66B471 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
56D0F20D30C17218004DBD2B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
56E5D7F71B4D422D00430942 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -257,6 +406,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
B5C3BD355A31911BA9D34C68 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
DC3773F119C8CBB3004FCF85 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -289,6 +445,13 @@
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
56D0F20A30C17218004DBD2B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
56E5D7F51B4D422D00430942 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -296,6 +459,20 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
677B998369A0C1FAA69120B7 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
8A3253E0E6F543AF8E4071B6 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
DC3773EE19C8CBB3004FCF85 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -306,47 +483,32 @@
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
064B54476CF36B181327EDFC /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = DC3773F219C8CBB3004FCF85 /* GRDB */;
targetProxy = 829B064D4975B60C0623B1B2 /* PBXContainerItemProxy */;
};
56D0F20830C17218004DBD2B /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = DC3773F219C8CBB3004FCF85 /* GRDB */;
targetProxy = 56D0F20930C17218004DBD2B /* PBXContainerItemProxy */;
};
56E5D8001B4D422E00430942 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = DC3773F219C8CBB3004FCF85 /* GRDB */;
targetProxy = 56E5D7FF1B4D422E00430942 /* PBXContainerItemProxy */;
};
F0D310A8491E14866D6C126A /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = DC3773F219C8CBB3004FCF85 /* GRDB */;
targetProxy = BDA5EFE64FE73E35F6D72D75 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
56E5D8021B4D422E00430942 /* Debug */ = {
551FEC7C0085DBB820263A1D /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 5698C1C32CA844F4001C0EB0 /* GRDBTests.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
OTHER_SWIFT_FLAGS = "$(inherited) -D SQLITE_MODULE";
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_OBJC_BRIDGING_HEADER = "Tests/GRDBTests/GRDBTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4";
};
name = Debug;
};
56E5D8031B4D422E00430942 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 5698C1C32CA844F4001C0EB0 /* GRDBTests.xcconfig */;
baseConfigurationReference = 9961981D015C33AB03B08547 /* GRDBSwift6Tests.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
@@ -361,21 +523,205 @@
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
OTHER_SWIFT_FLAGS = "$(inherited) -D SQLITE_MODULE";
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OBJC_BRIDGING_HEADER = "Tests/GRDBTests/GRDBTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4";
};
name = Release;
};
56D0F20F30C17218004DBD2B /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 56D0F21230C17218004DBD2B /* GRDBSwift6ApproachableConcurrencyTests.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
};
name = Debug;
};
56D0F21030C17218004DBD2B /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 56D0F21230C17218004DBD2B /* GRDBSwift6ApproachableConcurrencyTests.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
};
name = Release;
};
56E5D8021B4D422E00430942 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 5698C1C32CA844F4001C0EB0 /* GRDBSwift5Tests.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
};
name = Debug;
};
56E5D8031B4D422E00430942 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 5698C1C32CA844F4001C0EB0 /* GRDBSwift5Tests.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
};
name = Release;
};
B1E19278BC423F6FE01ECE17 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = D585450E1D4D590FFEFBE90D /* GRDBSwift6MainActorIsolationTests.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
};
name = Debug;
};
C7C3656B2B513F520BC9764E /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = D585450E1D4D590FFEFBE90D /* GRDBSwift6MainActorIsolationTests.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
};
name = Release;
};
DB8B1F9D519E70A9C2BEB816 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 9961981D015C33AB03B08547 /* GRDBSwift6Tests.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
};
name = Debug;
};
DC37740719C8CBB3004FCF85 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -410,6 +756,7 @@
DEAD_CODE_STRIPPING = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
@@ -468,6 +815,7 @@
DEAD_CODE_STRIPPING = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
@@ -502,6 +850,7 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
INFOPLIST_FILE = Support/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
@@ -535,6 +884,7 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
INFOPLIST_FILE = Support/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
@@ -556,7 +906,34 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
56E5D8011B4D422E00430942 /* Build configuration list for PBXNativeTarget "GRDBTests" */ = {
18070F9F8DFD5096561CA62F /* Build configuration list for PBXNativeTarget "GRDBSwift6Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
DB8B1F9D519E70A9C2BEB816 /* Debug */,
551FEC7C0085DBB820263A1D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
44F4400344672EAFB8D49AC3 /* Build configuration list for PBXNativeTarget "GRDBSwift6MainActorIsolationTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
B1E19278BC423F6FE01ECE17 /* Debug */,
C7C3656B2B513F520BC9764E /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
56D0F20E30C17218004DBD2B /* Build configuration list for PBXNativeTarget "GRDBSwift6ApproachableConcurrencyTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
56D0F20F30C17218004DBD2B /* Debug */,
56D0F21030C17218004DBD2B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
56E5D8011B4D422E00430942 /* Build configuration list for PBXNativeTarget "GRDBSwift5Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
56E5D8021B4D422E00430942 /* Debug */,
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2600"
LastUpgradeVersion = "2720"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -29,8 +29,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56E5D7F81B4D422D00430942"
BuildableName = "GRDBTests.xctest"
BlueprintName = "GRDBTests"
BuildableName = "GRDBSwift5Tests.xctest"
BlueprintName = "GRDBSwift5Tests"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</BuildActionEntry>
@@ -49,8 +49,38 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56E5D7F81B4D422D00430942"
BuildableName = "GRDBTests.xctest"
BlueprintName = "GRDBTests"
BuildableName = "GRDBSwift5Tests.xctest"
BlueprintName = "GRDBSwift5Tests"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "56D0F20730C17218004DBD2B"
BuildableName = "GRDBSwift6ApproachableConcurrencyTests.xctest"
BlueprintName = "GRDBSwift6ApproachableConcurrencyTests"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AF4E64BCF2E3A40030D9C72E"
BuildableName = "GRDBSwift6MainActorIsolationTests.xctest"
BlueprintName = "GRDBSwift6MainActorIsolationTests"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "137ECBDAB512C64A624D7C18"
BuildableName = "GRDBSwift6Tests.xctest"
BlueprintName = "GRDBSwift6Tests"
ReferencedContainer = "container:GRDB.xcodeproj">
</BuildableReference>
</TestableReference>
+1 -20
View File
@@ -1,22 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<Group
location = "group:Documentation/Playgrounds"
name = "Playgrounds">
<FileRef
location = "group:Tour.playground">
</FileRef>
<FileRef
location = "group:TransactionObserver.playground">
</FileRef>
<FileRef
location = "group:Associations.playground">
</FileRef>
<FileRef
location = "group:MyPlayground.playground">
</FileRef>
</Group>
<FileRef
location = "group:BRAG.md">
</FileRef>
@@ -30,7 +14,7 @@
location = "group:TODO.md">
</FileRef>
<FileRef
location = "group:Documentation/ReleaseProcess.md">
location = "group:RELEASING.md">
</FileRef>
<FileRef
location = "group:Makefile">
@@ -41,9 +25,6 @@
<FileRef
location = "group:GRDBCustom.xcodeproj">
</FileRef>
<FileRef
location = "group:Tests/Performance/GRDBProfiling/GRDBProfiling.xcodeproj">
</FileRef>
<FileRef
location = "group:Documentation/DemoApps/GRDBDemo/GRDBDemo.xcodeproj">
</FileRef>
-20
View File
@@ -1,20 +0,0 @@
// Fixits for changes introduced by GRDB 7.0.0
// swiftlint:disable all
extension Configuration {
@available(*, unavailable, message: "The default transaction kind is now automatically managed.")
public var defaultTransactionKind: Database.TransactionKind {
get { preconditionFailure() }
set { preconditionFailure() }
}
}
@available(*, unavailable, message: "DatabaseFuture has been removed.")
public class DatabaseFuture<Value> { }
extension DatabasePool {
@available(*, unavailable, message: "concurrentRead has been removed. Use `asyncConcurrentRead` instead.")
public func concurrentRead<T>(_ value: @escaping (Database) throws -> T) -> DatabaseFuture<T> { preconditionFailure() }
}
// swiftlint:enable all
@@ -1,676 +0,0 @@
// MARK: - Insert Callbacks
extension MutablePersistableRecord {
@inline(__always)
@inlinable
public mutating func willInsert(_ db: Database) throws { }
@inline(__always)
@inlinable
public func aroundInsert(_ db: Database, insert: () throws -> InsertionSuccess) throws {
_ = try insert()
}
@inline(__always)
@inlinable
public mutating func didInsert(_ inserted: InsertionSuccess) { }
}
// MARK: - Insert
extension MutablePersistableRecord {
/// Executes an `INSERT` statement.
///
/// For example:
///
/// ```swift
/// try dbQueue.write { db in
/// var player = Player(name: "Arthur")
/// try player.insert(db)
/// }
/// ```
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution. If
/// nil, <doc:/MutablePersistableRecord/persistenceConflictPolicy-1isyv>
/// is used.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or any
/// error thrown by the persistence callbacks defined by the record type.
@inlinable // allow specialization so that empty callbacks are removed
public mutating func insert(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution? = nil)
throws
{
try willSave(db)
var saved: PersistenceSuccess?
try aroundSave(db) {
let inserted = try insertWithCallbacks(db, onConflict: conflictResolution)
saved = PersistenceSuccess(inserted)
return saved!
}
guard let saved else {
try persistenceCallbackMisuse("aroundSave")
}
didSave(saved)
}
/// Executes an `INSERT` statement, and returns the inserted record.
///
/// For example:
///
/// ```swift
/// let player = Player(name: "Arthur")
/// let insertedPlayer = try await dbQueue.write { [player] db in
/// try player.inserted(db)
/// }
/// ```
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution. If
/// nil, <doc:/MutablePersistableRecord/persistenceConflictPolicy-1isyv>
/// is used.
/// - returns: The inserted record.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or any
/// error thrown by the persistence callbacks defined by the record type.
@inlinable // allow specialization so that empty callbacks are removed
public func inserted(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution? = nil)
throws -> Self
{
var result = self
try result.insert(db, onConflict: conflictResolution)
return result
}
}
// MARK: - Insert and Fetch
extension MutablePersistableRecord {
#if GRDBCUSTOMSQLITE || SQLITE_HAS_CODEC
/// Executes an `INSERT RETURNING` statement, and returns a new record built
/// from the inserted row.
///
/// This method is equivalent to ``insertAndFetch(_:onConflict:as:)``,
/// with `Self` as the `returnedType` argument:
///
/// ```swift
/// // Equivalent
/// let insertedPlayer = try player.insertAndFetch(db)
/// let insertedPlayer = try player.insertAndFetch(db, as: Player.self)
/// ```
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution. If
/// nil, <doc:/MutablePersistableRecord/persistenceConflictPolicy-1isyv>
/// is used.
/// - returns: The inserted record.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or any
/// error thrown by the persistence callbacks defined by the record type.
/// ``RecordError/recordNotFound(databaseTableName:key:)`` can be
/// thrown if the insertion failed due to the IGNORE conflict policy.
@inlinable // allow specialization so that empty callbacks are removed
public func insertAndFetch(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution? = nil)
throws -> Self
where Self: FetchableRecord
{
var result = self
return try result.insertAndFetch(db, onConflict: conflictResolution, as: Self.self)
}
/// Executes an `INSERT RETURNING` statement, and returns a new record built
/// from the inserted row.
///
/// This method helps deal with default column values and
/// generated columns.
///
/// For example:
///
/// ```swift
/// // A table with an auto-incremented primary key and a default value
/// try dbQueue.write { db in
/// try db.execute(sql: """
/// CREATE TABLE player(
/// id INTEGER PRIMARY KEY AUTOINCREMENT,
/// name TEXT,
/// score INTEGER DEFAULT 1000)
/// """)
/// }
///
/// // A player with partial database information
/// struct PartialPlayer: MutablePersistableRecord {
/// static let databaseTableName = "player"
/// var name: String
/// }
///
/// // A full player, with all database information
/// struct Player: TableRecord, FetchableRecord {
/// var id: Int64
/// var name: String
/// var score: Int
/// }
///
/// // Insert a partial player, get a full one
/// try dbQueue.write { db in
/// var partialPlayer = PartialPlayer(name: "Alice")
///
/// // INSERT INTO player (name) VALUES ('Alice') RETURNING *
/// let player = try partialPlayer.insertAndFetch(db, as: Player.self)
/// print(player.id) // The inserted id
/// print(player.name) // The inserted name
/// print(player.score) // The default score
/// }
/// ```
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution. If
/// nil, <doc:/MutablePersistableRecord/persistenceConflictPolicy-1isyv>
/// is used.
/// - parameter returnedType: The type of the returned record.
/// - returns: A record of type `returnedType`.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or any
/// error thrown by the persistence callbacks defined by the record type.
/// ``RecordError/recordNotFound(databaseTableName:key:)`` can be
/// thrown if the insertion failed due to the IGNORE conflict policy.
@inlinable // allow specialization so that empty callbacks are removed
public mutating func insertAndFetch<T: FetchableRecord & TableRecord>(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution? = nil,
as returnedType: T.Type)
throws -> T
{
let record = self
return try insertAndFetch(db, onConflict: conflictResolution, selection: T.databaseSelection) {
if let result = try T.fetchOne($0) {
return result
}
throw record.recordNotFound(db)
}
}
/// Executes an `INSERT RETURNING` statement, and returns the selected
/// columns from the inserted row.
///
/// This method helps deal with default column values and
/// generated columns.
///
/// For example:
///
/// ```swift
/// // A table with an auto-incremented primary key and a default value
/// try dbQueue.write { db in
/// try db.execute(sql: """
/// CREATE TABLE player(
/// id INTEGER PRIMARY KEY AUTOINCREMENT,
/// name TEXT,
/// score INTEGER DEFAULT 1000)
/// """)
/// }
///
/// // A player with partial database information
/// struct PartialPlayer: MutablePersistableRecord {
/// static let databaseTableName = "player"
/// var name: String
/// }
///
/// // Insert a partial player, get the inserted score
/// try dbQueue.write { db in
/// var partialPlayer = PartialPlayer(name: "Alice")
///
/// // INSERT INTO player (name) VALUES ('Alice') RETURNING score
/// let score = try partialPlayer.insertAndFetch(db, selection: [Column("score")]) { statement in
/// try Int.fetchOne(statement)
/// }
/// print(score) // The inserted score
/// }
/// ```
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution. If
/// nil, <doc:/MutablePersistableRecord/persistenceConflictPolicy-1isyv>
/// is used.
/// - parameter selection: The returned columns (must not be empty).
/// - parameter fetch: A closure that executes its ``Statement`` argument.
/// If the conflict policy is `IGNORE`, the statement may return no row.
/// - returns: The result of the `fetch` function.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or any
/// error thrown by the persistence callbacks defined by the record type.
/// - precondition: `selection` is not empty.
@inlinable // allow specialization so that empty callbacks are removed
public mutating func insertAndFetch<T>(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution? = nil,
selection: [any SQLSelectable],
fetch: (Statement) throws -> T)
throws -> T
{
GRDBPrecondition(!selection.isEmpty, "Invalid empty selection")
try willSave(db)
var success: (inserted: InsertionSuccess, returned: T)?
try aroundSave(db) {
success = try insertAndFetchWithCallbacks(
db, onConflict: conflictResolution,
selection: selection,
fetch: fetch)
return PersistenceSuccess(success!.inserted)
}
guard let success else {
try persistenceCallbackMisuse("aroundSave")
}
didSave(PersistenceSuccess(success.inserted))
return success.returned
}
/// Executes an `INSERT RETURNING` statement, and returns the selected
/// columns from the inserted row.
///
/// This method helps deal with default column values and
/// generated columns.
///
/// For example:
///
/// ```swift
/// // A table with an auto-incremented primary key and a default value
/// try dbQueue.write { db in
/// try db.execute(sql: """
/// CREATE TABLE player(
/// id INTEGER PRIMARY KEY AUTOINCREMENT,
/// name TEXT,
/// score INTEGER DEFAULT 1000)
/// """)
/// }
///
/// // A player with partial database information
/// struct PartialPlayer: MutablePersistableRecord {
/// static let databaseTableName = "player"
/// var name: String
///
/// enum Columns {
/// static let score = Column("score")
/// }
/// }
///
/// // Insert a partial player, get the inserted score
/// try dbQueue.write { db in
/// var partialPlayer = PartialPlayer(name: "Alice")
///
/// // INSERT INTO player (name) VALUES ('Alice') RETURNING score
/// let score = try partialPlayer.insertAndFetch(db) { statement in
/// try Int.fetchOne(statement)
/// } select: {
/// [$0.score]
/// }
/// print(score) // The inserted score
/// }
/// ```
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution. If
/// nil, <doc:/MutablePersistableRecord/persistenceConflictPolicy-1isyv>
/// is used.
/// - parameter fetch: A closure that executes its ``Statement`` argument.
/// If the conflict policy is `IGNORE`, the statement may return no row.
/// - parameter select: A closure that returns the returned columns
/// (must not be empty).
/// - returns: The result of the `fetch` function.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or any
/// error thrown by the persistence callbacks defined by the record type.
/// - precondition: The result of `select` is not empty.
@inlinable // allow specialization so that empty callbacks are removed
public mutating func insertAndFetch<T>(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution? = nil,
fetch: (Statement) throws -> T,
select: (DatabaseComponents) throws -> [any SQLSelectable]
) throws -> T
where Self: TableRecord
{
try insertAndFetch(db, onConflict: conflictResolution, selection: select(Self.databaseComponents), fetch: fetch)
}
#else
/// Executes an `INSERT RETURNING` statement, and returns a new record built
/// from the inserted row.
///
/// This method is equivalent to ``insertAndFetch(_:onConflict:as:)``,
/// with `Self` as the `returnedType` argument:
///
/// ```swift
/// // Equivalent
/// let insertedPlayer = try player.insertAndFetch(db)
/// let insertedPlayer = try player.insertAndFetch(db, as: Player.self)
/// ```
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution. If
/// nil, <doc:/MutablePersistableRecord/persistenceConflictPolicy-1isyv>
/// is used.
/// - returns: The inserted record.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or any
/// error thrown by the persistence callbacks defined by the record type.
/// ``RecordError/recordNotFound(databaseTableName:key:)`` can be
/// thrown if the insertion failed due to the IGNORE conflict policy.
@inlinable // allow specialization so that empty callbacks are removed
@available(iOS 15, macOS 12, tvOS 15, watchOS 8, *) // SQLite 3.35.0+
public func insertAndFetch(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution? = nil)
throws -> Self
where Self: FetchableRecord
{
var result = self
return try result.insertAndFetch(db, onConflict: conflictResolution, as: Self.self)
}
/// Executes an `INSERT RETURNING` statement, and returns a new record built
/// from the inserted row.
///
/// This method helps deal with default column values and
/// generated columns.
///
/// For example:
///
/// ```swift
/// // A table with an auto-incremented primary key and a default value
/// try dbQueue.write { db in
/// try db.execute(sql: """
/// CREATE TABLE player(
/// id INTEGER PRIMARY KEY AUTOINCREMENT,
/// name TEXT,
/// score INTEGER DEFAULT 1000)
/// """)
/// }
///
/// // A player with partial database information
/// struct PartialPlayer: MutablePersistableRecord {
/// static let databaseTableName = "player"
/// var name: String
/// }
///
/// // A full player, with all database information
/// struct Player: TableRecord, FetchableRecord {
/// var id: Int64
/// var name: String
/// var score: Int
/// }
///
/// // Insert a partial player, get a full one
/// try dbQueue.write { db in
/// var partialPlayer = PartialPlayer(name: "Alice")
///
/// // INSERT INTO player (name) VALUES ('Alice') RETURNING *
/// let player = try partialPlayer.insertAndFetch(db, as: Player.self)
/// print(player.id) // The inserted id
/// print(player.name) // The inserted name
/// print(player.score) // The default score
/// }
/// ```
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution. If
/// nil, <doc:/MutablePersistableRecord/persistenceConflictPolicy-1isyv>
/// is used.
/// - parameter returnedType: The type of the returned record.
/// - returns: A record of type `returnedType`.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or any
/// error thrown by the persistence callbacks defined by the record type.
/// ``RecordError/recordNotFound(databaseTableName:key:)`` can be
/// thrown if the insertion failed due to the IGNORE conflict policy.
@inlinable // allow specialization so that empty callbacks are removed
@available(iOS 15, macOS 12, tvOS 15, watchOS 8, *) // SQLite 3.35.0+
public mutating func insertAndFetch<T: FetchableRecord & TableRecord>(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution? = nil,
as returnedType: T.Type)
throws -> T
{
let record = self
return try insertAndFetch(db, onConflict: conflictResolution, selection: T.databaseSelection) {
if let result = try T.fetchOne($0) {
return result
}
throw record.recordNotFound(db)
}
}
/// Executes an `INSERT RETURNING` statement, and returns the selected
/// columns from the inserted row.
///
/// This method helps deal with default column values and
/// generated columns.
///
/// For example:
///
/// ```swift
/// // A table with an auto-incremented primary key and a default value
/// try dbQueue.write { db in
/// try db.execute(sql: """
/// CREATE TABLE player(
/// id INTEGER PRIMARY KEY AUTOINCREMENT,
/// name TEXT,
/// score INTEGER DEFAULT 1000)
/// """)
/// }
///
/// // A player with partial database information
/// struct PartialPlayer: MutablePersistableRecord {
/// static let databaseTableName = "player"
/// var name: String
/// }
///
/// // Insert a partial player, get the inserted score
/// try dbQueue.write { db in
/// var partialPlayer = PartialPlayer(name: "Alice")
///
/// // INSERT INTO player (name) VALUES ('Alice') RETURNING score
/// let score = try partialPlayer.insertAndFetch(db, selection: [Column("score")]) { statement in
/// try Int.fetchOne(statement)
/// }
/// print(score) // The inserted score
/// }
/// ```
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution. If
/// nil, <doc:/MutablePersistableRecord/persistenceConflictPolicy-1isyv>
/// is used.
/// - parameter selection: The returned columns (must not be empty).
/// - parameter fetch: A closure that executes its ``Statement`` argument.
/// If the conflict policy is `IGNORE`, the statement may return no row.
/// - returns: The result of the `fetch` function.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or any
/// error thrown by the persistence callbacks defined by the record type.
/// - precondition: `selection` is not empty.
@inlinable // allow specialization so that empty callbacks are removed
@available(iOS 15, macOS 12, tvOS 15, watchOS 8, *) // SQLite 3.35.0+
public mutating func insertAndFetch<T>(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution? = nil,
selection: [any SQLSelectable],
fetch: (Statement) throws -> T)
throws -> T
{
GRDBPrecondition(!selection.isEmpty, "Invalid empty selection")
try willSave(db)
var success: (inserted: InsertionSuccess, returned: T)?
try aroundSave(db) {
success = try insertAndFetchWithCallbacks(
db, onConflict: conflictResolution,
selection: selection,
fetch: fetch)
return PersistenceSuccess(success!.inserted)
}
guard let success else {
try persistenceCallbackMisuse("aroundSave")
}
didSave(PersistenceSuccess(success.inserted))
return success.returned
}
/// Executes an `INSERT RETURNING` statement, and returns the selected
/// columns from the inserted row.
///
/// This method helps deal with default column values and
/// generated columns.
///
/// For example:
///
/// ```swift
/// // A table with an auto-incremented primary key and a default value
/// try dbQueue.write { db in
/// try db.execute(sql: """
/// CREATE TABLE player(
/// id INTEGER PRIMARY KEY AUTOINCREMENT,
/// name TEXT,
/// score INTEGER DEFAULT 1000)
/// """)
/// }
///
/// // A player with partial database information
/// struct PartialPlayer: MutablePersistableRecord {
/// static let databaseTableName = "player"
/// var name: String
///
/// enum Columns {
/// static let score = Column("score")
/// }
/// }
///
/// // Insert a partial player, get the inserted score
/// try dbQueue.write { db in
/// var partialPlayer = PartialPlayer(name: "Alice")
///
/// // INSERT INTO player (name) VALUES ('Alice') RETURNING score
/// let score = try partialPlayer.insertAndFetch(db) { statement in
/// try Int.fetchOne(statement)
/// } select: {
/// [$0.score]
/// }
/// print(score) // The inserted score
/// }
/// ```
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution. If
/// nil, <doc:/MutablePersistableRecord/persistenceConflictPolicy-1isyv>
/// is used.
/// - parameter fetch: A closure that executes its ``Statement`` argument.
/// If the conflict policy is `IGNORE`, the statement may return no row.
/// - parameter select: A closure that returns the returned columns
/// (must not be empty).
/// - returns: The result of the `fetch` function.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or any
/// error thrown by the persistence callbacks defined by the record type.
/// - precondition: The result of `select` is not empty.
@inlinable // allow specialization so that empty callbacks are removed
@available(iOS 15, macOS 12, tvOS 15, watchOS 8, *) // SQLite 3.35.0+
public mutating func insertAndFetch<T>(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution? = nil,
fetch: (Statement) throws -> T,
select: (DatabaseComponents) throws -> [any SQLSelectable]
) throws -> T
where Self: TableRecord
{
try insertAndFetch(
db,
onConflict: conflictResolution,
selection: select(Self.databaseComponents),
fetch: fetch)
}
#endif
}
// MARK: - Internals
extension MutablePersistableRecord {
/// Executes an `INSERT` statement, and runs insertion callbacks.
@inlinable // allow specialization so that empty callbacks are removed
mutating func insertWithCallbacks(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution?)
throws -> InsertionSuccess
{
let (inserted, _) = try insertAndFetchWithCallbacks(db, onConflict: conflictResolution, selection: []) {
// Nothing to fetch
try $0.execute()
}
return inserted
}
/// Executes an `INSERT` statement, with `RETURNING` clause if `selection`
/// is not empty, and runs insertion callbacks.
@inlinable // allow specialization so that empty callbacks are removed
mutating func insertAndFetchWithCallbacks<T>(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution?,
selection: [any SQLSelectable],
fetch: (Statement) throws -> T)
throws -> (InsertionSuccess, T)
{
try willInsert(db)
var success: (inserted: InsertionSuccess, returned: T)?
try aroundInsert(db) {
success = try insertAndFetchWithoutCallbacks(
db, onConflict: conflictResolution,
selection: selection,
fetch: fetch)
return success!.inserted
}
guard let success else {
try persistenceCallbackMisuse("aroundInsert")
}
didInsert(success.inserted)
return success
}
/// Executes an `INSERT` statement, with `RETURNING` clause if `selection`
/// is not empty, and DOES NOT run insertion callbacks.
@usableFromInline
func insertAndFetchWithoutCallbacks<T>(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution?,
selection: [any SQLSelectable],
fetch: (Statement) throws -> T)
throws -> (InsertionSuccess, T)
{
let conflictResolution = conflictResolution ?? type(of: self)
.persistenceConflictPolicy
.conflictResolutionForInsert
let dao = try DAO(db, self)
let statement = try dao.insertStatement(
db,
onConflict: conflictResolution,
returning: selection)
let returned = try fetch(statement)
let rowIDColumn = dao.primaryKey.rowIDColumn
let rowid = db.lastInsertedRowID
// Update the persistenceContainer with the inserted rowid.
// This allows the Record class to set its `hasDatabaseChanges` property
// to false in its `aroundInsert` callback.
var persistenceContainer = dao.persistenceContainer
if let rowIDColumn {
persistenceContainer[rowIDColumn] = rowid
}
let inserted = InsertionSuccess(
rowID: rowid,
rowIDColumn: rowIDColumn,
persistenceContainer: persistenceContainer)
return (inserted, returned)
}
}
@@ -1,419 +0,0 @@
// MARK: - Save Callbacks
extension MutablePersistableRecord {
@inline(__always)
@inlinable
public func willSave(_ db: Database) throws { }
@inline(__always)
@inlinable
public func aroundSave(_ db: Database, save: () throws -> PersistenceSuccess) throws {
_ = try save()
}
@inline(__always)
@inlinable
public func didSave(_ saved: PersistenceSuccess) { }
}
// MARK: - Save
extension MutablePersistableRecord {
/// Executes an `INSERT` or `UPDATE` statement.
///
/// If the receiver has a non-nil primary key and a matching row in the
/// database, this method performs an update.
///
/// Otherwise, performs an insert.
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution. If
/// nil, <doc:/MutablePersistableRecord/persistenceConflictPolicy-1isyv>
/// is used.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or any
/// error thrown by the persistence callbacks defined by the record type.
@inlinable // allow specialization so that empty callbacks are removed
public mutating func save(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution? = nil)
throws
{
try willSave(db)
var saved: PersistenceSuccess?
try aroundSave(db) {
saved = try updateOrInsertWithCallbacks(db, onConflict: conflictResolution)
return saved!
}
guard let saved else {
try persistenceCallbackMisuse("aroundSave")
}
didSave(saved)
}
/// Executes an `INSERT` or `UPDATE` statement, and returns the
/// saved record.
///
/// Usage:
///
/// let player = Player(id: nil, name: "Arthur")
/// let savedPlayer = try dbQueue.write { db in
/// try player.saved(db)
/// }
/// print(player.id) // nil
/// print(savedPlayer.id) // some id
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution. If
/// nil, <doc:/MutablePersistableRecord/persistenceConflictPolicy-1isyv>
/// is used.
/// - returns: The saved record.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or any
/// error thrown by the persistence callbacks defined by the record type.
@inlinable // allow specialization so that empty callbacks are removed
public func saved(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution? = nil)
throws -> Self
{
var result = self
try result.save(db, onConflict: conflictResolution)
return result
}
}
// MARK: - Save and Fetch
extension MutablePersistableRecord {
#if GRDBCUSTOMSQLITE || SQLITE_HAS_CODEC
/// Executes an `INSERT RETURNING` or `UPDATE RETURNING` statement, and
/// returns a new record built from the saved row.
///
/// If the receiver has a non-nil primary key and a matching row in the
/// database, this method performs an update. Otherwise, it performs
/// an insert.
///
/// This method helps deal with default column values and
/// generated columns.
///
/// For example:
///
/// let player: Player = ...
/// let savedPlayer = try player.saveAndFetch(db)
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution. If
/// nil, <doc:/MutablePersistableRecord/persistenceConflictPolicy-1isyv>
/// is used.
/// - returns: The saved record.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or any
/// error thrown by the persistence callbacks defined by the record type.
/// ``RecordError/recordNotFound(databaseTableName:key:)`` can be
/// thrown if the database changes fail due to the IGNORE conflict policy.
@inlinable // allow specialization so that empty callbacks are removed
public func saveAndFetch(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution? = nil)
throws -> Self
where Self: FetchableRecord
{
var result = self
return try result.saveAndFetch(db, onConflict: conflictResolution, as: Self.self)
}
/// Executes an `INSERT RETURNING` or `UPDATE RETURNING` statement, and
/// returns a new record built from the saved row.
///
/// If the receiver has a non-nil primary key and a matching row in the
/// database, this method performs an update. Otherwise, it performs
/// an insert.
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution. If
/// nil, <doc:/MutablePersistableRecord/persistenceConflictPolicy-1isyv>
/// is used.
/// - parameter returnedType: The type of the returned record.
/// - returns: A record of type `returnedType`.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or any
/// error thrown by the persistence callbacks defined by the record type.
/// ``RecordError/recordNotFound(databaseTableName:key:)`` can be
/// thrown if the database changes fail due to the IGNORE conflict policy.
@inlinable // allow specialization so that empty callbacks are removed
public mutating func saveAndFetch<T: FetchableRecord & TableRecord>(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution? = nil,
as returnedType: T.Type)
throws -> T
{
try willSave(db)
var success: (saved: PersistenceSuccess, returned: T)?
try aroundSave(db) {
let record = self
success = try updateOrInsertAndFetchWithCallbacks(
db, onConflict: conflictResolution,
selection: T.databaseSelection,
fetch: {
if let result = try T.fetchOne($0) {
return result
}
throw record.recordNotFound(db)
})
return success!.saved
}
guard let success else {
try persistenceCallbackMisuse("aroundSave")
}
didSave(success.saved)
return success.returned
}
/// Executes an `INSERT RETURNING` or `UPDATE RETURNING` statement, and
/// returns the selected columns from the saved row.
///
/// If the receiver has a non-nil primary key and a matching row in the
/// database, this method performs an update. Otherwise, it performs
/// an insert.
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution. If
/// nil, <doc:/MutablePersistableRecord/persistenceConflictPolicy-1isyv>
/// is used.
/// - parameter selection: The returned columns (must not be empty).
/// - parameter fetch: A function that executes its ``Statement`` argument.
/// - returns: The result of the `fetch` function.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or any
/// error thrown by the persistence callbacks defined by the record type.
/// - precondition: `selection` is not empty.
@inlinable // allow specialization so that empty callbacks are removed
public mutating func saveAndFetch<T>(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution? = nil,
selection: [any SQLSelectable],
fetch: (Statement) throws -> T)
throws -> T
{
GRDBPrecondition(!selection.isEmpty, "Invalid empty selection")
try willSave(db)
var success: (saved: PersistenceSuccess, returned: T)?
try aroundSave(db) {
success = try updateOrInsertAndFetchWithCallbacks(
db, onConflict: conflictResolution,
selection: selection,
fetch: fetch)
return success!.saved
}
guard let success else {
try persistenceCallbackMisuse("aroundSave")
}
didSave(success.saved)
return success.returned
}
#else
/// Executes an `INSERT RETURNING` or `UPDATE RETURNING` statement, and
/// returns a new record built from the saved row.
///
/// If the receiver has a non-nil primary key and a matching row in the
/// database, this method performs an update. Otherwise, it performs
/// an insert.
///
/// This method helps deal with default column values and
/// generated columns.
///
/// For example:
///
/// let player: Player = ...
/// let savedPlayer = try player.saveAndFetch(db)
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution. If
/// nil, <doc:/MutablePersistableRecord/persistenceConflictPolicy-1isyv>
/// is used.
/// - returns: The saved record.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or any
/// error thrown by the persistence callbacks defined by the record type.
/// ``RecordError/recordNotFound(databaseTableName:key:)`` can be
/// thrown if the database changes fail due to the IGNORE conflict policy.
@inlinable // allow specialization so that empty callbacks are removed
@available(iOS 15, macOS 12, tvOS 15, watchOS 8, *) // SQLite 3.35.0+
public func saveAndFetch(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution? = nil)
throws -> Self
where Self: FetchableRecord
{
var result = self
return try result.saveAndFetch(db, onConflict: conflictResolution, as: Self.self)
}
/// Executes an `INSERT RETURNING` or `UPDATE RETURNING` statement, and
/// returns a new record built from the saved row.
///
/// If the receiver has a non-nil primary key and a matching row in the
/// database, this method performs an update. Otherwise, it performs
/// an insert.
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution. If
/// nil, <doc:/MutablePersistableRecord/persistenceConflictPolicy-1isyv>
/// is used.
/// - parameter returnedType: The type of the returned record.
/// - returns: A record of type `returnedType`.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or any
/// error thrown by the persistence callbacks defined by the record type.
/// ``RecordError/recordNotFound(databaseTableName:key:)`` can be
/// thrown if the database changes fail due to the IGNORE conflict policy.
@inlinable // allow specialization so that empty callbacks are removed
@available(iOS 15, macOS 12, tvOS 15, watchOS 8, *) // SQLite 3.35.0+
public mutating func saveAndFetch<T: FetchableRecord & TableRecord>(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution? = nil,
as returnedType: T.Type)
throws -> T
{
try willSave(db)
var success: (saved: PersistenceSuccess, returned: T)?
try aroundSave(db) {
let record = self
success = try updateOrInsertAndFetchWithCallbacks(
db, onConflict: conflictResolution,
selection: T.databaseSelection,
fetch: {
if let result = try T.fetchOne($0) {
return result
}
throw record.recordNotFound(db)
})
return success!.saved
}
guard let success else {
try persistenceCallbackMisuse("aroundSave")
}
didSave(success.saved)
return success.returned
}
/// Executes an `INSERT RETURNING` or `UPDATE RETURNING` statement, and
/// returns the selected columns from the saved row.
///
/// If the receiver has a non-nil primary key and a matching row in the
/// database, this method performs an update. Otherwise, it performs
/// an insert.
///
/// - parameter db: A database connection.
/// - parameter conflictResolution: A policy for conflict resolution. If
/// nil, <doc:/MutablePersistableRecord/persistenceConflictPolicy-1isyv>
/// is used.
/// - parameter selection: The returned columns (must not be empty).
/// - parameter fetch: A function that executes its ``Statement`` argument.
/// - returns: The result of the `fetch` function.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs, or any
/// error thrown by the persistence callbacks defined by the record type.
/// - precondition: `selection` is not empty.
@inlinable // allow specialization so that empty callbacks are removed
@available(iOS 15, macOS 12, tvOS 15, watchOS 8, *) // SQLite 3.35.0+
public mutating func saveAndFetch<T>(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution? = nil,
selection: [any SQLSelectable],
fetch: (Statement) throws -> T)
throws -> T
{
GRDBPrecondition(!selection.isEmpty, "Invalid empty selection")
try willSave(db)
var success: (saved: PersistenceSuccess, returned: T)?
try aroundSave(db) {
success = try updateOrInsertAndFetchWithCallbacks(
db, onConflict: conflictResolution,
selection: selection,
fetch: fetch)
return success!.saved
}
guard let success else {
try persistenceCallbackMisuse("aroundSave")
}
didSave(success.saved)
return success.returned
}
#endif
}
// MARK: - Internal
extension MutablePersistableRecord {
/// Executes an `UPDATE` or `INSERT` statement, and runs insertion or
/// update callbacks.
@inlinable // allow specialization so that empty callbacks are removed
mutating func updateOrInsertWithCallbacks(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution?)
throws -> PersistenceSuccess
{
let (saved, _) = try updateOrInsertAndFetchWithCallbacks(
db, onConflict: conflictResolution,
selection: [],
fetch: {
// Nothing to fetch
try $0.execute()
})
return saved
}
/// Executes an `UPDATE` or `INSERT` statement, with `RETURNING` clause
/// if `selection` is not empty, and runs insertion or update callbacks.
@inlinable // allow specialization so that empty callbacks are removed
mutating func updateOrInsertAndFetchWithCallbacks<T>(
_ db: Database,
onConflict conflictResolution: Database.ConflictResolution?,
selection: [any SQLSelectable],
fetch: (Statement) throws -> T)
throws -> (PersistenceSuccess, T)
{
// Attempt to update if the record has a primary key
if let key = try primaryKey(db) {
let databaseTableName = type(of: self).databaseTableName
do {
let columns = try Set(db.columns(in: databaseTableName).map(\.name))
return try updateAndFetchWithCallbacks(
db, onConflict: conflictResolution,
columns: columns,
selection: selection,
fetch: fetch)
} catch RecordError.recordNotFound(databaseTableName: databaseTableName, key: key) {
// No row was updated: fallback on insert.
}
}
// Insert
let (inserted, returned) = try insertAndFetchWithCallbacks(
db, onConflict: conflictResolution,
selection: selection,
fetch: fetch)
return (PersistenceSuccess(inserted), returned)
}
/// Return a non-nil dictionary if record has a non-null primary key
@usableFromInline
func primaryKey(_ db: Database) throws -> [String: DatabaseValue]? {
let databaseTableName = type(of: self).databaseTableName
let primaryKeyInfo = try db.primaryKey(databaseTableName)
let container = try PersistenceContainer(db, self)
let primaryKey = Dictionary(uniqueKeysWithValues: primaryKeyInfo.columns.map {
($0, container.databaseValue(at: $0))
})
if primaryKey.allSatisfy({ $0.value.isNull }) {
return nil
}
return primaryKey
}
}
+417 -24
View File
@@ -8,15 +8,39 @@
/* Begin PBXBuildFile section */
56781B08243F7B5300650A83 /* GRDB-Bridging.h in Headers */ = {isa = PBXBuildFile; fileRef = 56781B06243F7B4B00650A83 /* GRDB-Bridging.h */; settings = {ATTRIBUTES = (Public, ); }; };
56C9EB9B2495324700FE5D55 /* grdb_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 56C9EB9A2495324700FE5D55 /* grdb_config.h */; settings = {ATTRIBUTES = (Private, ); }; };
56C9EB9B2495324700FE5D55 /* grdb_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 56C9EB9A2495324700FE5D55 /* grdb_config.h */; settings = {ATTRIBUTES = (Public, ); }; };
B01E89134E826280778505C3 /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F3BA805A1CFB2BB2003DC1BA /* GRDB.framework */; };
E2B456869E1F9252ED403327 /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F3BA805A1CFB2BB2003DC1BA /* GRDB.framework */; };
EED476F21CFD17270026A4EC /* GRDBCustomSQLite-USER.h in Headers */ = {isa = PBXBuildFile; fileRef = EED476F11CFD16FF0026A4EC /* GRDBCustomSQLite-USER.h */; settings = {ATTRIBUTES = (Public, ); }; };
F3BA80931CFB2F13003DC1BA /* GRDB.h in Headers */ = {isa = PBXBuildFile; fileRef = F3BA7FF11CFB23D3003DC1BA /* GRDB.h */; settings = {ATTRIBUTES = (Public, ); }; };
F3BA80951CFB2F18003DC1BA /* sqlite3.h in Headers */ = {isa = PBXBuildFile; fileRef = F3BA7FF01CFB23C9003DC1BA /* sqlite3.h */; settings = {ATTRIBUTES = (Public, ); }; };
F3BA80961CFB2F45003DC1BA /* libsqlitecustom.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F3BA7FF81CFB23E4003DC1BA /* libsqlitecustom.a */; };
F3BA80A01CFB2F6F003DC1BA /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F3BA805A1CFB2BB2003DC1BA /* GRDB.framework */; };
F9FD3AF06F24C99F3E72B802 /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F3BA805A1CFB2BB2003DC1BA /* GRDB.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
72F09E87598431D4C724B1ED /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = DC3773EA19C8CBB3004FCF85 /* Project object */;
proxyType = 1;
remoteGlobalIDString = F3BA80591CFB2BB2003DC1BA;
remoteInfo = GRDBCustomSQLiteOSX;
};
B2AE1C3D5DCA9D4E53C5191B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = DC3773EA19C8CBB3004FCF85 /* Project object */;
proxyType = 1;
remoteGlobalIDString = F3BA80591CFB2BB2003DC1BA;
remoteInfo = GRDBCustomSQLiteOSX;
};
D6313D521A35160477F62EC9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = DC3773EA19C8CBB3004FCF85 /* Project object */;
proxyType = 1;
remoteGlobalIDString = F3BA80591CFB2BB2003DC1BA;
remoteInfo = GRDBCustomSQLiteOSX;
};
EED9F6471CFE39D7004BA2B8 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F3BA7FF31CFB23E4003DC1BA /* SQLiteLib.xcodeproj */;
@@ -41,13 +65,19 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
0FE21DC3F5FE5B423DAF8B1A /* GRDBCustomSwift6MainActorIsolationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBCustomSwift6MainActorIsolationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
3F88AAE5CD399A6D530F5B9A /* GRDBCustomSwift6Tests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = GRDBCustomSwift6Tests.xcconfig; path = SQLiteCustom/GRDBCustomSwift6Tests.xcconfig; sourceTree = "<group>"; };
56781B06243F7B4B00650A83 /* GRDB-Bridging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "GRDB-Bridging.h"; path = "SQLiteCustom/GRDB-Bridging.h"; sourceTree = "<group>"; };
56C494421ED726C500CC72AF /* GRDBDeploymentTarget.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = GRDBDeploymentTarget.xcconfig; path = SQLiteCustom/GRDBDeploymentTarget.xcconfig; sourceTree = "<group>"; };
56C9EB9A2495324700FE5D55 /* grdb_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = grdb_config.h; path = SQLiteCustom/grdb_config.h; sourceTree = "<group>"; };
74C20556B3E1AB3888067F4F /* GRDBCustomSwift6ApproachableConcurrencyTests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = GRDBCustomSwift6ApproachableConcurrencyTests.xcconfig; path = SQLiteCustom/GRDBCustomSwift6ApproachableConcurrencyTests.xcconfig; sourceTree = "<group>"; };
BB0B5671B6EC1357591CF7F6 /* GRDBCustomSwift6ApproachableConcurrencyTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBCustomSwift6ApproachableConcurrencyTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
CB3CFFFCF1B2DCC0734E2D22 /* GRDBCustomSwift5Tests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = GRDBCustomSwift5Tests.xcconfig; path = SQLiteCustom/GRDBCustomSwift5Tests.xcconfig; sourceTree = "<group>"; };
DC2393C61ABE35F8003FF113 /* GRDB-Bridging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GRDB-Bridging.h"; sourceTree = "<group>"; };
DC3773F719C8CBB3004FCF85 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
DC3773F819C8CBB3004FCF85 /* GRDB.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GRDB.h; sourceTree = "<group>"; };
DC37740419C8CBB3004FCF85 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
DED09C78161854132C6CFF30 /* GRDBCustomSwift6Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBCustomSwift6Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
EED476F11CFD16FF0026A4EC /* GRDBCustomSQLite-USER.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "GRDBCustomSQLite-USER.h"; path = "SQLiteCustom/GRDBCustomSQLite-USER.h"; sourceTree = "<group>"; };
F3BA7FEE1CFB23B7003DC1BA /* GRDB.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = GRDB.xcconfig; path = SQLiteCustom/GRDB.xcconfig; sourceTree = "<group>"; };
F3BA7FEF1CFB23BF003DC1BA /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; name = module.modulemap; path = SQLiteCustom/module.modulemap; sourceTree = "<group>"; };
@@ -55,9 +85,10 @@
F3BA7FF11CFB23D3003DC1BA /* GRDB.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = GRDB.h; path = SQLiteCustom/GRDB.h; sourceTree = "<group>"; };
F3BA7FF31CFB23E4003DC1BA /* SQLiteLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SQLiteLib.xcodeproj; path = SQLiteCustom/src/SQLiteLib.xcodeproj; sourceTree = "<group>"; };
F3BA805A1CFB2BB2003DC1BA /* GRDB.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GRDB.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F3BA809B1CFB2F6F003DC1BA /* GRDBCustomTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBCustomTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
F3BA809B1CFB2F6F003DC1BA /* GRDBCustomSwift5Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBCustomSwift5Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
F3BA813A1CFB3402003DC1BA /* GRDBCustomSQLite-USER.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "GRDBCustomSQLite-USER.xcconfig"; path = "SQLiteCustom/GRDBCustomSQLite-USER.xcconfig"; sourceTree = "<group>"; };
F3BA813B1CFB3770003DC1BA /* GRDBCustomSQLite-Testing.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "GRDBCustomSQLite-Testing.xcconfig"; path = "SQLiteCustom/GRDBCustomSQLite-Testing.xcconfig"; sourceTree = "<group>"; };
FA42BB8AB2795AA918744DB5 /* GRDBCustomSwift6MainActorIsolationTests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = GRDBCustomSwift6MainActorIsolationTests.xcconfig; path = SQLiteCustom/GRDBCustomSwift6MainActorIsolationTests.xcconfig; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
@@ -71,11 +102,39 @@
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
/* Begin PBXFileSystemSynchronizedRootGroup section */
56FF360A2FCC8CBA00E841A9 /* GRDB */ = {isa = PBXFileSystemSynchronizedRootGroup; exceptions = (56FF36B42FCC8CBA00E841A9 /* PBXFileSystemSynchronizedBuildFileExceptionSet */, ); explicitFileTypes = {}; explicitFolders = (); path = GRDB; sourceTree = "<group>"; };
56FF3CD82FCC8D9600E841A9 /* GRDBTests */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = GRDBTests; sourceTree = "<group>"; };
56A1E0022FD0A00000ABCDEF /* GRDBTestSupport */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = GRDBTestSupport; sourceTree = "<group>"; };
56FF360A2FCC8CBA00E841A9 /* Sources/GRDB */ = {isa = PBXFileSystemSynchronizedRootGroup; exceptions = (56FF36B42FCC8CBA00E841A9 /* PBXFileSystemSynchronizedBuildFileExceptionSet */, ); explicitFileTypes = {}; explicitFolders = (); path = Sources/GRDB; sourceTree = "<group>"; };
56FF3CD82FCC8D9600E841A9 /* GRDBSwift5Tests */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = GRDBSwift5Tests; sourceTree = "<group>"; };
6C4C1471D2FDF9FD118A4A88 /* GRDBSwift6ApproachableConcurrencyTests */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = GRDBSwift6ApproachableConcurrencyTests; sourceTree = "<group>"; };
8E9FCAC86BBBA0815D11605C /* GRDBSwift6Tests */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = GRDBSwift6Tests; sourceTree = "<group>"; };
CA4DBF2CD3C9B36548CD0E27 /* GRDBSwift6MainActorIsolationTests */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = GRDBSwift6MainActorIsolationTests; sourceTree = "<group>"; };
/* End PBXFileSystemSynchronizedRootGroup section */
/* Begin PBXFrameworksBuildPhase section */
57F11F1403C6EB2D4A7BF60F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
F9FD3AF06F24C99F3E72B802 /* GRDB.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
96DA7079C329BAF0A0AA3C18 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
B01E89134E826280778505C3 /* GRDB.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
E82CD891F22BFF0F8709D022 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
E2B456869E1F9252ED403327 /* GRDB.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
F3BA80561CFB2BB2003DC1BA /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -107,7 +166,11 @@
children = (
5614DEEE1BA9D6F9003163B3 /* Frameworks */,
DC37740319C8CBB3004FCF85 /* Supporting Files */,
56FF3CD82FCC8D9600E841A9 /* GRDBTests */,
56FF3CD82FCC8D9600E841A9 /* GRDBSwift5Tests */,
6C4C1471D2FDF9FD118A4A88 /* GRDBSwift6ApproachableConcurrencyTests */,
CA4DBF2CD3C9B36548CD0E27 /* GRDBSwift6MainActorIsolationTests */,
8E9FCAC86BBBA0815D11605C /* GRDBSwift6Tests */,
56A1E0022FD0A00000ABCDEF /* GRDBTestSupport */,
);
path = Tests;
sourceTree = "<group>";
@@ -115,7 +178,7 @@
DC3773E919C8CBB3004FCF85 = {
isa = PBXGroup;
children = (
56FF360A2FCC8CBA00E841A9 /* GRDB */,
56FF360A2FCC8CBA00E841A9 /* Sources/GRDB */,
F3BA7FED1CFB21F8003DC1BA /* GRDBCustomSQLite */,
DC10500F19C904DD00D8CA30 /* Tests */,
DC37743319C8CFCE004FCF85 /* Supporting Files */,
@@ -130,7 +193,10 @@
isa = PBXGroup;
children = (
F3BA805A1CFB2BB2003DC1BA /* GRDB.framework */,
F3BA809B1CFB2F6F003DC1BA /* GRDBCustomTests.xctest */,
F3BA809B1CFB2F6F003DC1BA /* GRDBCustomSwift5Tests.xctest */,
BB0B5671B6EC1357591CF7F6 /* GRDBCustomSwift6ApproachableConcurrencyTests.xctest */,
0FE21DC3F5FE5B423DAF8B1A /* GRDBCustomSwift6MainActorIsolationTests.xctest */,
DED09C78161854132C6CFF30 /* GRDBCustomSwift6Tests.xctest */,
);
name = Products;
sourceTree = "<group>";
@@ -173,6 +239,10 @@
F3BA7FEF1CFB23BF003DC1BA /* module.modulemap */,
F3BA7FEE1CFB23B7003DC1BA /* GRDB.xcconfig */,
F3BA813B1CFB3770003DC1BA /* GRDBCustomSQLite-Testing.xcconfig */,
CB3CFFFCF1B2DCC0734E2D22 /* GRDBCustomSwift5Tests.xcconfig */,
74C20556B3E1AB3888067F4F /* GRDBCustomSwift6ApproachableConcurrencyTests.xcconfig */,
FA42BB8AB2795AA918744DB5 /* GRDBCustomSwift6MainActorIsolationTests.xcconfig */,
3F88AAE5CD399A6D530F5B9A /* GRDBCustomSwift6Tests.xcconfig */,
56C494421ED726C500CC72AF /* GRDBDeploymentTarget.xcconfig */,
F3BA7FF31CFB23E4003DC1BA /* SQLiteLib.xcodeproj */,
EED476F41CFD174D0026A4EC /* Customize */,
@@ -206,6 +276,69 @@
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
296CC26A78846C1774A353AA /* GRDBCustomSwift6MainActorIsolationTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 399B483926BB0B955F02D498 /* Build configuration list for PBXNativeTarget "GRDBCustomSwift6MainActorIsolationTests" */;
buildPhases = (
75D162FC1CC3CA052F0344BA /* Sources */,
96DA7079C329BAF0A0AA3C18 /* Frameworks */,
90B93112186E9F7AECB688F7 /* Resources */,
);
buildRules = (
);
dependencies = (
D7F44CA5E3DF0445555A67AD /* PBXTargetDependency */,
);
fileSystemSynchronizedGroups = (
CA4DBF2CD3C9B36548CD0E27 /* GRDBSwift6MainActorIsolationTests */,
);
name = GRDBCustomSwift6MainActorIsolationTests;
productName = GRDBCustomSQLiteOSXTests;
productReference = 0FE21DC3F5FE5B423DAF8B1A /* GRDBCustomSwift6MainActorIsolationTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
72D40DE94672F9BFA1E13194 /* GRDBCustomSwift6Tests */ = {
isa = PBXNativeTarget;
buildConfigurationList = ABE21B80405ED66030CC384F /* Build configuration list for PBXNativeTarget "GRDBCustomSwift6Tests" */;
buildPhases = (
9671F9897A52A5940A4711D3 /* Sources */,
E82CD891F22BFF0F8709D022 /* Frameworks */,
3D29DA1786E317241F590532 /* Resources */,
);
buildRules = (
);
dependencies = (
91A130C334C256F66E3035BE /* PBXTargetDependency */,
);
fileSystemSynchronizedGroups = (
8E9FCAC86BBBA0815D11605C /* GRDBSwift6Tests */,
);
name = GRDBCustomSwift6Tests;
productName = GRDBCustomSQLiteOSXTests;
productReference = DED09C78161854132C6CFF30 /* GRDBCustomSwift6Tests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
8696532B65D06114EEA1C73A /* GRDBCustomSwift6ApproachableConcurrencyTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 715216561A90D637D1FF412C /* Build configuration list for PBXNativeTarget "GRDBCustomSwift6ApproachableConcurrencyTests" */;
buildPhases = (
F886BF64014403547C21AE73 /* Sources */,
57F11F1403C6EB2D4A7BF60F /* Frameworks */,
AB777E177DD80A866BFDE1B2 /* Resources */,
);
buildRules = (
);
dependencies = (
910B2E4620DF4C75AB752E6B /* PBXTargetDependency */,
);
fileSystemSynchronizedGroups = (
6C4C1471D2FDF9FD118A4A88 /* GRDBSwift6ApproachableConcurrencyTests */,
);
name = GRDBCustomSwift6ApproachableConcurrencyTests;
productName = GRDBCustomSQLiteOSXTests;
productReference = BB0B5671B6EC1357591CF7F6 /* GRDBCustomSwift6ApproachableConcurrencyTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
F3BA80591CFB2BB2003DC1BA /* GRDBCustom */ = {
isa = PBXNativeTarget;
buildConfigurationList = F3BA805F1CFB2BB2003DC1BA /* Build configuration list for PBXNativeTarget "GRDBCustom" */;
@@ -223,16 +356,16 @@
EED9F6481CFE39D7004BA2B8 /* PBXTargetDependency */,
);
fileSystemSynchronizedGroups = (
56FF360A2FCC8CBA00E841A9 /* GRDB */,
56FF360A2FCC8CBA00E841A9 /* Sources/GRDB */,
);
name = GRDBCustom;
productName = GRDBCustomSQLite;
productReference = F3BA805A1CFB2BB2003DC1BA /* GRDB.framework */;
productType = "com.apple.product-type.framework";
};
F3BA809A1CFB2F6F003DC1BA /* GRDBCustomTests */ = {
F3BA809A1CFB2F6F003DC1BA /* GRDBCustomSwift5Tests */ = {
isa = PBXNativeTarget;
buildConfigurationList = F3BA80A31CFB2F6F003DC1BA /* Build configuration list for PBXNativeTarget "GRDBCustomTests" */;
buildConfigurationList = F3BA80A31CFB2F6F003DC1BA /* Build configuration list for PBXNativeTarget "GRDBCustomSwift5Tests" */;
buildPhases = (
F3BA80971CFB2F6F003DC1BA /* Sources */,
F3BA80981CFB2F6F003DC1BA /* Frameworks */,
@@ -244,11 +377,12 @@
F3BA80A21CFB2F6F003DC1BA /* PBXTargetDependency */,
);
fileSystemSynchronizedGroups = (
56FF3CD82FCC8D9600E841A9 /* GRDBTests */,
56A1E0022FD0A00000ABCDEF /* GRDBTestSupport */,
56FF3CD82FCC8D9600E841A9 /* GRDBSwift5Tests */,
);
name = GRDBCustomTests;
name = GRDBCustomSwift5Tests;
productName = GRDBCustomSQLiteOSXTests;
productReference = F3BA809B1CFB2F6F003DC1BA /* GRDBCustomTests.xctest */;
productReference = F3BA809B1CFB2F6F003DC1BA /* GRDBCustomSwift5Tests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
@@ -259,7 +393,7 @@
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 2600;
LastUpgradeCheck = 2720;
ORGANIZATIONNAME = "Gwendal Roué";
TargetAttributes = {
F3BA80591CFB2BB2003DC1BA = {
@@ -292,7 +426,10 @@
projectRoot = "";
targets = (
F3BA80591CFB2BB2003DC1BA /* GRDBCustom */,
F3BA809A1CFB2F6F003DC1BA /* GRDBCustomTests */,
F3BA809A1CFB2F6F003DC1BA /* GRDBCustomSwift5Tests */,
8696532B65D06114EEA1C73A /* GRDBCustomSwift6ApproachableConcurrencyTests */,
296CC26A78846C1774A353AA /* GRDBCustomSwift6MainActorIsolationTests */,
72D40DE94672F9BFA1E13194 /* GRDBCustomSwift6Tests */,
);
};
/* End PBXProject section */
@@ -308,6 +445,27 @@
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
3D29DA1786E317241F590532 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
90B93112186E9F7AECB688F7 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
AB777E177DD80A866BFDE1B2 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
F3BA80581CFB2BB2003DC1BA /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -364,6 +522,20 @@
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
75D162FC1CC3CA052F0344BA /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
9671F9897A52A5940A4711D3 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
F3BA80551CFB2BB2003DC1BA /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -378,9 +550,31 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
F886BF64014403547C21AE73 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
910B2E4620DF4C75AB752E6B /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = F3BA80591CFB2BB2003DC1BA /* GRDBCustom */;
targetProxy = B2AE1C3D5DCA9D4E53C5191B /* PBXContainerItemProxy */;
};
91A130C334C256F66E3035BE /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = F3BA80591CFB2BB2003DC1BA /* GRDBCustom */;
targetProxy = 72F09E87598431D4C724B1ED /* PBXContainerItemProxy */;
};
D7F44CA5E3DF0445555A67AD /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = F3BA80591CFB2BB2003DC1BA /* GRDBCustom */;
targetProxy = D6313D521A35160477F62EC9 /* PBXContainerItemProxy */;
};
EED9F6481CFE39D7004BA2B8 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = sqlitecustom;
@@ -394,6 +588,122 @@
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
033CDFD8E1DA68D705188F80 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = FA42BB8AB2795AA918744DB5 /* GRDBCustomSwift6MainActorIsolationTests.xcconfig */;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator driverkit iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
};
name = Release;
};
5395727F00FA1E8DF66174BD /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 3F88AAE5CD399A6D530F5B9A /* GRDBCustomSwift6Tests.xcconfig */;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator driverkit iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
};
name = Debug;
};
B077E91F97F004CA48DC2837 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 74C20556B3E1AB3888067F4F /* GRDBCustomSwift6ApproachableConcurrencyTests.xcconfig */;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator driverkit iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
};
name = Release;
};
D92142DE121495B1AE9A7F90 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = FA42BB8AB2795AA918744DB5 /* GRDBCustomSwift6MainActorIsolationTests.xcconfig */;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator driverkit iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
};
name = Debug;
};
DC37740719C8CBB3004FCF85 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -428,6 +738,7 @@
DEAD_CODE_STRIPPING = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
@@ -486,6 +797,7 @@
DEAD_CODE_STRIPPING = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
@@ -504,6 +816,64 @@
};
name = Release;
};
DD6A662F281D6B4F49DBCC7E /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 74C20556B3E1AB3888067F4F /* GRDBCustomSwift6ApproachableConcurrencyTests.xcconfig */;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator driverkit iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
};
name = Debug;
};
E06B5E4EF49B07A404C85BBA /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 3F88AAE5CD399A6D530F5B9A /* GRDBCustomSwift6Tests.xcconfig */;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator driverkit iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
};
name = Release;
};
F3BA80601CFB2BB2003DC1BA /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = F3BA7FEE1CFB23B7003DC1BA /* GRDB.xcconfig */;
@@ -522,6 +892,7 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_NO_COMMON_BLOCKS = YES;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
@@ -557,6 +928,7 @@
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GCC_NO_COMMON_BLOCKS = YES;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
@@ -577,7 +949,7 @@
};
F3BA80A41CFB2F6F003DC1BA /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = F3BA813B1CFB3770003DC1BA /* GRDBCustomSQLite-Testing.xcconfig */;
baseConfigurationReference = CB3CFFFCF1B2DCC0734E2D22 /* GRDBCustomSwift5Tests.xcconfig */;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ENABLE_MODULES = YES;
@@ -593,22 +965,19 @@
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCustomSQLiteOSXTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator driverkit iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_OBJC_BRIDGING_HEADER = "Tests/GRDBTests/GRDBTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4";
};
name = Debug;
};
F3BA80A51CFB2F6F003DC1BA /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = F3BA813B1CFB3770003DC1BA /* GRDBCustomSQLite-Testing.xcconfig */;
baseConfigurationReference = CB3CFFFCF1B2DCC0734E2D22 /* GRDBCustomSwift5Tests.xcconfig */;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ENABLE_MODULES = YES;
@@ -625,16 +994,13 @@
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCustomSQLiteOSXTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator driverkit iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OBJC_BRIDGING_HEADER = "Tests/GRDBTests/GRDBTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4";
};
name = Release;
@@ -642,6 +1008,33 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
399B483926BB0B955F02D498 /* Build configuration list for PBXNativeTarget "GRDBCustomSwift6MainActorIsolationTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D92142DE121495B1AE9A7F90 /* Debug */,
033CDFD8E1DA68D705188F80 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
715216561A90D637D1FF412C /* Build configuration list for PBXNativeTarget "GRDBCustomSwift6ApproachableConcurrencyTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
DD6A662F281D6B4F49DBCC7E /* Debug */,
B077E91F97F004CA48DC2837 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
ABE21B80405ED66030CC384F /* Build configuration list for PBXNativeTarget "GRDBCustomSwift6Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
5395727F00FA1E8DF66174BD /* Debug */,
E06B5E4EF49B07A404C85BBA /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
DC3773ED19C8CBB3004FCF85 /* Build configuration list for PBXProject "GRDBCustom" */ = {
isa = XCConfigurationList;
buildConfigurations = (
@@ -660,7 +1053,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
F3BA80A31CFB2F6F003DC1BA /* Build configuration list for PBXNativeTarget "GRDBCustomTests" */ = {
F3BA80A31CFB2F6F003DC1BA /* Build configuration list for PBXNativeTarget "GRDBCustomSwift5Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F3BA80A41CFB2F6F003DC1BA /* Debug */,
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2600"
LastUpgradeVersion = "2720"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -29,8 +29,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F3BA809A1CFB2F6F003DC1BA"
BuildableName = "GRDBCustomTests.xctest"
BlueprintName = "GRDBCustomTests"
BuildableName = "GRDBCustomSwift5Tests.xctest"
BlueprintName = "GRDBCustomSwift5Tests"
ReferencedContainer = "container:GRDBCustom.xcodeproj">
</BuildableReference>
</BuildActionEntry>
@@ -49,8 +49,38 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F3BA809A1CFB2F6F003DC1BA"
BuildableName = "GRDBCustomTests.xctest"
BlueprintName = "GRDBCustomTests"
BuildableName = "GRDBCustomSwift5Tests.xctest"
BlueprintName = "GRDBCustomSwift5Tests"
ReferencedContainer = "container:GRDBCustom.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8696532B65D06114EEA1C73A"
BuildableName = "GRDBCustomSwift6ApproachableConcurrencyTests.xctest"
BlueprintName = "GRDBCustomSwift6ApproachableConcurrencyTests"
ReferencedContainer = "container:GRDBCustom.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "296CC26A78846C1774A353AA"
BuildableName = "GRDBCustomSwift6MainActorIsolationTests.xctest"
BlueprintName = "GRDBCustomSwift6MainActorIsolationTests"
ReferencedContainer = "container:GRDBCustom.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "72D40DE94672F9BFA1E13194"
BuildableName = "GRDBCustomSwift6Tests.xctest"
BlueprintName = "GRDBCustomSwift6Tests"
ReferencedContainer = "container:GRDBCustom.xcodeproj">
</BuildableReference>
</TestableReference>
+77 -125
View File
@@ -8,13 +8,12 @@
# make distclean - Restore repository to a pristine state
default: test
smokeTest: test_framework_GRDBiOS_maxTarget test_framework_GRDBiOS_minTarget test_framework_SQLCipher3 test_framework_SQLCipher4Encrypted test_framework_GRDBCustomSQLiteiOS_maxTarget test_SPM
smokeTest: test_framework_GRDBiOS_maxTarget test_framework_GRDBiOS_minTarget test_SPM_SQLCipherEncrypted test_framework_GRDBCustomSQLiteiOS_maxTarget test_SPM
# =====
# Tools
GIT := $(shell command -v git)
POD := $(shell command -v pod)
XCRUN := $(shell command -v xcrun)
XCODEBUILD := set -o pipefail && $(shell command -v xcodebuild)
@@ -42,6 +41,7 @@ endif
# =====
# Configuration
UNIVERSAL_XCFRAMEWORK_PATH = build/universal_xcframework
DOCS_PATH = Documentation/Reference
TEST_ACTIONS = clean build build-for-testing test-without-building
@@ -71,17 +71,22 @@ endif
# =====
# Tests
test: test_framework test_archive test_install test_demo_apps
test: test_framework test_archive test_install test_traits test_demo_apps
test_framework: test_framework_darwin
test_framework_darwin: test_framework_GRDB test_framework_GRDBCustom test_framework_SQLCipher test_SPM
test_framework_darwin: test_framework_GRDB test_framework_GRDBCustom test_SPM test_SPM_SQLCipher
test_framework_GRDB: test_framework_GRDBOSX test_framework_GRDBiOS test_framework_GRDBtvOS
test_framework_GRDBCustom: test_framework_GRDBCustomSQLiteOSX test_framework_GRDBCustomSQLiteiOS
test_framework_SQLCipher: test_framework_SQLCipher3 test_framework_SQLCipher3Encrypted test_framework_SQLCipher4 test_framework_SQLCipher4Encrypted
test_archive: test_universal_xcframework
test_install: test_install_manual test_install_SPM test_install_customSQLite test_install_GRDB_CocoaPods
test_CocoaPodsLint: test_CocoaPodsLint_GRDB
test_SPM_SQLCipher: test_SPM_SQLCipherUnencrypted test_SPM_SQLCipherEncrypted
test_archive: universal_xcframework test_universal_xcframework
test_install: test_install_manual test_install_SPM test_install_customSQLite
test_demo_apps: test_GRDBDemo
test_traits: \
test_traits_SQLCipherApp_LibraryWithoutTraits \
test_traits_SQLCipherProject_LibraryWithoutTraits \
test_traits_DefaultApp_LibraryWithSQLCipher \
test_traits_SQLCipherApp_LibraryWithSQLCipher \
test_traits_SystemSQLiteApp_LibraryWithSQLCipher
test_framework_GRDBOSX:
$(XCODEBUILD) \
@@ -159,80 +164,50 @@ test_framework_GRDBCustomSQLiteiOS_minTarget: SQLiteCustom
$(TEST_ACTIONS) \
$(XCPRETTY)
test_framework_SQLCipher3:
ifdef POD
cd Tests/CocoaPods/SQLCipher3 && \
$(POD) install && \
$(XCODEBUILD) \
-workspace GRDBTests.xcworkspace \
-scheme GRDBTests \
build-for-testing test-without-building \
$(XCPRETTY)
else
@echo CocoaPods must be installed for test_framework_SQLCipher3
@exit 1
endif
test_framework_SQLCipher3Encrypted:
ifdef POD
cd Tests/CocoaPods/SQLCipher3 && \
$(POD) install && \
$(XCODEBUILD) \
-workspace GRDBTests.xcworkspace \
-scheme GRDBEncryptedTests \
build-for-testing test-without-building \
$(XCPRETTY)
else
@echo CocoaPods must be installed for test_framework_SQLCipher3Encrypted
@exit 1
endif
test_framework_SQLCipher4:
ifdef POD
cd Tests/CocoaPods/SQLCipher4 && \
$(POD) install && \
$(XCODEBUILD) \
-workspace GRDBTests.xcworkspace \
-scheme GRDBTests \
build-for-testing test-without-building \
$(XCPRETTY)
else
@echo CocoaPods must be installed for test_framework_SQLCipher4
@exit 1
endif
test_framework_SQLCipher4Encrypted:
ifdef POD
cd Tests/CocoaPods/SQLCipher4 && \
$(POD) install && \
$(XCODEBUILD) \
-workspace GRDBTests.xcworkspace \
-scheme GRDBEncryptedTests \
build-for-testing test-without-building \
$(XCPRETTY)
else
@echo CocoaPods must be installed for test_framework_SQLCipher4Encrypted
@exit 1
endif
test_SPM:
# Add sanitizers when available: https://twitter.com/simjp/status/929140877540278272
rm -rf Tests/products
$(SWIFT) package clean
$(SWIFT) build
$(SWIFT) build -c release
set -o pipefail && $(SWIFT) test --parallel
test_universal_xcframework:
rm -rf Tests/products
mkdir Tests/products
test_SPM_SQLCipherUnencrypted:
set -o pipefail && $(SWIFT) test --parallel --traits SQLCipher
test_SPM_SQLCipherEncrypted:
set -o pipefail && $(SWIFT) test --parallel --traits SQLCipher -Xswiftc -DGRDBCIPHER_USE_ENCRYPTION
test_traits_SQLCipherApp_LibraryWithoutTraits:
SWIFT=$(SWIFT) Tests/Traits/test_sqlcipher_linkage.sh package Tests/Traits/SQLCipherApp_LibraryWithoutTraits SQLCipherApp_LibraryWithoutTraits
test_traits_SQLCipherProject_LibraryWithoutTraits:
Tests/Traits/test_sqlcipher_linkage.sh project Tests/Traits/SQLCipherProject_LibraryWithoutTraits App
test_traits_DefaultApp_LibraryWithSQLCipher:
SWIFT=$(SWIFT) Tests/Traits/test_sqlcipher_linkage.sh package Tests/Traits/DefaultApp_LibraryWithSQLCipher DefaultApp_LibraryWithSQLCipher
test_traits_SQLCipherApp_LibraryWithSQLCipher:
SWIFT=$(SWIFT) Tests/Traits/test_sqlcipher_linkage.sh package Tests/Traits/SQLCipherApp_LibraryWithSQLCipher SQLCipherApp_LibraryWithSQLCipher
test_traits_SystemSQLiteApp_LibraryWithSQLCipher:
SWIFT=$(SWIFT) Tests/Traits/test_sqlcipher_linkage.sh package Tests/Traits/SystemSQLiteApp_LibraryWithSQLCipher SystemSQLiteApp_LibraryWithSQLCipher
# Build the universal framework from scratch
universal_xcframework:
rm -rf $(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB.xcframework
$(MAKE) $(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB.xcframework
# Build the universal framework if it is not built yet
$(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB.xcframework:
rm -rf $(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB-*.xcarchive
mkdir -p $(UNIVERSAL_XCFRAMEWORK_PATH)
$(XCODEBUILD) archive \
-project GRDB.xcodeproj \
-scheme GRDB \
-destination "generic/platform=iOS" \
OTHER_SWIFT_FLAGS=$(OTHER_SWIFT_FLAGS) \
GCC_PREPROCESSOR_DEFINITIONS=$(GCC_PREPROCESSOR_DEFINITIONS) \
-archivePath "$(PWD)/Tests/products/GRDB-iOS.xcarchive" \
-archivePath "$(PWD)/$(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB-iOS.xcarchive" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
$(XCODEBUILD) archive \
@@ -241,7 +216,7 @@ test_universal_xcframework:
-destination "generic/platform=iOS Simulator" \
OTHER_SWIFT_FLAGS=$(OTHER_SWIFT_FLAGS) \
GCC_PREPROCESSOR_DEFINITIONS=$(GCC_PREPROCESSOR_DEFINITIONS) \
-archivePath "$(PWD)/Tests/products/GRDB-iOS_Simulator.xcarchive" \
-archivePath "$(PWD)/$(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB-iOS_Simulator.xcarchive" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
$(XCODEBUILD) archive \
@@ -250,7 +225,7 @@ test_universal_xcframework:
-destination "generic/platform=macOS" \
OTHER_SWIFT_FLAGS=$(OTHER_SWIFT_FLAGS) \
GCC_PREPROCESSOR_DEFINITIONS=$(GCC_PREPROCESSOR_DEFINITIONS) \
-archivePath "$(PWD)/Tests/products/GRDB-macOS.xcarchive" \
-archivePath "$(PWD)/$(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB-macOS.xcarchive" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
$(XCODEBUILD) archive \
@@ -259,15 +234,37 @@ test_universal_xcframework:
-destination "generic/platform=macOS,variant=Mac Catalyst" \
OTHER_SWIFT_FLAGS=$(OTHER_SWIFT_FLAGS) \
GCC_PREPROCESSOR_DEFINITIONS=$(GCC_PREPROCESSOR_DEFINITIONS) \
-archivePath "$(PWD)/Tests/products/GRDB-Mac_Catalyst.xcarchive" \
-archivePath "$(PWD)/$(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB-Mac_Catalyst.xcarchive" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
$(XCODEBUILD) -create-xcframework \
-archive '$(PWD)/Tests/products/GRDB-iOS.xcarchive' -framework GRDB.framework \
-archive '$(PWD)/Tests/products/GRDB-iOS_Simulator.xcarchive' -framework GRDB.framework \
-archive '$(PWD)/Tests/products/GRDB-macOS.xcarchive' -framework GRDB.framework \
-archive '$(PWD)/Tests/products/GRDB-Mac_Catalyst.xcarchive' -framework GRDB.framework \
-output '$(PWD)/Tests/products/GRDB.xcframework'
-archive '$(PWD)/$(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB-iOS.xcarchive' -framework GRDB.framework \
-archive '$(PWD)/$(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB-iOS_Simulator.xcarchive' -framework GRDB.framework \
-archive '$(PWD)/$(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB-macOS.xcarchive' -framework GRDB.framework \
-archive '$(PWD)/$(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB-Mac_Catalyst.xcarchive' -framework GRDB.framework \
-output '$(PWD)/$(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB.xcframework'
# Check that an application can use the universal framework: run on
# macOS, typecheck on other platforms. The minimum OS versions match
# Support/GRDBDeploymentTarget.xcconfig.
test_universal_xcframework: $(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB.xcframework
$(XCRUN) --sdk macosx swiftc Tests/GRDBXCFramework/main.swift \
-F '$(PWD)/$(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB.xcframework/macos-arm64_x86_64' \
-Xlinker -rpath -Xlinker '$(PWD)/$(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB.xcframework/macos-arm64_x86_64' \
-o '$(PWD)/$(UNIVERSAL_XCFRAMEWORK_PATH)/GRDBXCFramework'
# Run the program built above:
'$(PWD)/$(UNIVERSAL_XCFRAMEWORK_PATH)/GRDBXCFramework'
$(XCRUN) --sdk iphoneos swiftc -typecheck Tests/GRDBXCFramework/main.swift \
-target arm64-apple-ios15.0 \
-F '$(PWD)/$(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB.xcframework/ios-arm64'
$(XCRUN) --sdk iphonesimulator swiftc -typecheck Tests/GRDBXCFramework/main.swift \
-target arm64-apple-ios15.0-simulator \
-F '$(PWD)/$(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB.xcframework/ios-arm64_x86_64-simulator'
$(XCRUN) --sdk macosx swiftc -typecheck Tests/GRDBXCFramework/main.swift \
-target arm64-apple-ios15.0-macabi \
-Fsystem "$$($(XCRUN) --sdk macosx --show-sdk-path)/System/iOSSupport/System/Library/Frameworks" \
-I "$$($(XCRUN) --sdk macosx --show-sdk-path)/System/iOSSupport/usr/lib/swift" \
-F '$(PWD)/$(UNIVERSAL_XCFRAMEWORK_PATH)/GRDB.xcframework/ios-arm64_x86_64-maccatalyst'
test_install_manual:
$(XCODEBUILD) \
@@ -281,13 +278,11 @@ test_install_manual:
test_install_SPM: test_install_SPM_Package test_install_SPM_Project test_install_SPM_Dynamic_Project test_install_SPM_macos_release test_install_SPM_ios_release
test_install_SPM_Package:
rm -rf Tests/products
cd Tests/SPM/PlainPackage && \
$(SWIFT) build && \
./.build/debug/SPM
test_install_SPM_Project:
rm -rf Tests/products
$(XCODEBUILD) \
-project Tests/SPM/PlainProject/Plain.xcodeproj \
-scheme Plain \
@@ -297,7 +292,6 @@ test_install_SPM_Project:
$(XCPRETTY)
test_install_SPM_Dynamic_Project:
rm -rf Tests/products
$(XCODEBUILD) \
-project Tests/SPM/ios-dynamic/ios-dynamic.xcodeproj \
-scheme ios-dynamic \
@@ -307,7 +301,6 @@ test_install_SPM_Dynamic_Project:
$(XCPRETTY)
test_install_SPM_macos_release:
rm -rf Tests/products
$(XCODEBUILD) \
-project Tests/SPM/macos/macos.xcodeproj \
-scheme macos \
@@ -317,7 +310,6 @@ test_install_SPM_macos_release:
$(XCPRETTY)
test_install_SPM_ios_release:
rm -rf Tests/products
$(XCODEBUILD) \
-project Tests/SPM/ios/ios.xcodeproj \
-scheme ios \
@@ -335,48 +327,6 @@ test_install_customSQLite: SQLiteCustom
clean build \
$(XCPRETTY)
test_install_GRDB_CocoaPods: test_install_GRDB_CocoaPods_framework test_install_GRDB_CocoaPods_static
test_install_GRDB_CocoaPods_framework:
ifdef POD
cd Tests/CocoaPods/GRDBiOS-framework && \
$(POD) install && \
$(XCODEBUILD) \
-workspace iOS.xcworkspace \
-scheme iOS \
-configuration Release \
-destination $(MAX_IOS_DESTINATION) \
clean build \
$(XCPRETTY)
else
@echo CocoaPods must be installed for test_install_GRDB_CocoaPods
@exit 1
endif
test_install_GRDB_CocoaPods_static:
ifdef POD
cd Tests/CocoaPods/GRDBiOS-static && \
$(POD) install && \
$(XCODEBUILD) \
-workspace iOS.xcworkspace \
-scheme iOS \
-configuration Release \
-destination $(MAX_IOS_DESTINATION) \
clean build \
$(XCPRETTY)
else
@echo CocoaPods must be installed for test_install_GRDB_CocoaPods
@exit 1
endif
test_CocoaPodsLint_GRDB:
ifdef POD
$(POD) lib lint GRDB.swift.podspec --allow-warnings
else
@echo CocoaPods must be installed for test_CocoaPodsLint_GRDB
@exit 1
endif
test_GRDBDemo:
$(XCODEBUILD) \
-project Documentation/DemoApps/GRDBDemo/GRDBDemo.xcodeproj \
@@ -450,7 +400,9 @@ distclean:
clean:
$(SWIFT) package reset
cd Tests/SPM && $(SWIFT) package reset
rm -rf Tests/Traits/*/.build
rm -rf $(UNIVERSAL_XCFRAMEWORK_PATH)
rm -rf $(DOCS_PATH)
find . -name Package.resolved | xargs rm -f
.PHONY: distclean clean doc test smokeTest SQLiteCustom
.PHONY: distclean clean doc test smokeTest SQLiteCustom universal_xcframework test_universal_xcframework
+69 -50
View File
@@ -1,4 +1,4 @@
// swift-tools-version:6.1
// swift-tools-version:6.4
// The swift-tools-version declares the minimum version of Swift required to build this package.
import Foundation
@@ -17,9 +17,14 @@ var swiftSettings: [SwiftSetting] = [
.define("SQLITE_ENABLE_SNAPSHOT"),
// Not all Linux distributions have support for WAL snapshots.
.define("SQLITE_DISABLE_SNAPSHOT", .when(platforms: [.linux])),
.define("SQLITE_HAS_CODEC", .when(traits: ["SQLCipher"])),
]
var cSettings: [CSetting] = [
.define("SQLITE_HAS_CODEC", .when(traits: ["SQLCipher"])),
]
var dependencies: [PackageDescription.Package.Dependency] = [
.package(url: "https://github.com/sqlcipher/SQLCipher.swift", from: "4.11.0"),
]
var cSettings: [CSetting] = []
var dependencies: [PackageDescription.Package.Dependency] = []
// Don't rely on those environment variables. They are ONLY testing conveniences:
// $ SQLITE_ENABLE_PREUPDATE_HOOK=1 make test_SPM
@@ -38,83 +43,97 @@ if ProcessInfo.processInfo.environment["SPI_BUILDER"] == "1" {
dependencies.append(.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"))
}
// GRDB+SQLCipher: Uncomment those lines
//dependencies.append(.package(url: "https://github.com/sqlcipher/SQLCipher.swift.git", from: "4.11.0"))
//cSettings.append(.define("SQLITE_HAS_CODEC"))
//swiftSettings.append(.define("SQLITE_HAS_CODEC"))
//swiftSettings.append(.define("SQLCipher"))
let package = Package(
name: "GRDB",
defaultLocalization: "en", // for tests
platforms: [
.iOS(.v13),
.macOS(.v10_15),
.tvOS(.v13),
.watchOS(.v7),
.iOS(.v15),
.macOS(.v12),
.tvOS(.v15),
.watchOS(.v9),
],
products: [
// GRDB+SQLCipher: Delete the GRDBSQLite library
.library(name: "GRDBSQLite", targets: ["GRDBSQLite"]),
.library(name: "GRDB", targets: ["GRDB"]),
.library(name: "GRDB-dynamic", type: .dynamic, targets: ["GRDB"]),
],
traits: [
.default(enabledTraits: ["SystemSQLite"]),
.trait(
name: "SystemSQLite",
description: "Use the SQLite library installed on the system, unless overridden by another trait.",
),
.trait(
name: "SQLCipher",
description: "Use SQLCipher instead of the SQLite library installed on the system.",
),
],
dependencies: dependencies,
targets: [
// GRDB+SQLCipher: Delete the GRDBSQLite target
.systemLibrary(
name: "GRDBSQLite",
providers: [.apt(["libsqlite3-dev"])]),
// GRDB+SQLCipher: Uncomment the GRDBSQLCipher target
//.target(
// name: "GRDBSQLCipher",
// dependencies: [.product(name: "SQLCipher", package: "SQLCipher.swift")]
//),
.target(
name: "GRDBSQLCipher",
dependencies: [
.product(name: "SQLCipher", package: "SQLCipher.swift", condition: .when(traits: ["SQLCipher"])),
]
),
.target(
name: "GRDB",
dependencies: [
// GRDB+SQLCipher: Delete the GRDBSQLite dependency
.target(name: "GRDBSQLite"),
// GRDB+SQLCipher: Uncomment the SQLCipher and GRDBSQLCipher dependencies
//.product(name: "SQLCipher", package: "SQLCipher.swift"),
//.target(name: "GRDBSQLCipher"),
.target(name: "GRDBSQLite", condition: .when(traits: ["SystemSQLite"])),
.product(name: "SQLCipher", package: "SQLCipher.swift", condition: .when(traits: ["SQLCipher"])),
.target(name: "GRDBSQLCipher", condition: .when(traits: ["SQLCipher"])),
],
path: "GRDB",
resources: [.copy("PrivacyInfo.xcprivacy")],
cSettings: cSettings,
swiftSettings: swiftSettings + [
.enableUpcomingFeature("MemberImportVisibility"),
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
.enableUpcomingFeature("InferIsolatedConformances"),
]),
.target(
name: "GRDBTestSupport",
path: "Tests/GRDBTestSupport"),
.testTarget(
name: "GRDBTests",
dependencies: ["GRDB"],
path: "Tests",
exclude: [
"CocoaPods",
"Crash",
"CustomSQLite",
"GRDBManualInstall",
"GRDBTests/Core/DatabasePool/getThreadsCount.c",
"Info.plist",
"Performance",
"SPM",
"Swift6Migration",
"generatePerformanceReport.rb",
"parsePerformanceTests.rb",
],
name: "GRDBSwift5Tests",
dependencies: ["GRDB", "GRDBTestSupport"],
resources: [
.copy("GRDBTests/Betty.jpeg"),
.copy("GRDBTests/Private/InflectionsTests.json"),
.copy("GRDBTests/ValueObservation/Issue1383.sqlite"),
.copy("GRDBTests/GRDBCipher/db.SQLCipher3"),
.copy("Betty.jpeg"),
.copy("Private/InflectionsTests.json"),
.copy("ValueObservation/Issue1383.sqlite"),
.copy("GRDBCipher/db.SQLCipher3"),
],
cSettings: cSettings,
swiftSettings: swiftSettings + [
// Tests still use the Swift 5 language mode.
.swiftLanguageMode(.v5),
.enableUpcomingFeature("InferSendableFromCaptures"),
.enableUpcomingFeature("GlobalActorIsolatedTypesUsability"),
])
],
swiftLanguageModes: [.v6]
],
),
.testTarget(
name: "GRDBSwift6ApproachableConcurrencyTests",
dependencies: ["GRDB"],
cSettings: cSettings,
swiftSettings: swiftSettings + [
.enableUpcomingFeature("ApproachableConcurrency"),
],
),
.testTarget(
name: "GRDBSwift6MainActorIsolationTests",
dependencies: ["GRDB"],
cSettings: cSettings,
swiftSettings: swiftSettings + [
.defaultIsolation(MainActor.self),
.enableUpcomingFeature("ApproachableConcurrency"),
],
),
.testTarget(
name: "GRDBSwift6Tests",
dependencies: ["GRDB"],
cSettings: cSettings,
swiftSettings: swiftSettings,
),
]
)
+29 -63
View File
@@ -1,7 +1,7 @@
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/groue/GRDB.swift/master/GRDB~dark.png">
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/groue/GRDB.swift/master/GRDB.png">
<img alt="GRDB: A toolkit for SQLite databases, with a focus on application development." src="https://raw.githubusercontent.com/groue/GRDB.swift/master/GRDB.png">
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/groue/GRDB.swift/master/Documentation/Images/GRDB~dark.png">
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/groue/GRDB.swift/master/Documentation/Images/GRDB.png">
<img alt="GRDB: A toolkit for SQLite databases, with a focus on application development." src="https://raw.githubusercontent.com/groue/GRDB.swift/master/Documentation/Images/GRDB.png">
</picture>
<p align="center">
@@ -10,14 +10,14 @@
</p>
<p align="center">
<a href="https://developer.apple.com/swift/"><img alt="Swift 6.1" src="https://img.shields.io/badge/swift-6.1-orange.svg?style=flat"></a>
<a href="https://developer.apple.com/swift/"><img alt="Swift 6.4" src="https://img.shields.io/badge/swift-6.4-orange.svg?style=flat"></a>
<a href="https://github.com/groue/GRDB.swift/blob/master/LICENSE"><img alt="License" src="https://img.shields.io/github/license/groue/GRDB.swift.svg?maxAge=2592000"></a>
<a href="https://github.com/groue/GRDB.swift/actions/workflows/CI.yml"><img alt="CI Status" src="https://github.com/groue/GRDB.swift/actions/workflows/CI.yml/badge.svg?branch=master"></a>
</p>
**Latest release**: November 30, 2026 • [version 7.12.1](https://github.com/groue/GRDB.swift/tree/v7.12.1) • [CHANGELOG](CHANGELOG.md) • [Migrating From GRDB 6 to GRDB 7](Documentation/GRDB7MigrationGuide.md)
**Requirements**: iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 7.0+ &bull; SQLite 3.20.0+ &bull; Swift 6.1+ / Xcode 16.3+
**Requirements**: iOS 15.0+ / macOS 12.0+ / tvOS 15.0+ / watchOS 9.0+ &bull; SQLite 3.36.0+ &bull; Swift 6.4+ / Xcode 27.0+
**Contact**:
@@ -325,7 +325,7 @@ Documentation
- [Unicode](#unicode)
- [Memory Management](#memory-management)
- [Data Protection](https://swiftpackageindex.com/groue/GRDB.swift/documentation/grdb/databaseconnections)
- :bulb: [Migrating From GRDB 6 to GRDB 7](Documentation/GRDB7MigrationGuide.md)
- :bulb: [Migrating From GRDB 7 to GRDB 8](Documentation/GRDB8MigrationGuide.md)
- :bulb: [Why Adopt GRDB?](Documentation/WhyAdoptGRDB.md)
- :bulb: [Recommended Practices for Designing Record Types](https://swiftpackageindex.com/groue/GRDB.swift/documentation/grdb/recordrecommendedpractices)
@@ -358,40 +358,6 @@ GRDB offers two libraries, `GRDB` and `GRDB-dynamic`. Pick only one. When in dou
> **Note**: Linux support is provided by contributors. It is not automatically tested, and not officially maintained. If you notice a build or runtime failure on Linux, please open a pull request with the necessary fix, thank you!
## CocoaPods
[CocoaPods](http://cocoapods.org/) is a dependency manager for Xcode projects. To use GRDB with CocoaPods (version 1.2 or higher), specify in your `Podfile`:
```ruby
pod 'GRDB.swift'
```
GRDB can be installed as a framework, or a static library.
**Important Note for CocoaPods installation**
Due to an [issue](https://github.com/CocoaPods/CocoaPods/issues/11839) in CocoaPods, it is currently not possible to deploy new versions of GRDB to CocoaPods. The last version available on CocoaPods is 6.24.1. To install later versions of GRDB using CocoaPods, use one of the following workarounds:
- Depend on the `GRDB7` branch. This is more or less equivalent to what `pod 'GRDB.swift', '~> 7.0'` would normally do, if CocoaPods allowed new GRDB versions to be published:
```ruby
# Can't use semantic versioning due to https://github.com/CocoaPods/CocoaPods/issues/11839
pod 'GRDB.swift', git: 'https://github.com/groue/GRDB.swift.git', branch: 'GRDB7'
```
- Depend on a specific version explicitly (Replace the tag with the version you want to use):
```ruby
# Can't use semantic versioning due to https://github.com/CocoaPods/CocoaPods/issues/11839
# Replace the tag with the tag that you want to use.
pod 'GRDB.swift', git: 'https://github.com/groue/GRDB.swift.git', tag: 'v6.29.0'
```
## Carthage
[Carthage](https://github.com/Carthage/Carthage) is **unsupported**. For some context about this decision, see [#433](https://github.com/groue/GRDB.swift/issues/433).
## Manually
1. [Download](https://github.com/groue/GRDB.swift/releases) a copy of GRDB, or clone its repository and make sure you checkout the latest tagged version.
@@ -1615,15 +1581,17 @@ try Int.fetchOne(db, request) // Int?
**If not all SQLite APIs are exposed in GRDB, you can still use the [SQLite C Interface](https://www.sqlite.org/c3ref/intro.html) and call [SQLite C functions](https://www.sqlite.org/c3ref/funclist.html).**
To access the C SQLite functions from SQLCipher or the system SQLite, you need to perform an extra import:
To access the C SQLite functions, import the module of the SQLite library that GRDB uses: `SQLite3` for the system SQLite, or `SQLCipher` when GRDB uses [SQLCipher](#encryption):
```swift
import SQLite3 // System SQLite
import SQLCipher // SQLCipher
import SQLite3 // System SQLite
// import SQLCipher // SQLCipher
let sqliteVersion = String(cString: sqlite3_libversion())
```
When GRDB uses SQLCipher, import `SQLCipher` only. Importing `SQLite3`, or `GRDBSQLite` (the GRDB module that wraps the system SQLite), can link the system SQLite next to SQLCipher, which will create undefined behavior and should be avoided.
Raw pointers to database connections and statements are available through the `Database.sqliteConnection` and `Statement.sqliteStatement` properties:
```swift
@@ -2181,8 +2149,6 @@ For more information about batch updates, see [Update Requests](#update-requests
[UPSERT](https://www.sqlite.org/lang_UPSERT.html) is an SQLite feature that causes an INSERT to behave as an UPDATE or a no-op if the INSERT would violate a uniqueness constraint (primary key or unique index).
> **Note**: Upsert apis are available from SQLite 3.35.0+: iOS 15.0+, macOS 12.0+, tvOS 15.0+, watchOS 8.0+, or with a [custom SQLite build] or [SQLCipher](#encryption).
>
> **Note**: With regard to [persistence callbacks](#available-callbacks), an upsert behaves exactly like an insert. In particular: the `aroundInsert(_:)` and `didInsert(_:)` callbacks report the rowid of the inserted or updated row; `willUpdate`, `aroundUpdate`, `didUpdate` are not called.
[PersistableRecord] provides three upsert methods:
@@ -2275,8 +2241,6 @@ For more information about batch updates, see [Update Requests](#update-requests
SQLite is able to return values from an inserted, updated, or deleted row, with the [`RETURNING` clause](https://www.sqlite.org/lang_returning.html).
> **Note**: Support for the `RETURNING` clause is available from SQLite 3.35.0+: iOS 15.0+, macOS 12.0+, tvOS 15.0+, watchOS 8.0+, or with a [custom SQLite build] or [SQLCipher](#encryption).
The `RETURNING` clause helps deal with database features such as auto-incremented ids, default values, and [generated columns](https://sqlite.org/gencol.html). You can, for example, insert a few columns and fetch the default or generated ones in one step.
GRDB uses the `RETURNING` clause in all persistence methods that contain `AndFetch` in their name.
@@ -2754,11 +2718,11 @@ The standard way to provide such context is the `userInfo` dictionary. Implement
```swift
protocol FetchableRecord {
static var databaseDecodingUserInfo: [CodingUserInfoKey: Any] { get }
@preconcurrency static var databaseDecodingUserInfo: [CodingUserInfoKey: any Sendable] { get }
}
protocol EncodableRecord {
static var databaseEncodingUserInfo: [CodingUserInfoKey: Any] { get }
@preconcurrency static var databaseEncodingUserInfo: [CodingUserInfoKey: any Sendable] { get }
}
```
@@ -2791,7 +2755,7 @@ let player = try decoder.decode(Player.self, from: jsonData)
```swift
extension Player: FetchableRecord {
static var databaseDecodingUserInfo: [CodingUserInfoKey: Any] {
static var databaseDecodingUserInfo: [CodingUserInfoKey: any Sendable] {
[decoderName: "database row"]
}
}
@@ -2800,7 +2764,7 @@ extension Player: FetchableRecord {
let player = try Player.fetchOne(db, ...)
```
> **Note**: make sure the `databaseDecodingUserInfo` and `databaseEncodingUserInfo` properties are explicitly declared as `[CodingUserInfoKey: Any]`. If they are not, the Swift compiler may silently miss the protocol requirement, resulting in sticky empty userInfo.
> **Note**: make sure the `databaseDecodingUserInfo` and `databaseEncodingUserInfo` properties are explicitly declared as `[CodingUserInfoKey: any Sendable]`. If they are not, the Swift compiler may silently miss the protocol requirement, resulting in sticky empty userInfo.
### Tip: Derive Columns from Coding Keys
@@ -4586,23 +4550,26 @@ try Player.customRequest().fetchAll(db) // [Player]
Encryption
==========
**GRDB can encrypt your database with [SQLCipher](http://sqlcipher.net) v3.4+.**
**GRDB can encrypt your database with [SQLCipher](https://www.zetetic.net/sqlcipher/) v4.5+.**
To use SQLCipher with the [Swift Package Manager](https://swift.org/package-manager/), you must fork GRDB, and modify `Package.swift`. Instructions are in the file itself, in comments that contain "GRDB+SQLCipher".
To use SQLCipher with the [Swift Package Manager](https://swift.org/package-manager/), enable the `SQLCipher` trait of the GRDB package. It takes precedence over the `SystemSQLite` trait, which is enabled by default, and possibly by other packages of your project.
To use SQLCipher with [CocoaPods](http://cocoapods.org/), specify in your `Podfile`:
In the Package Dependencies of an Xcode project, select the GRDB package and check `SQLCipher`.
```ruby
# GRDB with SQLCipher 4
pod 'GRDB.swift/SQLCipher'
pod 'SQLCipher', '~> 4.0'
In a `Package.swift` file, list `SQLCipher` in the traits of the GRDB dependency:
# GRDB with SQLCipher 3
pod 'GRDB.swift/SQLCipher'
pod 'SQLCipher', '~> 3.4'
```swift
dependencies: [
.package(
url: "https://github.com/groue/GRDB.swift.git",
from: "8.0.0",
traits: ["SQLCipher"])
]
```
Make sure you remove any existing `pod 'GRDB.swift'` from your Podfile. `GRDB.swift/SQLCipher` must be the only active GRDB pod in your whole project, or you will face linker or runtime errors, due to the conflicts between SQLCipher and the system SQLite.
If another package of your project enables the `SQLCipher` trait, and the Swift Package Manager fails to resolve dependencies with the error "exhausted attempts to resolve the dependencies graph", add the [SQLCipher.swift](https://github.com/sqlcipher/SQLCipher.swift) package to the dependencies of your project, without linking any of its products to your targets.
> **Note**: [**:fire: EXPERIMENTAL**](#what-are-experimental-features) The `SQLCipher` trait is experimental, because future versions of Swift or Xcode might link the system SQLite next to SQLCipher, which would create undefined behavior.
- [Creating or Opening an Encrypted Database](#creating-or-opening-an-encrypted-database)
- [Changing the Passphrase of an Encrypted Database](#changing-the-passphrase-of-an-encrypted-database)
@@ -5910,7 +5877,6 @@ Sample Code
- The [Documentation](#documentation) is full of GRDB snippets.
- [Demo Applications]
- Open `GRDB.xcworkspace`: it contains GRDB-enabled playgrounds to play with.
- [groue/SortedDifference](https://github.com/groue/SortedDifference): How to synchronize a database table with a JSON payload
@@ -1,27 +1,19 @@
Release Process
===============
**This is internal documentation.**
To release a new GRDB version:
# Releasing a New Version
- Tests
- `make distclean test`
- Build and run GRDBDemo
- Check for performance regression with GRDBOSXPerformanceTests
- On https://github.com/groue/sqlcipher.git upgrade, update SQLCipher version in README.md
- On https://github.com/swiftlyfalling/SQLiteLib upgrade, update SQLite version in Documentation/CustomSQLiteBuilds.md
- Update GRDB version number and release date in:
- CHANGELOG.md
- GRDB.swift.podspec
- README.md
- Support/Info.plist
- Commit and tag
- Look for undesired tags: `git for-each-ref --format '%(refname) %(authorname)' refs/tags`
- Look for undesired tags: `git for-each-ref --format '%(refname) %(authorname)' refs/tags | sort -V`
- Push to the `master` branch
- Push to the `development` branch
- Push to the `GRDB7` branch
- `pod trunk push --allow-warnings GRDB.swift.podspec`
- Push to the `GRDB8` branch
- Update [performance comparison](https://github.com/groue/GRDB.swift/wiki/Performance):
`make test_performance | Tests/parsePerformanceTests.rb | Tests/generatePerformanceReport.rb`
+2
View File
@@ -14,3 +14,5 @@ GCC_PREPROCESSOR_DEFINITIONS = "GRDBCUSTOMSQLITE=1"
OTHER_SWIFT_FLAGS = -D USING_BUILTIN_SQLITE -D GRDBCUSTOMSQLITE $(CUSTOM_OTHER_SWIFT_FLAGS)
HEADER_SEARCH_PATHS = $(SRCROOT)/SQLiteCustom/src
SWIFT_VERSION = 6.1
SWIFT_UPCOMING_FEATURE_NONISOLATED_NONSENDING_BY_DEFAULT = YES
SWIFT_UPCOMING_FEATURE_INFER_ISOLATED_CONFORMANCES = YES
@@ -1,5 +1,5 @@
// DO NOT MODIFY.
// This config file is used to expose other settings to the test bundle.
// This config file is used to expose other settings to the test bundles.
CUSTOM_OTHER_SWIFT_FLAGS= // do not modify
@@ -10,7 +10,3 @@ CUSTOM_OTHER_SWIFT_FLAGS= // do not modify
OTHER_CFLAGS = -DUSING_BUILTIN_SQLITE -DGRDBCUSTOMSQLITE $(CUSTOM_SQLLIBRARY_CFLAGS) // Do not modify.
OTHER_SWIFT_FLAGS = -D USING_BUILTIN_SQLITE -D GRDBCUSTOMSQLITE $(CUSTOM_OTHER_SWIFT_FLAGS) // Do not modify.
// Tests still use the Swift 5 language mode.
SWIFT_UPCOMING_FEATURE_INFER_SENDABLE_FROM_CAPTURES = YES
OTHER_SWIFT_FLAGS = $(inherited) -enable-upcoming-feature GlobalActorIsolatedTypesUsability
@@ -0,0 +1,7 @@
#include "GRDBCustomSQLite-Testing.xcconfig"
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.$(PRODUCT_NAME:rfc1034identifier)
SWIFT_OBJC_BRIDGING_HEADER = Tests/GRDBSwift5Tests/GRDBSwift5Tests-Bridging-Header.h
SWIFT_VERSION = 5.0
SWIFT_UPCOMING_FEATURE_INFER_SENDABLE_FROM_CAPTURES = YES
OTHER_SWIFT_FLAGS = $(inherited) -enable-upcoming-feature GlobalActorIsolatedTypesUsability
@@ -0,0 +1,5 @@
#include "GRDBCustomSQLite-Testing.xcconfig"
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.$(PRODUCT_NAME:rfc1034identifier)
SWIFT_VERSION = 6.0
SWIFT_APPROACHABLE_CONCURRENCY = YES
@@ -0,0 +1,6 @@
#include "GRDBCustomSQLite-Testing.xcconfig"
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.$(PRODUCT_NAME:rfc1034identifier)
SWIFT_VERSION = 6.0
SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor
SWIFT_APPROACHABLE_CONCURRENCY = YES
@@ -0,0 +1,4 @@
#include "GRDBCustomSQLite-Testing.xcconfig"
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.$(PRODUCT_NAME:rfc1034identifier)
SWIFT_VERSION = 6.0
+4 -4
View File
@@ -1,4 +1,4 @@
IPHONEOS_DEPLOYMENT_TARGET = 13.0
MACOSX_DEPLOYMENT_TARGET = 10.15
TVOS_DEPLOYMENT_TARGET = 13.0
WATCHOS_DEPLOYMENT_TARGET = 7.0
IPHONEOS_DEPLOYMENT_TARGET = 15.0
MACOSX_DEPLOYMENT_TARGET = 12.0
TVOS_DEPLOYMENT_TARGET = 15.0
WATCHOS_DEPLOYMENT_TARGET = 9.0
-5
View File
@@ -9,7 +9,6 @@ static inline void _registerErrorLogCallback(_errorLogCallback callback) {
sqlite3_config(SQLITE_CONFIG_LOG, callback, 0);
}
#if SQLITE_VERSION_NUMBER >= 3029000
/// Wrapper around sqlite3_db_config() which is a variadic function that can't
/// be used from Swift.
static inline void _disableDoubleQuotedStringLiterals(sqlite3 *db) {
@@ -23,8 +22,4 @@ static inline void _enableDoubleQuotedStringLiterals(sqlite3 *db) {
sqlite3_db_config(db, SQLITE_DBCONFIG_DQS_DDL, 1, (void *)0);
sqlite3_db_config(db, SQLITE_DBCONFIG_DQS_DML, 1, (void *)0);
}
#else
static inline void _disableDoubleQuotedStringLiterals(sqlite3 *db) { }
static inline void _enableDoubleQuotedStringLiterals(sqlite3 *db) { }
#endif
#endif /* grdb_config_h */
+2 -2
View File
@@ -1,5 +1,5 @@
included:
- ../GRDB
- ../Sources/GRDB
disabled_rules:
- comment_spacing
@@ -59,7 +59,7 @@ opt_in_rules:
- pattern_matching_keywords
- prohibited_super_call
- reduce_into
- redundant_self_in_closure
- redundant_self
- redundant_type_annotation
- shorthand_optional_binding
- sorted_first_last
@@ -1,13 +1,15 @@
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
#if !canImport(Darwin)
@@ -92,8 +94,8 @@ public struct Configuration: Sendable {
/// The default configuration label is nil.
public var label: String?
/// A boolean value indicating whether SQLite 3.29+ interprets
/// double-quoted strings as string literals when they do not match any
/// A boolean value indicating whether SQLite interprets double-quoted
/// strings as string literals when they do not match any
/// valid identifier.
///
/// The default and recommended value is false:
@@ -105,9 +107,9 @@ public struct Configuration: Sendable {
/// """)
/// ```
///
/// When true, or before SQLite version 3.29.0, double-quoted strings that
/// do not match any valid identifier are interpreted as string literals,
/// as in the example below. This is an SQLite
/// When true, double-quoted strings that do not match any valid
/// identifier are interpreted as string literals, as in the
/// example below. This is an SQLite
/// [misfeature](https://sqlite.org/quirks.html#double_quoted_string_literals_are_accepted):
///
/// ```swift
File renamed without changes.
@@ -1,7 +1,5 @@
#if SQLITE_HAS_CODEC
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif SQLCipher
#if SQLCipher
import SQLCipher
#else
#error("No SQLCipher library configured")
@@ -1,13 +1,15 @@
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
extension Database {
@@ -68,27 +70,35 @@ extension Database {
///
/// Related SQLite documentation: <https://www.sqlite.org/pragma.html#pragma_schema_version>
public func schemaVersion() throws -> Int32 {
try Int32.fetchOne(internalCachedStatement(sql: "PRAGMA schema_version"))!
try Int32.fetchOne(cachedStatement(sql: "PRAGMA schema_version"))!
}
/// Clears the database schema cache.
///
/// If the database schema is modified by another SQLite connection to the
/// same database file, your application may need to call this method in
/// order to avoid undesired consequences.
/// GRDB caches information about the database schema, such as the
/// columns of tables. When another SQLite connection to the same
/// database file modifies the schema, this information becomes
/// outdated.
///
/// GRDB clears this cache when it detects a schema change at the
/// beginning of a transaction opened by a database access method
/// such as `read` or `write`, by ``inTransaction(_:_:)``, or by
/// ``inSavepoint(_:)``. It does not check in `DEFERRED` transactions
/// that can write.
///
/// Call this method when another connection may have modified the
/// schema since the last check, for example in
/// `writeWithoutTransaction`.
public func clearSchemaCache() {
// TODO: can't we automatically clear the cache for writer connection,
// just as we do for DatabasePool reader connections?
SchedulingWatchdog.preconditionValidQueue(self)
schemaCache.clear()
// We also clear statement cache despite the automatic statement
// recompilation (see https://www.sqlite.org/c3ref/prepare.html)
// because the automatic statement recompilation only happens a
// limited number of times (`SQLITE_MAX_SCHEMA_RETRY`).
internalStatementCache.clear()
publicStatementCache.clear()
// We also clear the statement cache. SQLite automatically
// recompiles statements after a schema change (see
// https://www.sqlite.org/c3ref/prepare.html), but the recompilation
// does not update the statement information gathered by
// `StatementAuthorizer` at compilation time.
statementCache.clear()
}
/// Clears the database schema cache if the database schema has changed
@@ -100,8 +110,24 @@ extension Database {
// <https://sqlite.org/fileformat2.html#database_header>
let schemaVersion = try self.schemaVersion()
if lastSchemaVersion != schemaVersion {
lastSchemaVersion = schemaVersion
// The schema has changed.
//
// When we compile a database statement in this new schema,
// SQLite might compile it against the previous schema. It's
// generally not a problem, because SQLite will detect the
// mismatch from `sqlite3_step`, and recompile it.
//
// However, the statement metadata recorded by
// `StatementAuthorizer` from the initial compilation might be
// wrong, with potential bad consequences on database
// observation.
//
// Executing a statement that reads `sqlite_master` makes
// SQLite reload its schema. This is the observed SQLite
// behavior, not a documented guarantee.
try execute(sql: "SELECT * FROM sqlite_master LIMIT 0")
clearSchemaCache()
lastSchemaVersion = schemaVersion
}
}
@@ -160,7 +186,7 @@ extension Database {
}
#else
/// Returns information about a table or a view
@available(iOS 15.4, macOS 12.4, tvOS 15.4, watchOS 8.5, *) // SQLite 3.37+
@available(iOS 15.4, macOS 12.4, tvOS 15.4, *) // SQLite 3.37+
func table(_ tableName: String) throws -> TableInfo? {
for schemaID in try fetchSchemaIdentifiers() {
if let result = try table(for: DatabaseObjectID(name: tableName, schemaID: schemaID)) {
@@ -171,7 +197,7 @@ extension Database {
}
/// Returns information about a table or a view
@available(iOS 15.4, macOS 12.4, tvOS 15.4, watchOS 8.5, *) // SQLite 3.37+
@available(iOS 15.4, macOS 12.4, tvOS 15.4, *) // SQLite 3.37+
func table(for table: DatabaseObjectID) throws -> TableInfo? {
try _table(for: table)
}
@@ -582,7 +608,7 @@ extension Database {
return try self.table(for: table)!.isWithoutRowIDTable == false
}
#else
if #available(iOS 15.4, macOS 12.4, tvOS 15.4, watchOS 8.5, *) { // SQLite 3.37+
if #available(iOS 15.4, macOS 12.4, tvOS 15.4, *) { // SQLite 3.37+
return try self.table(for: table)!.isWithoutRowIDTable == false
}
#endif
@@ -1028,58 +1054,12 @@ extension Database {
/// Fetches the columns in the database table identified by `table`, or
/// returns nil if the database schema does not contain that table.
///
/// This method relies entirely on SQLite schema introspection. Starting with
/// SQLite 3.26.0, it returns all columns, including
/// This method relies entirely on SQLite schema introspection. It
/// returns all columns, including
/// [generated columns](https://www.sqlite.org/gencol.html) and
/// [hidden columns](https://www.sqlite.org/vtab.html#hiddencol).
func fetchPrimitiveColumns(in table: DatabaseObjectID) throws -> [ColumnInfo]? {
// https://www.sqlite.org/pragma.html
//
// > PRAGMA database.table_info(table-name);
// >
// > This pragma returns one row for each column in the named table.
// > Columns in the result set include the column name, data type,
// > whether or not the column can be NULL, and the default value for
// > the column. The "pk" column in the result set is zero for columns
// > that are not part of the primary key, and is the index of the
// > column in the primary key for columns that are part of the primary
// > key.
//
// sqlite> CREATE TABLE players (
// id INTEGER PRIMARY KEY,
// firstName TEXT,
// lastName TEXT);
//
// sqlite> PRAGMA table_info("players");
// cid | name | type | notnull | dflt_value | pk |
// 0 | id | INTEGER | 0 | NULL | 1 |
// 1 | name | TEXT | 0 | NULL | 0 |
// 2 | score | INTEGER | 0 | NULL | 0 |
//
//
// PRAGMA table_info does not expose hidden and generated columns. For
// that, we need PRAGMA table_xinfo, introduced in SQLite 3.26.0:
// https://sqlite.org/releaselog/3_26_0.html
//
// > PRAGMA schema.table_xinfo(table-name);
//
// > This pragma returns one row for each column in the named table,
// > including hidden columns in virtual tables. The output is the same
// > as for PRAGMA table_info except that hidden columns are shown
// > rather than being omitted.
//
// sqlite> PRAGMA table_xinfo("players");
// cid | name | type | notnull | dflt_value | pk | hidden
// 0 | id | INTEGER | 0 | NULL | 1 | 0
// 1 | firstName | TEXT | 0 | NULL | 0 | 0
// 2 | lastName | TEXT | 0 | NULL | 0 | 0
let columnInfoQuery: String
if sqlite3_libversion_number() < 3026000 {
columnInfoQuery = "PRAGMA \(table.schemaID.name).table_info(\(table.name.quotedDatabaseIdentifier))"
} else {
// Use PRAGMA table_xinfo so that we can load generated columns
columnInfoQuery = "PRAGMA \(table.schemaID.name).table_xinfo(\(table.name.quotedDatabaseIdentifier))"
}
let columnInfoQuery = "PRAGMA \(table.schemaID.name).table_xinfo(\(table.name.quotedDatabaseIdentifier))"
let columns = try ColumnInfo
.fetchAll(self, sql: columnInfoQuery)
.sorted(by: { $0.cid < $1.cid })
@@ -1295,11 +1275,10 @@ public struct DatabaseObjectID: Hashable, Sendable {
///
/// Related SQLite documentation:
///
/// - [pragma `table_info`](https://www.sqlite.org/pragma.html#pragma_table_info)
/// - [pragma `table_xinfo`](https://www.sqlite.org/pragma.html#pragma_table_xinfo)
public struct ColumnInfo: FetchableRecord, Sendable {
let cid: Int
let hidden: Int?
let hidden: Int
/// The column name.
public let name: String
@@ -1,13 +1,15 @@
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
import Foundation
@@ -92,8 +94,8 @@ extension Database {
/// let moreThanThirtyCount = try Int.fetchOne(statement, arguments: [30])!
///
/// - parameter sql: An SQL string.
/// - parameter prepFlags: Flags for sqlite3_prepare_v3 (available from
/// SQLite 3.20.0, see <http://www.sqlite.org/c3ref/prepare.html>)
/// - parameter prepFlags: Flags for `sqlite3_prepare_v3` see
/// <http://www.sqlite.org/c3ref/prepare.html>.
/// - returns: A prepared statement.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs.
func makeStatement(sql: String, prepFlags: CUnsignedInt) throws -> Statement {
@@ -142,14 +144,19 @@ extension Database {
/// try statement.execute(arguments: ["Barbara"])
/// ```
///
/// The returned statement may have already been used: it may or may not
/// contain values for its arguments, if any.
/// The returned statement has no argument values.
///
/// The returned statement is distinct from any statement that is still
/// in use (held by the application or by a cursor), even if it has the
/// same SQL. For example, it is possible to iterate the results of a
/// cached statement while executing the same SQL from another cached
/// statement.
///
/// - parameter sql: An SQL string.
/// - returns: A prepared statement.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs.
public func cachedStatement(sql: String) throws -> Statement {
try publicStatementCache.statement(sql)
try statementCache.statement(sql)
}
/// Returns a prepared statement that can be reused.
@@ -185,6 +192,15 @@ extension Database {
/// """)
/// ```
///
/// When the literal does not set any argument, the returned statement
/// has no argument values.
///
/// The returned statement is distinct from any statement that is still
/// in use (held by the application or by a cursor), even if it has the
/// same SQL. For example, it is possible to iterate the results of a
/// cached statement while executing the same SQL from another cached
/// statement.
///
/// - parameter sqlLiteral: An ``SQL`` literal.
/// - returns: A prepared statement.
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs.
@@ -198,11 +214,6 @@ extension Database {
return statement
}
/// Returns a cached statement that does not conflict with user's cached statements.
func internalCachedStatement(sql: String) throws -> Statement {
try internalStatementCache.statement(sql)
}
/// Returns a cursor of prepared statements.
///
/// For example:
@@ -477,8 +488,7 @@ extension Database {
// https://www.sqlite.org/c3ref/reset.html
//
// So make sure we clear this statement from the cache.
internalStatementCache.remove(statement)
publicStatementCache.remove(statement)
statementCache.remove(statement)
checkForAutocommitTransition()
@@ -554,8 +564,17 @@ extension Database {
}
}
/// A thread-unsafe statement cache
struct StatementCache {
/// A thread-unsafe statement cache.
///
/// The cache holds one statement per SQL string. A cached statement is
/// returned only if no one else holds a reference to it. Otherwise, the
/// cache returns a new statement, which is not cached.
///
/// This class is a reference type so that `isKnownUniquelyReferenced` can
/// check the cached statements in place. A value type would be copied when
/// accessed through the lazy `Database.statementCache` property, and the
/// copy would retain all statements.
final class StatementCache {
unowned let db: Database
private var statements: [String: Statement] = [:]
@@ -563,9 +582,20 @@ struct StatementCache {
self.db = database
}
mutating func statement(_ sql: String) throws -> Statement {
if let statement = statements[sql] {
return statement
/// - precondition: this method is called on a valid dispatch queue.
func statement(_ sql: String) throws -> Statement {
if let index = statements.index(forKey: sql) {
// Check the statement in place: a local copy would add
// a reference.
if isKnownUniquelyReferenced(&statements.values[index]) {
let statement = statements.values[index]
statement.prepareForReuse()
return statement
}
// The cached statement is in use: return a new statement,
// which is not cached.
return try db.makeStatement(sql: sql)
}
// http://www.sqlite.org/c3ref/c_prepare_persistent.html#sqlitepreparepersistent
@@ -579,15 +609,15 @@ struct StatementCache {
return statement
}
mutating func clear() {
func clear() {
statements = [:]
}
mutating func remove(_ statement: Statement) {
func remove(_ statement: Statement) {
statements.removeFirst { $0.value === statement }
}
mutating func removeAll(where shouldBeRemoved: (Statement) -> Bool) {
func removeAll(where shouldBeRemoved: (Statement) -> Bool) {
statements = statements.filter { (_, statement) in !shouldBeRemoved(statement) }
}
}
@@ -1,14 +1,16 @@
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
import GRDBSQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
import GRDBSQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
import Foundation
@@ -298,13 +300,8 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
/// The cache for the available database schemas (main, temp, attached databases).
var schemaCache = SchemaCache()
/// The cache for statements managed by GRDB. It is distinct from
/// `publicStatementCache` so that we do not mess with statement arguments
/// set by the user.
lazy var internalStatementCache = StatementCache(database: self)
/// The cache for statements managed by the user.
lazy var publicStatementCache = StatementCache(database: self)
/// The cache for statements, used by both GRDB and the user.
lazy var statementCache = StatementCache(database: self)
/// The database authorizer provides information about compiled
/// database statements, and prevents the truncate optimization when
@@ -334,7 +331,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
/// // Prints, for example, "3048000"
/// print(Database.sqliteLibVersionNumber)
/// ```
@inline(__always)
@inline(always)
@inlinable
public static var sqliteLibVersionNumber: CInt {
sqlite3_libversion_number()
@@ -670,8 +667,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
// Finalize all cached statements since they would prevent
// immediate connection closing.
internalStatementCache.clear()
publicStatementCache.clear()
statementCache.clear()
// https://www.sqlite.org/c3ref/close.html
// > If the database connection is associated with unfinalized prepared
@@ -714,8 +710,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
// Finalize all cached statements since they would prevent
// immediate connection closing.
internalStatementCache.clear()
publicStatementCache.clear()
statementCache.clear()
// https://www.sqlite.org/c3ref/close.html
// > If sqlite3_close_v2() is called with unfinalized prepared
@@ -848,7 +843,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
// concurrent and we can pretend it occurred before or after
// the PRAGMA.
try ignoringInterruption {
try internalCachedStatement(sql: "PRAGMA query_only = 1").execute()
try cachedStatement(sql: "PRAGMA query_only = 1").execute()
}
}
readOnlyDepth += 1
@@ -868,7 +863,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
// concurrent and we can pretend it occurred before or after
// the PRAGMA.
try ignoringInterruption {
try internalCachedStatement(sql: "PRAGMA query_only = 0").execute()
try cachedStatement(sql: "PRAGMA query_only = 0").execute()
}
}
}
@@ -1524,6 +1519,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
/// error thrown by `operations`.
public func inTransaction(_ kind: TransactionKind? = nil, _ operations: () throws -> TransactionCompletion) throws {
// Begin transaction
let kind = kind ?? defaultTransactionKind
try beginTransaction(kind)
// Support for `checkForAbortedTransaction()`.
@@ -1539,6 +1535,17 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
var firstError: Error?
let needsRollback: Bool
do {
// Another connection may have modified the database schema.
//
// Don't check in a DEFERRED transaction that may write:
// reading the schema version would start a read transaction,
// and the later upgrade to a write transaction could fail with
// SQLITE_BUSY, which can't be avoided with a busy timeout.
// See `beginTransaction(_:)`.
if kind != .deferred || isReadOnly {
try clearSchemaCacheIfNeeded()
}
let completion = try operations()
switch completion {
case .commit:
@@ -1744,11 +1751,17 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
// cannot be avoided with a busy timeout.
//
// See <https://github.com/groue/GRDB.swift/issues/1483>.
let kind = kind ?? (isReadOnly ? .deferred : .immediate)
let kind = kind ?? defaultTransactionKind
try execute(sql: "BEGIN \(kind.rawValue) TRANSACTION")
assert(sqlite3_get_autocommit(sqliteConnection) == 0)
}
/// The transaction kind of ``beginTransaction(_:)`` when no kind
/// is provided.
private var defaultTransactionKind: TransactionKind {
isReadOnly ? .deferred : .immediate
}
/// Rolls back a database transaction.
///
/// Related SQLite documentation: <https://www.sqlite.org/lang_transaction.html>
@@ -1841,8 +1854,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
sqlite3_db_release_memory(sqliteConnection)
}
schemaCache.clear()
internalStatementCache.clear()
publicStatementCache.clear()
statementCache.clear()
}
// MARK: - Erasing
@@ -1,13 +1,15 @@
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
import Foundation
@@ -1,13 +1,15 @@
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
import Foundation
@@ -1,13 +1,15 @@
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
import Foundation
@@ -501,7 +503,7 @@ public final class DatabaseFunction: Identifiable, Sendable {
/// try Int.fetchOne(db, sql: "SELECT mysum(i) FROM test")! // 3
/// }
/// ```
public protocol DatabaseAggregate: GRDBSendableMetatype {
public protocol DatabaseAggregate: SendableMetatype {
/// Creates an aggregate.
///
/// A new instance is created for each aggregation.
@@ -335,7 +335,6 @@ extension DatabasePool: DatabaseReader {
// MARK: - Reading from Database
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func read<T>(_ value: (Database) throws -> T) throws -> T {
GRDBPrecondition(currentReader == nil, "Database methods are not reentrant.")
guard let readerPool else {
@@ -343,9 +342,10 @@ extension DatabasePool: DatabaseReader {
}
return try readerPool.get { reader in
try reader.sync { db in
// clearSchemaCacheIfNeeded() is called by the transaction
// started by `isolated`.
try db.isolated {
try db.clearSchemaCacheIfNeeded()
return try value(db)
try value(db)
}
}
}
@@ -417,7 +417,6 @@ extension DatabasePool: DatabaseReader {
}
}
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T {
GRDBPrecondition(currentReader == nil, "Database methods are not reentrant.")
guard let readerPool else {
@@ -784,7 +783,6 @@ extension DatabasePool: DatabaseReader {
extension DatabasePool: DatabaseWriter {
// MARK: - Writing in Database
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T {
try writer.sync(updates)
}
@@ -795,7 +793,6 @@ extension DatabasePool: DatabaseWriter {
try await writer.execute(updates)
}
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) throws -> T {
guard let readerPool else {
throw DatabaseError.connectionIsClosed()
@@ -224,7 +224,6 @@ extension DatabaseQueue: DatabaseReader {
// MARK: - Reading from Database
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func read<T>(_ value: (Database) throws -> T) throws -> T {
try writer.sync { db in
try db.isolated(readOnly: true) {
@@ -265,6 +264,7 @@ extension DatabaseQueue: DatabaseReader {
// See <https://github.com/groue/GRDB.swift/pull/1213>.
try db.beginReadOnly()
try db.beginTransaction(.deferred)
try db.clearSchemaCacheIfNeeded()
value(.success(db))
} catch {
value(.failure(error))
@@ -272,7 +272,6 @@ extension DatabaseQueue: DatabaseReader {
}
}
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func unsafeRead<T>(_ value: (Database) throws -> T) rethrows -> T {
try writer.sync(value)
}
@@ -319,6 +318,7 @@ extension DatabaseQueue: DatabaseReader {
// See <https://github.com/groue/GRDB.swift/pull/1213>.
try db.beginReadOnly()
try db.beginTransaction(.deferred)
try db.clearSchemaCacheIfNeeded()
value(.success(db))
} catch {
value(.failure(error))
@@ -391,7 +391,6 @@ extension DatabaseQueue: DatabaseWriter {
}
}
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T {
try writer.sync(updates)
}
@@ -402,7 +401,6 @@ extension DatabaseQueue: DatabaseWriter {
try await writer.execute(updates)
}
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) throws -> T {
try writer.sync(updates)
}
@@ -185,7 +185,6 @@ public protocol DatabaseReader: AnyObject, Sendable {
/// - parameter value: A closure which accesses the database.
/// - throws: The error thrown by `value`, or any ``DatabaseError`` that
/// would happen while establishing the database access.
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
func read<T>(_ value: (Database) throws -> T) throws -> T
/// Executes read-only database operations, and returns their result after
@@ -283,7 +282,6 @@ public protocol DatabaseReader: AnyObject, Sendable {
/// - parameter value: A closure which accesses the database.
/// - throws: The error thrown by `value`, or any ``DatabaseError`` that
/// would happen while establishing the database access.
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T
/// Executes database operations, and returns their result after they have
@@ -646,7 +644,6 @@ extension AnyDatabaseReader: DatabaseReader {
base.interrupt()
}
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func read<T>(_ value: (Database) throws -> T) throws -> T {
try base.read(value)
}
@@ -663,7 +660,6 @@ extension AnyDatabaseReader: DatabaseReader {
base.asyncRead(value)
}
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T {
try base.unsafeRead(value)
}
@@ -741,7 +737,6 @@ extension DatabaseSnapshotReader {
}
// There is no such thing as an unsafe access to a snapshot.
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T {
try read(value)
}
File renamed without changes.
@@ -202,7 +202,7 @@ extension DatabasePublishers {
}
public func receive<S>(subscriber: S)
where S: Subscriber & GRDBSendableMetatype,
where S: Subscriber & SendableMetatype,
Failure == S.Failure,
Output == S.Input
{
@@ -216,7 +216,7 @@ extension DatabasePublishers {
private class DatabaseRegionSubscription<Downstream>:
Subscription, @unchecked Sendable
where Downstream: Subscriber & GRDBSendableMetatype,
where Downstream: Subscriber & SendableMetatype,
Downstream.Failure == Error,
Downstream.Input == Database
{
@@ -153,7 +153,6 @@ extension DatabaseSnapshot: DatabaseSnapshotReader {
// MARK: - Reading from Database
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func read<T>(_ block: (Database) throws -> T) rethrows -> T {
try reader.sync(block)
}
@@ -170,7 +169,6 @@ extension DatabaseSnapshot: DatabaseSnapshotReader {
reader.async { value(.success($0)) }
}
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func unsafeRead<T>(_ value: (Database) throws -> T) rethrows -> T {
try reader.sync(value)
}
@@ -1,14 +1,16 @@
#if SQLITE_ENABLE_SNAPSHOT && !SQLITE_DISABLE_SNAPSHOT
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
/// A database connection that allows concurrent accesses to unchanging
@@ -272,7 +274,6 @@ extension DatabaseSnapshotPool: DatabaseSnapshotReader {
readerPool?.forEach { $0.interrupt() }
}
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func read<T>(_ value: (Database) throws -> T) throws -> T {
GRDBPrecondition(currentReader == nil, "Database methods are not reentrant.")
guard let readerPool else {
@@ -1,13 +1,15 @@
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
import Foundation
@@ -237,8 +239,7 @@ extension DatabaseValue: StatementBinding {
extension DatabaseValue: Sendable { }
// @unchecked Sendable because Data is not Sendable in all target OS
extension DatabaseValue.Storage: @unchecked Sendable { }
extension DatabaseValue.Storage: Sendable { }
// MARK: - Hashable & Equatable
@@ -97,7 +97,6 @@ public protocol DatabaseWriter: DatabaseReader {
///
/// - parameter updates: A closure which accesses the database.
/// - throws: The error thrown by `updates`.
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T
/// Executes database operations, and returns their result after they have
@@ -170,7 +169,6 @@ public protocol DatabaseWriter: DatabaseReader {
///
/// - parameter updates: A closure which accesses the database.
/// - throws: The error thrown by `updates`.
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) throws -> T
/// Executes database operations, and returns their result after they have
@@ -412,7 +410,6 @@ extension DatabaseWriter {
/// - throws: The error thrown by `updates`, or any ``DatabaseError`` that
/// would happen while establishing the database access or committing
/// the transaction.
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func write<T>(_ updates: (Database) throws -> T) throws -> T {
try writeWithoutTransaction { db in
var result: T?
@@ -527,7 +524,6 @@ extension DatabaseWriter {
// MARK: - Erasing the content of the database
/// Erase the database: delete all content, drop all tables, etc.
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func erase() throws {
try barrierWriteWithoutTransaction { try $0.erase() }
}
@@ -538,22 +534,10 @@ extension DatabaseWriter {
/// disk space.
///
/// Related SQLite documentation: <https://www.sqlite.org/lang_vacuum.html>
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func vacuum() throws {
try writeWithoutTransaction { try $0.execute(sql: "VACUUM") }
}
// VACUUM INTO was introduced in SQLite 3.27.0:
// https://www.sqlite.org/releaselog/3_27_0.html
//
// Old versions of SQLCipher won't have it, but I don't know how to perform
// availability checks that depend on the version of the SQLCipher CocoaPod
// chosen by the application. So let's just have the method fail at runtime.
//
// This method is declared on DatabaseWriter instead of DatabaseReader,
// so that it is not available on DatabaseSnaphot. VACUUM INTO is not
// available inside the transaction that is kept open by DatabaseSnaphot.
#if GRDBCUSTOMSQLITE || SQLITE_HAS_CODEC
/// Creates a new database file at the specified path with a minimum
/// amount of disk space.
///
@@ -563,27 +547,11 @@ extension DatabaseWriter {
/// Related SQLite documentation: <https://www.sqlite.org/lang_vacuum.html#vacuuminto>
///
/// - Parameter filePath: file path for new database
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func vacuum(into filePath: String) throws {
try writeWithoutTransaction {
try $0.execute(sql: "VACUUM INTO ?", arguments: [filePath])
}
}
#else
/// Creates a new database file at the specified path with a minimum
/// amount of disk space.
///
/// Related SQLite documentation: <https://www.sqlite.org/lang_vacuum.html#vacuuminto>
///
/// - Parameter filePath: file path for new database
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
@available(iOS 14, macOS 10.16, tvOS 14, *)
public func vacuum(into filePath: String) throws {
try writeWithoutTransaction {
try $0.execute(sql: "VACUUM INTO ?", arguments: [filePath])
}
}
#endif
// MARK: - Database Observation
@@ -666,7 +634,6 @@ extension DatabaseWriter {
try await writeWithoutTransaction { try $0.execute(sql: "VACUUM") }
}
#if GRDBCUSTOMSQLITE || SQLITE_HAS_CODEC
/// Creates a new database file at the specified path with a minimum
/// amount of disk space.
///
@@ -681,19 +648,6 @@ extension DatabaseWriter {
try $0.execute(sql: "VACUUM INTO ?", arguments: [filePath])
}
}
#else
/// Creates a new database file at the specified path with a minimum
/// amount of disk space.
///
/// Related SQLite documentation: <https://www.sqlite.org/lang_vacuum.html#vacuuminto>
///
/// - Parameter filePath: file path for new database
public func vacuum(into filePath: String) async throws {
try await writeWithoutTransaction {
try $0.execute(sql: "VACUUM INTO ?", arguments: [filePath])
}
}
#endif
}
#if canImport(Combine)
@@ -880,7 +834,6 @@ extension AnyDatabaseWriter: DatabaseReader {
base.interrupt()
}
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func read<T>(_ value: (Database) throws -> T) throws -> T {
try base.read(value)
}
@@ -897,7 +850,6 @@ extension AnyDatabaseWriter: DatabaseReader {
base.asyncRead(value)
}
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T {
try base.unsafeRead(value)
}
@@ -931,7 +883,6 @@ extension AnyDatabaseWriter: DatabaseReader {
}
extension AnyDatabaseWriter: DatabaseWriter {
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T {
try base.writeWithoutTransaction(updates)
}
@@ -942,7 +893,6 @@ extension AnyDatabaseWriter: DatabaseWriter {
try await base.writeWithoutTransaction(updates)
}
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
public func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) throws -> T {
try base.barrierWriteWithoutTransaction(updates)
}
File renamed without changes.
@@ -1,13 +1,15 @@
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
import Foundation
@@ -58,7 +60,6 @@ import Foundation
/// - ``decode(_:atIndex:)-33ykh``
/// - ``decode(_:atIndex:)-3btwn``
/// - ``withUnsafeData(atIndex:_:)``
/// - ``dataNoCopy(atIndex:)``
///
/// ### Accessing Row Values by Column Name
///
@@ -69,7 +70,6 @@ import Foundation
/// - ``decode(_:forColumn:)-4i1o4``
/// - ``decode(_:forColumn:)-4rhs4``
/// - ``withUnsafeData(named:_:)``
/// - ``dataNoCopy(named:)``
///
/// ### Accessing Row Values by Column
///
@@ -80,7 +80,6 @@ import Foundation
/// - ``decode(_:forColumn:)-1ljuo``
/// - ``decode(_:forColumn:)-47qeg``
/// - ``withUnsafeData(at:_:)``
/// - ``dataNoCopy(_:)``
///
/// ### Row Scopes & Associated Rows
///
@@ -321,8 +320,8 @@ extension Row {
// MARK: - Extracting Values
/// Fatal errors if index is out of bounds
@inline(__always)
@usableFromInline
@inline(always)
@inlinable
/* private */ func _checkIndex(_ index: Int, file: StaticString = #file, line: UInt = #line) {
GRDBPrecondition(index >= 0 && index < count, "row index out of range", file: file, line: line)
}
@@ -425,7 +424,7 @@ extension Row {
/// let row = try Row.fetchOne(db, sql: "SELECT NULL")!
/// let name: String? = row[0] // nil
/// ```
@inline(__always)
@inline(always)
@inlinable
public subscript<Value: DatabaseValueConvertible & StatementColumnConvertible>(_ index: Int) -> Value {
try! decode(Value.self, atIndex: index)
@@ -654,56 +653,6 @@ extension Row {
try withUnsafeData(named: column.name, body)
}
/// Returns the optional `Data` at given index.
///
/// Indexes span from `0` for the leftmost column to `row.count - 1` for the
/// rightmost column.
///
/// If the SQLite value is NULL, the result is nil. If the SQLite value can
/// not be converted to Data, a fatal error is raised.
///
/// The returned data does not own its bytes: it must not be used longer
/// than the row's lifetime.
@available(*, deprecated, message: "Use withUnsafeData(atIndex:_:) instead.")
public func dataNoCopy(atIndex index: Int) -> Data? {
try! withUnsafeData(atIndex: index, { $0 })
}
/// Returns the optional `Data` at given column.
///
/// Column name lookup is case-insensitive. When several columns exist with
/// the same name, the leftmost column is considered.
///
/// If the column is missing or if the SQLite value is NULL, the result is
/// nil. If the SQLite value cannot be converted to Data, a fatal error
/// is raised.
///
/// The returned data does not own its bytes: it must not be used longer
/// than the row's lifetime.
@available(*, deprecated, message: "Use withUnsafeData(named:_:) instead.")
public func dataNoCopy(named columnName: String) -> Data? {
guard let index = index(forColumn: columnName) else {
return nil
}
return try! withUnsafeData(atUncheckedIndex: index, { $0 })
}
/// Returns the optional `Data` at given column.
///
/// Column name lookup is case-insensitive. When several columns exist with
/// the same name, the leftmost column is considered.
///
/// If the column is missing or if the SQLite value is NULL, the result is
/// nil. If the SQLite value cannot be converted to Data, a fatal error
/// is raised.
///
/// The returned data does not own its bytes: it must not be used longer
/// than the row's lifetime.
@available(*, deprecated, message: "Use withUnsafeData(at:_:) instead.")
public func dataNoCopy(_ column: some ColumnExpression) -> Data? {
dataNoCopy(named: column.name)
}
/// Returns the first non-null value, if any. Identical to SQL `COALESCE` function.
///
/// For example:
@@ -1253,7 +1202,7 @@ extension Row {
/// ```
///
/// - throws: Any error that happens during the decoding.
@inline(__always)
@inline(always)
@inlinable
public func decode<Value: DatabaseValueConvertible & StatementColumnConvertible>(
_ type: Value.Type = Value.self,
@@ -2407,9 +2356,6 @@ extension Row: ExpressibleByDictionaryLiteral {
// MARK: - Index
@available(*, deprecated, renamed: "Row.Index")
typealias RowIndex = Row.Index
extension Row {
/// An index to a (column, value) pair in a ``Row``.
public struct Index: Sendable {
File renamed without changes.
@@ -1,13 +1,15 @@
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
/// A key that is used to decode a value in a row
File renamed without changes.
File renamed without changes.
@@ -45,33 +45,21 @@
/// - ``init(sql:arguments:adapter:cached:)-3qq8t``
/// - ``init(sql:arguments:adapter:cached:)-5ecx2``
public struct SQLRequest<RowDecoder> {
/// There are two statement caches: one "public" for statements generated by
/// the user, and one "internal" for the statements generated by GRDB. Those
/// are separated so that GRDB has no opportunity to inadvertently modify
/// the arguments of the user's cached statements.
enum Cache {
/// The public cache, for library user
case `public`
/// The internal cache, for GRDB
case `internal`
}
/// The row adapter.
public var adapter: (any RowAdapter)?
private(set) var sqlLiteral: SQL
let cache: Cache?
let cached: Bool
private init(
literal sqlLiteral: SQL,
adapter: (any RowAdapter)?,
fromCache cache: Cache?,
cached: Bool,
type: RowDecoder.Type)
{
self.sqlLiteral = sqlLiteral
self.adapter = adapter
self.cache = cache
self.cached = cached
}
}
@@ -102,7 +90,7 @@ extension SQLRequest {
self.init(
literal: SQL(sql: sql, arguments: arguments),
adapter: adapter,
fromCache: cached ? .public : nil,
cached: cached,
type: RowDecoder.self)
}
@@ -127,7 +115,7 @@ extension SQLRequest {
self.init(
literal: sqlLiteral,
adapter: adapter,
fromCache: cached ? .public : nil,
cached: cached,
type: RowDecoder.self)
}
}
@@ -156,7 +144,7 @@ extension SQLRequest<Row> {
self.init(
literal: SQL(sql: sql, arguments: arguments),
adapter: adapter,
fromCache: cached ? .public : nil,
cached: cached,
type: Row.self)
}
@@ -181,7 +169,7 @@ extension SQLRequest<Row> {
self.init(
literal: sqlLiteral,
adapter: adapter,
fromCache: cached ? .public : nil,
cached: cached,
type: Row.self)
}
}
@@ -202,15 +190,9 @@ extension SQLRequest: FetchRequest {
{
let context = SQLGenerationContext(db)
let sql = try sqlLiteral.sql(context)
let statement: Statement
switch cache {
case .none:
statement = try db.makeStatement(sql: sql)
case .public:
statement = try db.cachedStatement(sql: sql)
case .internal:
statement = try db.internalCachedStatement(sql: sql)
}
let statement = try cached
? db.cachedStatement(sql: sql)
: db.makeStatement(sql: sql)
try statement.setArguments(context.arguments)
return PreparedRequest(statement: statement, adapter: adapter)
}
@@ -1,13 +1,15 @@
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
import Foundation
@@ -163,8 +165,8 @@ public final class Statement {
/// containing SQL.
/// - parameter statementEnd: Upon success, the pointer to the next
/// statement in the C string.
/// - parameter prepFlags: Flags for sqlite3_prepare_v3 (available from
/// SQLite 3.20.0, see <http://www.sqlite.org/c3ref/prepare.html>)
/// - parameter prepFlags: Flags for `sqlite3_prepare_v3` see
/// <http://www.sqlite.org/c3ref/prepare.html>.
/// - throws: DatabaseError in case of compilation error.
required init?(
database: Database,
@@ -465,6 +467,20 @@ public final class Statement {
}
}
/// Resets the statement, and clears its arguments, so that it is in the
/// same state as a newly prepared statement.
///
/// - precondition: this method is called on a valid dispatch queue.
func prepareForReuse() {
// Ignore the result of sqlite3_reset, which might report the error
// of the last sqlite3_step(), if any. This should not prevent reuse.
// <https://www.sqlite.org/c3ref/reset.html>
sqlite3_reset(sqliteStatement)
clearBindings()
_arguments = StatementArguments()
argumentsAreValidAndBound = false
}
// MARK: Execution
func reset() throws {
@@ -1,13 +1,15 @@
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
#if canImport(string_h)
@@ -213,7 +215,7 @@ final class StatementAuthorizer {
private func insertUpdateEventKind(tableName: String, columnName: String) {
for (index, eventKind) in databaseEventKinds.enumerated() {
if case .update(let t, let columnNames) = eventKind, t == tableName {
if case let .update(t, columnNames) = eventKind, t == tableName {
var columnNames = columnNames
columnNames.insert(columnName)
databaseEventKinds[index] = .update(tableName: tableName, columnNames: columnNames)
@@ -1,13 +1,15 @@
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
/// A type that can decode itself from the low-level C interface to
@@ -126,7 +128,7 @@ public protocol StatementColumnConvertible {
extension StatementColumnConvertible {
// `Optional` overrides this default behavior.
/// Default implementation fails on decoding NULL.
@inline(__always)
@inline(always)
@inlinable
public static func fromStatement(_ sqliteStatement: SQLiteStatement, atUncheckedIndex index: CInt) -> Self? {
if sqlite3_column_type(sqliteStatement, index) == SQLITE_NULL {
@@ -153,7 +155,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
context: context())
}
@inline(__always)
@inline(always)
@inlinable
static func fastDecode(
fromRow row: Row,
@@ -170,7 +172,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
return try row.fastDecode(Self.self, atUncheckedIndex: index)
}
@inline(__always)
@inline(always)
@inlinable
static func fastDecode(
fromStatement sqliteStatement: SQLiteStatement,
@@ -186,7 +188,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
}
// Support for Decodable
@inline(__always)
@inline(always)
@inlinable
static func fastDecodeIfPresent(
fromRow row: Row,
@@ -1,13 +1,15 @@
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
import Foundation
@@ -1,13 +1,15 @@
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
import Foundation
@@ -79,7 +81,7 @@ extension DatabaseDateComponents: StatementColumnConvertible {
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
@inline(__always)
@inline(always)
@inlinable
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
guard let cString = sqlite3_column_text(sqliteStatement, index) else {
@@ -1,13 +1,15 @@
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
import Foundation
@@ -132,7 +134,7 @@ extension Date: StatementColumnConvertible {
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
@inline(__always)
@inline(always)
@inlinable
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
switch sqlite3_column_type(sqliteStatement, index) {
@@ -1,13 +1,15 @@
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
import Foundation
@@ -47,7 +49,7 @@ extension Decimal: DatabaseValueConvertible {
/// Decimal adopts StatementColumnConvertible
extension Decimal: StatementColumnConvertible {
@inline(__always)
@inline(always)
@inlinable
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
switch sqlite3_column_type(sqliteStatement, index) {
@@ -1,13 +1,15 @@
// Import C SQLite functions
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
#if GRDBFRAMEWORK // GRDB.xcodeproj
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
#elseif SQLCipher
import SQLCipher
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#else // SPM
#if SQLCipher // Takes precedence over SystemSQLite
import SQLCipher
#elseif SystemSQLite
import GRDBSQLite
#else
#error("Enable a GRDB trait that provides SQLite.")
#endif
#endif
import Foundation
@@ -84,7 +86,7 @@ extension UUID: DatabaseValueConvertible {
}
extension UUID: StatementColumnConvertible {
@inline(__always)
@inline(always)
@inlinable
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
switch sqlite3_column_type(sqliteStatement, index) {
@@ -39,7 +39,7 @@ extension StatementBinding where Self: RawRepresentable, Self.RawValue: Statemen
/// // adopt StatementColumnConvertible:
/// extension Color: StatementColumnConvertible { }
extension StatementColumnConvertible where Self: RawRepresentable, Self.RawValue: StatementColumnConvertible {
@inline(__always)
@inline(always)
@inlinable
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
guard let rawValue = RawValue(sqliteStatement: sqliteStatement, index: index) else {
Loaded 100 of 612 files, more files were not shown because too many files have changed in this diff. Show more