mirror of
https://github.com/groue/GRDB.swift
synced 2026-12-06 05:28:44 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45e58e64b7 | ||
|
|
8123704c56 | ||
|
|
b0e1be2e70 |
No files matched your search
@@ -18,11 +18,12 @@ Please fill out this template when filing an issue.
|
|||||||
|
|
||||||
### Environment
|
### Environment
|
||||||
|
|
||||||
|
**GRDB flavor(s):** (GRDB, SQLCipher, Custom SQLite build?)
|
||||||
**GRDB version:**
|
**GRDB version:**
|
||||||
**Enabled SwiftPM traits:**
|
**Installation method:** (CocoaPods, SPM, manual?)
|
||||||
**Xcode version:**
|
**Xcode version:**
|
||||||
**Swift version:**
|
**Swift version:**
|
||||||
**Platform(s) running GRDB:**
|
**Platform(s) running GRDB:** (iOS, macOS, watchOS?)
|
||||||
**macOS version running Xcode:**
|
**macOS version running Xcode:**
|
||||||
|
|
||||||
### Demo Project
|
### Demo Project
|
||||||
|
|||||||
+41
-24
@@ -1,4 +1,4 @@
|
|||||||
# https://github.com/actions/runner-images/blob/main/images/macos/xcode-27-arm64-Readme.md
|
# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md
|
||||||
|
|
||||||
name: "GRDB CI"
|
name: "GRDB CI"
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ on:
|
|||||||
- master
|
- master
|
||||||
- development
|
- development
|
||||||
paths:
|
paths:
|
||||||
- 'Sources/**'
|
- 'GRDB/**'
|
||||||
- 'Tests/**'
|
- 'Tests/**'
|
||||||
- '.github/workflows/**'
|
- '.github/workflows/**'
|
||||||
- 'Makefile'
|
- 'Makefile'
|
||||||
@@ -16,7 +16,7 @@ on:
|
|||||||
- 'SQLiteCustom/src'
|
- 'SQLiteCustom/src'
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- 'Sources/**'
|
- 'GRDB/**'
|
||||||
- 'Tests/**'
|
- 'Tests/**'
|
||||||
- '.github/workflows/**'
|
- '.github/workflows/**'
|
||||||
- 'Makefile'
|
- 'Makefile'
|
||||||
@@ -40,17 +40,17 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- xcode: "Xcode_27.2.app"
|
- xcode: "Xcode_16.4.app"
|
||||||
runsOn: xcode-27
|
runsOn: macOS-15
|
||||||
destination: "platform=macOS"
|
destination: "platform=macOS"
|
||||||
name: "macOS"
|
name: "macOS"
|
||||||
- xcode: "Xcode_27.2.app"
|
- xcode: "Xcode_16.4.app"
|
||||||
runsOn: xcode-27
|
runsOn: macOS-15
|
||||||
destination: "OS=27.2,name=iPhone 17"
|
destination: "OS=18.5,name=iPhone 16 Pro"
|
||||||
name: "iOS"
|
name: "iOS"
|
||||||
- xcode: "Xcode_27.2.app"
|
- xcode: "Xcode_16.4.app"
|
||||||
runsOn: xcode-27
|
runsOn: macOS-15
|
||||||
destination: "OS=27.2,name=Apple TV 4K (4th generation)"
|
destination: "OS=18.5,name=Apple TV"
|
||||||
name: "tvOS"
|
name: "tvOS"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
@@ -66,13 +66,30 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- xcode: "Xcode_27.2.app"
|
- xcode: "Xcode_16.4.app"
|
||||||
runsOn: xcode-27
|
runsOn: macOS-15
|
||||||
name: "Xcode 27.2"
|
name: "Xcode 16.4"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- name: ${{ matrix.name }}
|
- name: ${{ matrix.name }}
|
||||||
run: make test_SPM test_install_SPM
|
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:
|
SQLCipher4:
|
||||||
name: SQLCipher4
|
name: SQLCipher4
|
||||||
runs-on: ${{ matrix.runsOn }}
|
runs-on: ${{ matrix.runsOn }}
|
||||||
@@ -83,13 +100,13 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- xcode: "Xcode_27.2.app"
|
- xcode: "Xcode_16.4.app"
|
||||||
runsOn: xcode-27
|
runsOn: macOS-15
|
||||||
name: "Xcode 27.2"
|
name: "Xcode 16.4"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- name: ${{ matrix.name }}
|
- name: ${{ matrix.name }}
|
||||||
run: make test_SPM_SQLCipherEncrypted
|
run: make test_framework_SQLCipher4Encrypted
|
||||||
# CustomSQLite:
|
# CustomSQLite:
|
||||||
# name: CustomSQLite
|
# name: CustomSQLite
|
||||||
# runs-on: ${{ matrix.runsOn }}
|
# runs-on: ${{ matrix.runsOn }}
|
||||||
@@ -100,9 +117,9 @@ jobs:
|
|||||||
# fail-fast: false
|
# fail-fast: false
|
||||||
# matrix:
|
# matrix:
|
||||||
# include:
|
# include:
|
||||||
# - xcode: "Xcode_27.2.app"
|
# - xcode: "Xcode_16.4.app"
|
||||||
# runsOn: xcode-27
|
# runsOn: macOS-15
|
||||||
# name: "Xcode 27.2"
|
# name: "Xcode 16.4"
|
||||||
# steps:
|
# steps:
|
||||||
# - uses: actions/checkout@v5
|
# - uses: actions/checkout@v5
|
||||||
# - name: ${{ matrix.name }}
|
# - name: ${{ matrix.name }}
|
||||||
@@ -117,9 +134,9 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- xcode: "Xcode_27.2.app"
|
- xcode: "Xcode_16.4.app"
|
||||||
runsOn: xcode-27
|
runsOn: macOS-15
|
||||||
name: "Xcode 27.2"
|
name: "Xcode 16.4"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
- name: ${{ matrix.name }}
|
- name: ${{ matrix.name }}
|
||||||
|
|||||||
+6
-1
@@ -71,7 +71,6 @@ Session.vim
|
|||||||
# Build generated
|
# Build generated
|
||||||
build/
|
build/
|
||||||
DerivedData
|
DerivedData
|
||||||
/Package.resolved
|
|
||||||
|
|
||||||
# Various settings
|
# Various settings
|
||||||
*.pbxuser
|
*.pbxuser
|
||||||
@@ -101,6 +100,10 @@ xcuserdata
|
|||||||
SQLiteCustom/GRDBCustomSQLite-USER.h
|
SQLiteCustom/GRDBCustomSQLite-USER.h
|
||||||
SQLiteCustom/GRDBCustomSQLite-USER.xcconfig
|
SQLiteCustom/GRDBCustomSQLite-USER.xcconfig
|
||||||
|
|
||||||
|
# CocoaPods test
|
||||||
|
Pods
|
||||||
|
Podfile.lock
|
||||||
|
|
||||||
# SPM
|
# SPM
|
||||||
.build
|
.build
|
||||||
GRDB.xcworkspace/xcshareddata/swiftpm
|
GRDB.xcworkspace/xcshareddata/swiftpm
|
||||||
@@ -110,3 +113,5 @@ Tests/SPM/Packages
|
|||||||
# Ruby
|
# Ruby
|
||||||
.ruby-version
|
.ruby-version
|
||||||
|
|
||||||
|
# Test products
|
||||||
|
Tests/products
|
||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
[submodule "SQLiteCustom/src"]
|
[submodule "SQLiteCustom/src"]
|
||||||
path = SQLiteCustom/src
|
path = SQLiteCustom/src
|
||||||
url = https://github.com/groue/SQLiteLib
|
url = https://github.com/swiftlyfalling/SQLiteLib.git
|
||||||
+161
@@ -0,0 +1,161 @@
|
|||||||
|
# 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
|
||||||
@@ -144,29 +144,6 @@ 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.
|
|
||||||
- **New**: Asynchronous database accesses accept `sending` closures and return `sending` results, instead of requiring `Sendable` closures and results. Some callback-based database accesses (with completion blocks) are improved in the same way (`asyncRead(_:)`, `asyncMigrate(_:completion:)`, `writePublisher(receiveOn:updates:thenRead:)`, etc.)
|
|
||||||
- **New**: `ValueObservation` and `SharedValueObservation` can be started from any actor, not only the main actor, and notify fresh values on this actor.
|
|
||||||
- **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**: In the Swift 5 language mode, the shorthand closure notation in asynchronous database accesses, such as `try await writer.read(Player.fetchAll)`, triggers a compiler warning, even when the `InferSendableFromCaptures` upcoming feature is enabled.
|
|
||||||
- **Breaking Change**: `ValueObservation.removeDuplicates(by:)` requires a `Sendable` predicate.
|
|
||||||
- **Breaking Change**: `ValueObservation.start()` and `SharedValueObservation.start()` must be called from an actor, and the `scheduling` argument no longer accepts a dispatch queue.
|
|
||||||
- **Breaking Change**: `ValueObservation.values()` no longer has a `scheduling` argument.
|
|
||||||
- **Breaking Change**: `SharedValueObservation.publisher()` notifies fresh values on the main dispatch queue.
|
|
||||||
- **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
|
## 7.12.1
|
||||||
|
|
||||||
Released November 30, 2026
|
Released November 30, 2026
|
||||||
|
|||||||
+3
-1
@@ -11,6 +11,7 @@ How you can Contribute
|
|||||||
|
|
||||||
- For running tests:
|
- For running tests:
|
||||||
- Ruby
|
- Ruby
|
||||||
|
- [CocoaPods](https://cocoapods.org) (gem)
|
||||||
- [xcpretty](https://github.com/xcpretty/xcpretty) (gem)
|
- [xcpretty](https://github.com/xcpretty/xcpretty) (gem)
|
||||||
- For contributing code:
|
- For contributing code:
|
||||||
- [Swiftlint](https://github.com/realm/SwiftLint) (present in the `$PATH` or in `/opt/homebrew/bin/`)
|
- [Swiftlint](https://github.com/realm/SwiftLint) (present in the `$PATH` or in `/opt/homebrew/bin/`)
|
||||||
@@ -27,7 +28,8 @@ How you can Contribute
|
|||||||
- `GRDB`: GRDB sources
|
- `GRDB`: GRDB sources
|
||||||
- `Tests`: GRDB tests
|
- `Tests`: GRDB tests
|
||||||
- `GRDBCustom.xcodeproj`: the project which builds GRDB with a custom SQLite build.
|
- `GRDBCustom.xcodeproj`: the project which builds GRDB with a custom SQLite build.
|
||||||
- `GRDBDemo.xcodeproj`: the demo app.
|
- `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.
|
||||||
|
|
||||||
To work with `GRDBCustom.xcodeproj`:
|
To work with `GRDBCustom.xcodeproj`:
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ Custom SQLite Builds
|
|||||||
|
|
||||||
By default, GRDB uses the version of SQLite that ships with the target operating system.
|
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.54.1](https://www.sqlite.org/changes.html).**
|
**You can build GRDB with a custom build of [SQLite 3.47.2](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).
|
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 [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.
|
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.
|
||||||
|
|
||||||
> 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).
|
> 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_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 26.6;
|
IPHONEOS_DEPLOYMENT_TARGET = 17.6;
|
||||||
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
@@ -346,7 +346,7 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 26.6;
|
IPHONEOS_DEPLOYMENT_TARGET = 17.6;
|
||||||
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
@@ -381,7 +381,6 @@
|
|||||||
MARKETING_VERSION = 1.0;
|
MARKETING_VERSION = 1.0;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemo;
|
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemo;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
SWIFT_VERSION = 6.1;
|
SWIFT_VERSION = 6.1;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
@@ -411,7 +410,6 @@
|
|||||||
MARKETING_VERSION = 1.0;
|
MARKETING_VERSION = 1.0;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemo;
|
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemo;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
SWIFT_VERSION = 6.1;
|
SWIFT_VERSION = 6.1;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
@@ -428,7 +426,6 @@
|
|||||||
MARKETING_VERSION = 1.0;
|
MARKETING_VERSION = 1.0;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoTests;
|
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoTests;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
|
||||||
SWIFT_EMIT_LOC_STRINGS = NO;
|
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||||
SWIFT_VERSION = 6.1;
|
SWIFT_VERSION = 6.1;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
@@ -446,7 +443,6 @@
|
|||||||
MARKETING_VERSION = 1.0;
|
MARKETING_VERSION = 1.0;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoTests;
|
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBDemoTests;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
|
||||||
SWIFT_EMIT_LOC_STRINGS = NO;
|
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||||
SWIFT_VERSION = 6.1;
|
SWIFT_VERSION = 6.1;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "2720"
|
LastUpgradeVersion = "2600"
|
||||||
version = "1.7">
|
version = "1.7">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
|||||||
@@ -141,8 +141,8 @@ extension AppDatabase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete a random player
|
// Delete a random player
|
||||||
if Bool.random(), let player = try Player.order(sql: "RANDOM()").fetchOne(db) {
|
if Bool.random() {
|
||||||
try player.delete(db)
|
try Player.order(sql: "RANDOM()").limit(1).deleteAll(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update some players
|
// Update some players
|
||||||
|
|||||||
@@ -65,12 +65,18 @@
|
|||||||
},
|
},
|
||||||
"Anonymous" : {
|
"Anonymous" : {
|
||||||
|
|
||||||
|
},
|
||||||
|
"Cancel" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Name" : {
|
"Name" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"New Player" : {
|
"New Player" : {
|
||||||
|
|
||||||
|
},
|
||||||
|
"Save" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Score" : {
|
"Score" : {
|
||||||
|
|
||||||
|
|||||||
@@ -14,12 +14,10 @@ struct PlayerCreationSheet: View {
|
|||||||
.navigationTitle("New Player")
|
.navigationTitle("New Player")
|
||||||
.toolbar {
|
.toolbar {
|
||||||
ToolbarItem(placement: .cancellationAction) {
|
ToolbarItem(placement: .cancellationAction) {
|
||||||
Button(role: .cancel) {
|
Button("Cancel") { dismiss() }
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ToolbarItem(placement: .confirmationAction) {
|
ToolbarItem(placement: .confirmationAction) {
|
||||||
Button(role: .confirm) {
|
Button("Save") {
|
||||||
save()
|
save()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct PlayerEditView: View {
|
struct PlayerEditView: View {
|
||||||
|
@Environment(\.isPresented) var isPresented
|
||||||
@Environment(\.appDatabase) var appDatabase
|
@Environment(\.appDatabase) var appDatabase
|
||||||
@State var form: PlayerForm
|
@State var form: PlayerForm
|
||||||
var player: Player
|
var player: Player
|
||||||
@@ -15,9 +16,11 @@ struct PlayerEditView: View {
|
|||||||
PlayerFormView(form: $form)
|
PlayerFormView(form: $form)
|
||||||
}
|
}
|
||||||
.navigationTitle(player.name)
|
.navigationTitle(player.name)
|
||||||
.onDisappear {
|
.onChange(of: isPresented) {
|
||||||
// Back button was pressed
|
if !isPresented {
|
||||||
save()
|
// Back button was pressed
|
||||||
|
save()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ You can still specify a transaction kind explicitly when necessary. See [Transac
|
|||||||
|
|
||||||
In GRDB 7, `ValueObservation` favors the main actor, because it is frequently used to automatically update database values on screen.
|
In GRDB 7, `ValueObservation` favors the main actor, because it is frequently used to automatically update database values on screen.
|
||||||
|
|
||||||
By default, its [`start`](https://swiftpackageindex.com/groue/GRDB.swift/v7.12.1/documentation/grdb/valueobservation/start(in:scheduling:onerror:onchange:)-4mqbs) method must be called on the main actor, and its notification callbacks run on the main actor as well.
|
By default, its [`start`](https://swiftpackageindex.com/groue/GRDB.swift/documentation/grdb/valueobservation/start(in:scheduling:onerror:onchange:)) method must be called on the main actor, and its notification callbacks run on the main actor as well.
|
||||||
|
|
||||||
It is not necessary to call `MainActor.assumeIsolated` in `ValueObservation` callbacks:
|
It is not necessary to call `MainActor.assumeIsolated` in `ValueObservation` callbacks:
|
||||||
|
|
||||||
@@ -273,7 +273,7 @@ Do not miss [Swift Concurrency and GRDB], for more recommendations regarding non
|
|||||||
|
|
||||||
- The `PersistenceContainer` subscript no longer guarantees that the value returned is the same as what was previously set. It only guarantees that both values are encoded identically in the database.
|
- The `PersistenceContainer` subscript no longer guarantees that the value returned is the same as what was previously set. It only guarantees that both values are encoded identically in the database.
|
||||||
|
|
||||||
- The async sequence returned by [`ValueObservation.values`](https://swiftpackageindex.com/groue/GRDB.swift/v7.12.1/documentation/grdb/valueobservation/values(in:scheduling:bufferingpolicy:)) now iterates on the cooperative thread pool by default. Use .mainActor as the scheduler if you need the previous behavior.
|
- The async sequence returned by [`ValueObservation.values`](https://swiftpackageindex.com/groue/GRDB.swift/documentation/grdb/valueobservation/values(in:scheduling:bufferingpolicy:)) now iterates on the cooperative thread pool by default. Use .mainActor as the scheduler if you need the previous behavior.
|
||||||
|
|
||||||
[Migrating to Swift 6]: https://www.swift.org/migration/documentation/migrationguide
|
[Migrating to Swift 6]: https://www.swift.org/migration/documentation/migrationguide
|
||||||
[Sharing a Database]: https://swiftpackageindex.com/groue/GRDB.swift/documentation/grdb/databasesharing
|
[Sharing a Database]: https://swiftpackageindex.com/groue/GRDB.swift/documentation/grdb/databasesharing
|
||||||
|
|||||||
@@ -1,162 +0,0 @@
|
|||||||
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)
|
|
||||||
- [Starting Value Observations](#starting-value-observations)
|
|
||||||
- [Shorthand Closure Notation in Asynchronous Database Accesses](#shorthand-closure-notation-in-asynchronous-database-accesses)
|
|
||||||
- [Removing Duplicate Observed Values](#removing-duplicate-observed-values)
|
|
||||||
- [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.
|
|
||||||
|
|
||||||
## Starting Value Observations
|
|
||||||
|
|
||||||
In GRDB 7, `ValueObservation` notifies fresh values on the main actor, or on a `DispatchQueue`. In GRDB 8, the `start` method must be called from an actor, and always notifies fresh values on this actor. Its `onError` and `onChange` closures no longer have to be `Sendable`.
|
|
||||||
|
|
||||||
Observations started from the main actor, without any `scheduling` argument or with the `.immediate` scheduling, are not affected.
|
|
||||||
|
|
||||||
```swift
|
|
||||||
// GRDB 7+8
|
|
||||||
@MainActor func start() {
|
|
||||||
cancellable = observation.start(in: dbQueue) { error in
|
|
||||||
// Handle error
|
|
||||||
} onChange: { (players: [Player]) in
|
|
||||||
self.players = players
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
When application code starts observation from nonisolated code, or provides an explicit `DispatchQueue`, the compiler reports some errors:
|
|
||||||
|
|
||||||
```swift
|
|
||||||
// GRDB 8
|
|
||||||
nonisolated func start() {
|
|
||||||
// ❌ Call to actor-isolated instance method
|
|
||||||
// 'start(in:scheduling:isolation:onError:onChange:)' in a
|
|
||||||
// synchronous nonisolated context
|
|
||||||
// ❌ 'nil' is not compatible with expected argument type
|
|
||||||
// 'any Actor'
|
|
||||||
cancellable = observation.start(
|
|
||||||
in: dbQueue,
|
|
||||||
// ❌ 'async(onQueue:)' is unavailable: Remove the scheduling argument.
|
|
||||||
scheduling: .async(onQueue: .main),
|
|
||||||
) { error in
|
|
||||||
// Handle error
|
|
||||||
} onChange: { (players: [Player]) in
|
|
||||||
print("Fresh players: \(players)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
To fix those errors, isolate the code in an actor, such as the main actor, and remove the `scheduling` argument:
|
|
||||||
|
|
||||||
```swift
|
|
||||||
// GRDB 8
|
|
||||||
@MainActor func start() {
|
|
||||||
cancellable = observation.start(in: dbQueue) { error in
|
|
||||||
// Handle error
|
|
||||||
} onChange: { (players: [Player]) in
|
|
||||||
print("Fresh players: \(players)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
`SharedValueObservation` follows the same rules: its `start` method must be called from an actor, and notifies fresh values on this actor.
|
|
||||||
|
|
||||||
## Shorthand Closure Notation in Asynchronous Database Accesses
|
|
||||||
|
|
||||||
In applications compiled in the Swift 5 language mode, an asynchronous database access that uses the shorthand closure notation triggers a compiler warning with GRDB 8:
|
|
||||||
|
|
||||||
```swift
|
|
||||||
// GRDB 8, application in Swift 5 language mode
|
|
||||||
// ⚠️ Converting a value of type '(Database) throws -> [Player]' to
|
|
||||||
// type '(Database) throws -> sending [Player]' risks causing
|
|
||||||
// data races; this is an error in the Swift 6 language mode
|
|
||||||
let players = try await dbQueue.read(Player.fetchAll)
|
|
||||||
```
|
|
||||||
|
|
||||||
Fix this warning by writing a regular closure:
|
|
||||||
|
|
||||||
```swift
|
|
||||||
// GRDB 8, application in Swift 5 language mode
|
|
||||||
let players = try await dbQueue.read { db in
|
|
||||||
try Player.fetchAll(db)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Applications compiled in the Swift 6 language mode do not need to adapt their usages of the shorthand closure notation.
|
|
||||||
|
|
||||||
Synchronous database accesses are not affected, and still accept the shorthand closure notation in all language modes.
|
|
||||||
|
|
||||||
## Removing Duplicate Observed Values
|
|
||||||
|
|
||||||
The `ValueObservation.removeDuplicates(by:)` method now requires a `Sendable` predicate closure. If the compiler reports that your predicate is not `Sendable`, make it `Sendable`, for example by capturing only `Sendable` values.
|
|
||||||
|
|
||||||
`ValueObservation.removeDuplicates()`, which compares `Equatable` values, is not affected.
|
|
||||||
|
|
||||||
## 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] { ... }
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
//: 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)")
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<playground version='5.0' target-platform='macos' buildActiveScheme='true'>
|
||||||
|
<timeline fileName='timeline.xctimeline'/>
|
||||||
|
</playground>
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
// 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<playground version='5.0' target-platform='macos' buildActiveScheme='true'>
|
||||||
|
<timeline fileName='timeline.xctimeline'/>
|
||||||
|
</playground>
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
//: 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)
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?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>
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
//: 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])
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?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>
|
||||||
@@ -1,19 +1,27 @@
|
|||||||
# Releasing a New Version
|
Release Process
|
||||||
|
===============
|
||||||
|
|
||||||
|
**This is internal documentation.**
|
||||||
|
|
||||||
|
To release a new GRDB version:
|
||||||
|
|
||||||
- Tests
|
- Tests
|
||||||
- `make distclean test`
|
- `make distclean test`
|
||||||
- Build and run GRDBDemo
|
- Build and run GRDBDemo
|
||||||
- Check for performance regression with GRDBOSXPerformanceTests
|
- 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
|
- On https://github.com/swiftlyfalling/SQLiteLib upgrade, update SQLite version in Documentation/CustomSQLiteBuilds.md
|
||||||
- Update GRDB version number and release date in:
|
- Update GRDB version number and release date in:
|
||||||
- CHANGELOG.md
|
- CHANGELOG.md
|
||||||
|
- GRDB.swift.podspec
|
||||||
- README.md
|
- README.md
|
||||||
- Support/Info.plist
|
- Support/Info.plist
|
||||||
- Commit and tag
|
- Commit and tag
|
||||||
- Look for undesired tags: `git for-each-ref --format '%(refname) %(authorname)' refs/tags | sort -V`
|
- Look for undesired tags: `git for-each-ref --format '%(refname) %(authorname)' refs/tags`
|
||||||
- Push to the `master` branch
|
- Push to the `master` branch
|
||||||
- Push to the `development` branch
|
- Push to the `development` branch
|
||||||
- Push to the `GRDB8` branch
|
- Push to the `GRDB7` branch
|
||||||
|
- `pod trunk push --allow-warnings GRDB.swift.podspec`
|
||||||
- Update [performance comparison](https://github.com/groue/GRDB.swift/wiki/Performance):
|
- Update [performance comparison](https://github.com/groue/GRDB.swift/wiki/Performance):
|
||||||
|
|
||||||
`make test_performance | Tests/parsePerformanceTests.rb | Tests/generatePerformanceReport.rb`
|
`make test_performance | Tests/parsePerformanceTests.rb | Tests/generatePerformanceReport.rb`
|
||||||
File renamed without changes.
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 86 KiB |
@@ -0,0 +1,38 @@
|
|||||||
|
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
|
||||||
+28
-410
@@ -7,23 +7,13 @@
|
|||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
567DAF1C1EAB61ED00FC0928 /* grdb_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 567DAF141EAB61ED00FC0928 /* grdb_config.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
567DAF1C1EAB61ED00FC0928 /* grdb_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 567DAF141EAB61ED00FC0928 /* grdb_config.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
||||||
56D0F20C30C17218004DBD2B /* GRDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC3773F319C8CBB3004FCF85 /* GRDB.framework */; };
|
|
||||||
56E5D7FE1B4D422E00430942 /* 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, ); }; };
|
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, ); }; };
|
DC3773F919C8CBB3004FCF85 /* GRDB.h in Headers */ = {isa = PBXBuildFile; fileRef = DC3773F819C8CBB3004FCF85 /* GRDB.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
56D0F20930C17218004DBD2B /* PBXContainerItemProxy */ = {
|
|
||||||
isa = PBXContainerItemProxy;
|
|
||||||
containerPortal = DC3773EA19C8CBB3004FCF85 /* Project object */;
|
|
||||||
proxyType = 1;
|
|
||||||
remoteGlobalIDString = DC3773F219C8CBB3004FCF85;
|
|
||||||
remoteInfo = GRDBOSX;
|
|
||||||
};
|
|
||||||
56E5D7FF1B4D422E00430942 /* PBXContainerItemProxy */ = {
|
56E5D7FF1B4D422E00430942 /* PBXContainerItemProxy */ = {
|
||||||
isa = PBXContainerItemProxy;
|
isa = PBXContainerItemProxy;
|
||||||
containerPortal = DC3773EA19C8CBB3004FCF85 /* Project object */;
|
containerPortal = DC3773EA19C8CBB3004FCF85 /* Project object */;
|
||||||
@@ -31,20 +21,6 @@
|
|||||||
remoteGlobalIDString = DC3773F219C8CBB3004FCF85;
|
remoteGlobalIDString = DC3773F219C8CBB3004FCF85;
|
||||||
remoteInfo = GRDBOSX;
|
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 */
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
@@ -57,17 +33,11 @@
|
|||||||
569530FF1C9067CC00CF1A2B /* RecordCrashTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecordCrashTests.swift; sourceTree = "<group>"; };
|
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>"; };
|
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>"; };
|
569531011C9067CC00CF1A2B /* StatementCrashTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementCrashTests.swift; sourceTree = "<group>"; };
|
||||||
5698C1C32CA844F4001C0EB0 /* GRDBSwift5Tests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = GRDBSwift5Tests.xcconfig; sourceTree = "<group>"; };
|
5698C1C32CA844F4001C0EB0 /* GRDBTests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = GRDBTests.xcconfig; sourceTree = "<group>"; };
|
||||||
56B8F49A1B4E2F3600C24296 /* GRDB.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = GRDB.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>"; };
|
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>"; };
|
56C494401ED7255500CC72AF /* GRDBDeploymentTarget.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = GRDBDeploymentTarget.xcconfig; sourceTree = "<group>"; };
|
||||||
56D0F21130C17218004DBD2B /* GRDBSwift6ApproachableConcurrencyTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBSwift6ApproachableConcurrencyTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
56E5D7F91B4D422D00430942 /* GRDBTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GRDBTests.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>"; };
|
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; };
|
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>"; };
|
DC3773F719C8CBB3004FCF85 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
@@ -86,32 +56,11 @@
|
|||||||
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||||
|
|
||||||
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
||||||
1D1937F0CDDDB96354EF407C /* GRDBTestSupport */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = GRDBTestSupport; sourceTree = "<group>"; };
|
56C883812FCC65300099DE9A /* GRDB */ = {isa = PBXFileSystemSynchronizedRootGroup; exceptions = (56C8842B2FCC65300099DE9A /* PBXFileSystemSynchronizedBuildFileExceptionSet */, ); explicitFileTypes = {}; explicitFolders = (); path = GRDB; sourceTree = "<group>"; };
|
||||||
565F928630C2F80E009B685D /* GRDBTestSupportC */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = GRDBTestSupportC; sourceTree = "<group>"; };
|
56C887EB2FCC6B9A0099DE9A /* GRDBTests */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = GRDBTests; 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 */
|
/* End PBXFileSystemSynchronizedRootGroup section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase 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 */ = {
|
56E5D7F61B4D422D00430942 /* Frameworks */ = {
|
||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
@@ -127,14 +76,6 @@
|
|||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
E0FF00E7AD6E7127766C65D2 /* Frameworks */ = {
|
|
||||||
isa = PBXFrameworksBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
96FB7AD736D973E8E9A30380 /* GRDB.framework in Frameworks */,
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
/* End PBXFrameworksBuildPhase section */
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXGroup section */
|
/* Begin PBXGroup section */
|
||||||
@@ -157,12 +98,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
569530FA1C9067CC00CF1A2B /* Crash */,
|
569530FA1C9067CC00CF1A2B /* Crash */,
|
||||||
56C887EB2FCC6B9A0099DE9A /* GRDBSwift5Tests */,
|
56C887EB2FCC6B9A0099DE9A /* GRDBTests */,
|
||||||
56D0F1FC30C171E0004DBD2B /* GRDBSwift6ApproachableConcurrencyTests */,
|
|
||||||
56D0F20130C171E0004DBD2B /* GRDBSwift6MainActorIsolationTests */,
|
|
||||||
56D0F20630C171E0004DBD2B /* GRDBSwift6Tests */,
|
|
||||||
1D1937F0CDDDB96354EF407C /* GRDBTestSupport */,
|
|
||||||
565F928630C2F80E009B685D /* GRDBTestSupportC */,
|
|
||||||
DC37740319C8CBB3004FCF85 /* Supporting Files */,
|
DC37740319C8CBB3004FCF85 /* Supporting Files */,
|
||||||
);
|
);
|
||||||
path = Tests;
|
path = Tests;
|
||||||
@@ -171,7 +107,7 @@
|
|||||||
DC3773E919C8CBB3004FCF85 = {
|
DC3773E919C8CBB3004FCF85 = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
56C883812FCC65300099DE9A /* Sources/GRDB */,
|
56C883812FCC65300099DE9A /* GRDB */,
|
||||||
DC10500F19C904DD00D8CA30 /* Tests */,
|
DC10500F19C904DD00D8CA30 /* Tests */,
|
||||||
DC37743319C8CFCE004FCF85 /* Supporting Files */,
|
DC37743319C8CFCE004FCF85 /* Supporting Files */,
|
||||||
DC3773F419C8CBB3004FCF85 /* Products */,
|
DC3773F419C8CBB3004FCF85 /* Products */,
|
||||||
@@ -185,10 +121,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
DC3773F319C8CBB3004FCF85 /* GRDB.framework */,
|
DC3773F319C8CBB3004FCF85 /* GRDB.framework */,
|
||||||
56E5D7F91B4D422D00430942 /* GRDBSwift5Tests.xctest */,
|
56E5D7F91B4D422D00430942 /* GRDBTests.xctest */,
|
||||||
56D0F21130C17218004DBD2B /* GRDBSwift6ApproachableConcurrencyTests.xctest */,
|
|
||||||
970266BC29B4DCD6A1700E21 /* GRDBSwift6MainActorIsolationTests.xctest */,
|
|
||||||
6FC1DA2A6B5CD5D73C99E20E /* GRDBSwift6Tests.xctest */,
|
|
||||||
);
|
);
|
||||||
name = Products;
|
name = Products;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -210,11 +143,8 @@
|
|||||||
56C48E731C9A9923005DF1D9 /* module.modulemap */,
|
56C48E731C9A9923005DF1D9 /* module.modulemap */,
|
||||||
DC3773F719C8CBB3004FCF85 /* Info.plist */,
|
DC3773F719C8CBB3004FCF85 /* Info.plist */,
|
||||||
56B8F49A1B4E2F3600C24296 /* GRDB.xcconfig */,
|
56B8F49A1B4E2F3600C24296 /* GRDB.xcconfig */,
|
||||||
|
5698C1C32CA844F4001C0EB0 /* GRDBTests.xcconfig */,
|
||||||
56C494401ED7255500CC72AF /* GRDBDeploymentTarget.xcconfig */,
|
56C494401ED7255500CC72AF /* GRDBDeploymentTarget.xcconfig */,
|
||||||
5698C1C32CA844F4001C0EB0 /* GRDBSwift5Tests.xcconfig */,
|
|
||||||
56D0F21230C17218004DBD2B /* GRDBSwift6ApproachableConcurrencyTests.xcconfig */,
|
|
||||||
D585450E1D4D590FFEFBE90D /* GRDBSwift6MainActorIsolationTests.xcconfig */,
|
|
||||||
9961981D015C33AB03B08547 /* GRDBSwift6Tests.xcconfig */,
|
|
||||||
);
|
);
|
||||||
name = "Supporting Files";
|
name = "Supporting Files";
|
||||||
path = Support;
|
path = Support;
|
||||||
@@ -236,53 +166,9 @@
|
|||||||
/* End PBXHeadersBuildPhase section */
|
/* End PBXHeadersBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXNativeTarget section */
|
/* Begin PBXNativeTarget section */
|
||||||
137ECBDAB512C64A624D7C18 /* GRDBSwift6Tests */ = {
|
56E5D7F81B4D422D00430942 /* GRDBTests */ = {
|
||||||
isa = PBXNativeTarget;
|
isa = PBXNativeTarget;
|
||||||
buildConfigurationList = 18070F9F8DFD5096561CA62F /* Build configuration list for PBXNativeTarget "GRDBSwift6Tests" */;
|
buildConfigurationList = 56E5D8011B4D422E00430942 /* Build configuration list for PBXNativeTarget "GRDBTests" */;
|
||||||
buildPhases = (
|
|
||||||
677B998369A0C1FAA69120B7 /* Sources */,
|
|
||||||
E0FF00E7AD6E7127766C65D2 /* Frameworks */,
|
|
||||||
4F95D7921FDFB2BFED66B471 /* Resources */,
|
|
||||||
);
|
|
||||||
buildRules = (
|
|
||||||
);
|
|
||||||
dependencies = (
|
|
||||||
064B54476CF36B181327EDFC /* PBXTargetDependency */,
|
|
||||||
);
|
|
||||||
fileSystemSynchronizedGroups = (
|
|
||||||
1D1937F0CDDDB96354EF407C /* GRDBTestSupport */,
|
|
||||||
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 = (
|
|
||||||
1D1937F0CDDDB96354EF407C /* GRDBTestSupport */,
|
|
||||||
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 = (
|
buildPhases = (
|
||||||
56E5D7F51B4D422D00430942 /* Sources */,
|
56E5D7F51B4D422D00430942 /* Sources */,
|
||||||
56E5D7F61B4D422D00430942 /* Frameworks */,
|
56E5D7F61B4D422D00430942 /* Frameworks */,
|
||||||
@@ -294,34 +180,11 @@
|
|||||||
56E5D8001B4D422E00430942 /* PBXTargetDependency */,
|
56E5D8001B4D422E00430942 /* PBXTargetDependency */,
|
||||||
);
|
);
|
||||||
fileSystemSynchronizedGroups = (
|
fileSystemSynchronizedGroups = (
|
||||||
565F928630C2F80E009B685D /* GRDBTestSupportC */,
|
56C887EB2FCC6B9A0099DE9A /* GRDBTests */,
|
||||||
56C887EB2FCC6B9A0099DE9A /* GRDBSwift5Tests */,
|
|
||||||
);
|
);
|
||||||
name = GRDBSwift5Tests;
|
name = GRDBTests;
|
||||||
productName = GRDBOSXTests;
|
productName = GRDBOSXTests;
|
||||||
productReference = 56E5D7F91B4D422D00430942 /* GRDBSwift5Tests.xctest */;
|
productReference = 56E5D7F91B4D422D00430942 /* GRDBTests.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 = (
|
|
||||||
1D1937F0CDDDB96354EF407C /* GRDBTestSupport */,
|
|
||||||
56D0F20130C171E0004DBD2B /* GRDBSwift6MainActorIsolationTests */,
|
|
||||||
);
|
|
||||||
name = GRDBSwift6MainActorIsolationTests;
|
|
||||||
productName = GRDBOSXTests;
|
|
||||||
productReference = 970266BC29B4DCD6A1700E21 /* GRDBSwift6MainActorIsolationTests.xctest */;
|
|
||||||
productType = "com.apple.product-type.bundle.unit-test";
|
productType = "com.apple.product-type.bundle.unit-test";
|
||||||
};
|
};
|
||||||
DC3773F219C8CBB3004FCF85 /* GRDB */ = {
|
DC3773F219C8CBB3004FCF85 /* GRDB */ = {
|
||||||
@@ -339,7 +202,7 @@
|
|||||||
dependencies = (
|
dependencies = (
|
||||||
);
|
);
|
||||||
fileSystemSynchronizedGroups = (
|
fileSystemSynchronizedGroups = (
|
||||||
56C883812FCC65300099DE9A /* Sources/GRDB */,
|
56C883812FCC65300099DE9A /* GRDB */,
|
||||||
);
|
);
|
||||||
name = GRDB;
|
name = GRDB;
|
||||||
productName = GRDB;
|
productName = GRDB;
|
||||||
@@ -354,7 +217,7 @@
|
|||||||
attributes = {
|
attributes = {
|
||||||
BuildIndependentTargetsInParallel = YES;
|
BuildIndependentTargetsInParallel = YES;
|
||||||
LastSwiftUpdateCheck = 0730;
|
LastSwiftUpdateCheck = 0730;
|
||||||
LastUpgradeCheck = 2720;
|
LastUpgradeCheck = 2600;
|
||||||
ORGANIZATIONNAME = "Gwendal Roué";
|
ORGANIZATIONNAME = "Gwendal Roué";
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
56E5D7F81B4D422D00430942 = {
|
56E5D7F81B4D422D00430942 = {
|
||||||
@@ -381,29 +244,12 @@
|
|||||||
projectRoot = "";
|
projectRoot = "";
|
||||||
targets = (
|
targets = (
|
||||||
DC3773F219C8CBB3004FCF85 /* GRDB */,
|
DC3773F219C8CBB3004FCF85 /* GRDB */,
|
||||||
56E5D7F81B4D422D00430942 /* GRDBSwift5Tests */,
|
56E5D7F81B4D422D00430942 /* GRDBTests */,
|
||||||
56D0F20730C17218004DBD2B /* GRDBSwift6ApproachableConcurrencyTests */,
|
|
||||||
AF4E64BCF2E3A40030D9C72E /* GRDBSwift6MainActorIsolationTests */,
|
|
||||||
137ECBDAB512C64A624D7C18 /* GRDBSwift6Tests */,
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
/* End PBXProject section */
|
/* End PBXProject section */
|
||||||
|
|
||||||
/* Begin PBXResourcesBuildPhase section */
|
/* Begin PBXResourcesBuildPhase section */
|
||||||
4F95D7921FDFB2BFED66B471 /* Resources */ = {
|
|
||||||
isa = PBXResourcesBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
56D0F20D30C17218004DBD2B /* Resources */ = {
|
|
||||||
isa = PBXResourcesBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
56E5D7F71B4D422D00430942 /* Resources */ = {
|
56E5D7F71B4D422D00430942 /* Resources */ = {
|
||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
@@ -411,13 +257,6 @@
|
|||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
B5C3BD355A31911BA9D34C68 /* Resources */ = {
|
|
||||||
isa = PBXResourcesBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
DC3773F119C8CBB3004FCF85 /* Resources */ = {
|
DC3773F119C8CBB3004FCF85 /* Resources */ = {
|
||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
@@ -450,13 +289,6 @@
|
|||||||
/* End PBXShellScriptBuildPhase section */
|
/* End PBXShellScriptBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXSourcesBuildPhase section */
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
56D0F20A30C17218004DBD2B /* Sources */ = {
|
|
||||||
isa = PBXSourcesBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
56E5D7F51B4D422D00430942 /* Sources */ = {
|
56E5D7F51B4D422D00430942 /* Sources */ = {
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
@@ -464,20 +296,6 @@
|
|||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
677B998369A0C1FAA69120B7 /* Sources */ = {
|
|
||||||
isa = PBXSourcesBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
8A3253E0E6F543AF8E4071B6 /* Sources */ = {
|
|
||||||
isa = PBXSourcesBuildPhase;
|
|
||||||
buildActionMask = 2147483647;
|
|
||||||
files = (
|
|
||||||
);
|
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
|
||||||
};
|
|
||||||
DC3773EE19C8CBB3004FCF85 /* Sources */ = {
|
DC3773EE19C8CBB3004FCF85 /* Sources */ = {
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
@@ -488,114 +306,17 @@
|
|||||||
/* End PBXSourcesBuildPhase section */
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXTargetDependency 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 */ = {
|
56E5D8001B4D422E00430942 /* PBXTargetDependency */ = {
|
||||||
isa = PBXTargetDependency;
|
isa = PBXTargetDependency;
|
||||||
target = DC3773F219C8CBB3004FCF85 /* GRDB */;
|
target = DC3773F219C8CBB3004FCF85 /* GRDB */;
|
||||||
targetProxy = 56E5D7FF1B4D422E00430942 /* PBXContainerItemProxy */;
|
targetProxy = 56E5D7FF1B4D422E00430942 /* PBXContainerItemProxy */;
|
||||||
};
|
};
|
||||||
F0D310A8491E14866D6C126A /* PBXTargetDependency */ = {
|
|
||||||
isa = PBXTargetDependency;
|
|
||||||
target = DC3773F219C8CBB3004FCF85 /* GRDB */;
|
|
||||||
targetProxy = BDA5EFE64FE73E35F6D72D75 /* PBXContainerItemProxy */;
|
|
||||||
};
|
|
||||||
/* End PBXTargetDependency section */
|
/* End PBXTargetDependency section */
|
||||||
|
|
||||||
/* Begin XCBuildConfiguration section */
|
/* Begin XCBuildConfiguration section */
|
||||||
551FEC7C0085DBB820263A1D /* Release */ = {
|
|
||||||
isa = XCBuildConfiguration;
|
|
||||||
baseConfigurationReference = 9961981D015C33AB03B08547 /* GRDBSwift6Tests.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;
|
|
||||||
};
|
|
||||||
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 */ = {
|
56E5D8021B4D422E00430942 /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
baseConfigurationReference = 5698C1C32CA844F4001C0EB0 /* GRDBSwift5Tests.xcconfig */;
|
baseConfigurationReference = 5698C1C32CA844F4001C0EB0 /* GRDBTests.xcconfig */;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
@@ -609,19 +330,23 @@
|
|||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
"@loader_path/../Frameworks",
|
"@loader_path/../Frameworks",
|
||||||
);
|
);
|
||||||
|
OTHER_SWIFT_FLAGS = "$(inherited) -D SQLITE_MODULE";
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
|
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
|
||||||
SUPPORTS_MACCATALYST = YES;
|
SUPPORTS_MACCATALYST = YES;
|
||||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
|
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
|
||||||
|
SWIFT_OBJC_BRIDGING_HEADER = "Tests/GRDBTests/GRDBTests-Bridging-Header.h";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2,3,4";
|
TARGETED_DEVICE_FAMILY = "1,2,3,4";
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
56E5D8031B4D422E00430942 /* Release */ = {
|
56E5D8031B4D422E00430942 /* Release */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
baseConfigurationReference = 5698C1C32CA844F4001C0EB0 /* GRDBSwift5Tests.xcconfig */;
|
baseConfigurationReference = 5698C1C32CA844F4001C0EB0 /* GRDBTests.xcconfig */;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
@@ -636,97 +361,21 @@
|
|||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
"@loader_path/../Frameworks",
|
"@loader_path/../Frameworks",
|
||||||
);
|
);
|
||||||
|
OTHER_SWIFT_FLAGS = "$(inherited) -D SQLITE_MODULE";
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
|
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
|
||||||
SUPPORTS_MACCATALYST = YES;
|
SUPPORTS_MACCATALYST = YES;
|
||||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
|
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
|
||||||
SWIFT_COMPILATION_MODE = wholemodule;
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
|
SWIFT_OBJC_BRIDGING_HEADER = "Tests/GRDBTests/GRDBTests-Bridging-Header.h";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2,3,4";
|
TARGETED_DEVICE_FAMILY = "1,2,3,4";
|
||||||
};
|
};
|
||||||
name = Release;
|
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 */ = {
|
DC37740719C8CBB3004FCF85 /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
@@ -761,7 +410,6 @@
|
|||||||
DEAD_CODE_STRIPPING = YES;
|
DEAD_CODE_STRIPPING = YES;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
ENABLE_TESTABILITY = YES;
|
ENABLE_TESTABILITY = YES;
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
GCC_DYNAMIC_NO_PIC = NO;
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
GCC_NO_COMMON_BLOCKS = YES;
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
@@ -820,7 +468,6 @@
|
|||||||
DEAD_CODE_STRIPPING = YES;
|
DEAD_CODE_STRIPPING = YES;
|
||||||
ENABLE_NS_ASSERTIONS = NO;
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
GCC_NO_COMMON_BLOCKS = YES;
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
@@ -855,7 +502,6 @@
|
|||||||
DYLIB_CURRENT_VERSION = 1;
|
DYLIB_CURRENT_VERSION = 1;
|
||||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||||
ENABLE_MODULE_VERIFIER = YES;
|
ENABLE_MODULE_VERIFIER = YES;
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
|
||||||
INFOPLIST_FILE = Support/Info.plist;
|
INFOPLIST_FILE = Support/Info.plist;
|
||||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
@@ -889,7 +535,6 @@
|
|||||||
DYLIB_CURRENT_VERSION = 1;
|
DYLIB_CURRENT_VERSION = 1;
|
||||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||||
ENABLE_MODULE_VERIFIER = YES;
|
ENABLE_MODULE_VERIFIER = YES;
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
|
||||||
INFOPLIST_FILE = Support/Info.plist;
|
INFOPLIST_FILE = Support/Info.plist;
|
||||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
@@ -911,34 +556,7 @@
|
|||||||
/* End XCBuildConfiguration section */
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
/* Begin XCConfigurationList section */
|
/* Begin XCConfigurationList section */
|
||||||
18070F9F8DFD5096561CA62F /* Build configuration list for PBXNativeTarget "GRDBSwift6Tests" */ = {
|
56E5D8011B4D422E00430942 /* Build configuration list for PBXNativeTarget "GRDBTests" */ = {
|
||||||
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;
|
isa = XCConfigurationList;
|
||||||
buildConfigurations = (
|
buildConfigurations = (
|
||||||
56E5D8021B4D422E00430942 /* Debug */,
|
56E5D8021B4D422E00430942 /* Debug */,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "2720"
|
LastUpgradeVersion = "2600"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
@@ -29,8 +29,8 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "56E5D7F81B4D422D00430942"
|
BlueprintIdentifier = "56E5D7F81B4D422D00430942"
|
||||||
BuildableName = "GRDBSwift5Tests.xctest"
|
BuildableName = "GRDBTests.xctest"
|
||||||
BlueprintName = "GRDBSwift5Tests"
|
BlueprintName = "GRDBTests"
|
||||||
ReferencedContainer = "container:GRDB.xcodeproj">
|
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</BuildActionEntry>
|
</BuildActionEntry>
|
||||||
@@ -49,38 +49,8 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "56E5D7F81B4D422D00430942"
|
BlueprintIdentifier = "56E5D7F81B4D422D00430942"
|
||||||
BuildableName = "GRDBSwift5Tests.xctest"
|
BuildableName = "GRDBTests.xctest"
|
||||||
BlueprintName = "GRDBSwift5Tests"
|
BlueprintName = "GRDBTests"
|
||||||
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">
|
ReferencedContainer = "container:GRDB.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</TestableReference>
|
</TestableReference>
|
||||||
|
|||||||
+20
-1
@@ -1,6 +1,22 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
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
|
<FileRef
|
||||||
location = "group:BRAG.md">
|
location = "group:BRAG.md">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
@@ -14,7 +30,7 @@
|
|||||||
location = "group:TODO.md">
|
location = "group:TODO.md">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:RELEASING.md">
|
location = "group:Documentation/ReleaseProcess.md">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Makefile">
|
location = "group:Makefile">
|
||||||
@@ -25,6 +41,9 @@
|
|||||||
<FileRef
|
<FileRef
|
||||||
location = "group:GRDBCustom.xcodeproj">
|
location = "group:GRDBCustom.xcodeproj">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
|
<FileRef
|
||||||
|
location = "group:Tests/Performance/GRDBProfiling/GRDBProfiling.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Documentation/DemoApps/GRDBDemo/GRDBDemo.xcodeproj">
|
location = "group:Documentation/DemoApps/GRDBDemo/GRDBDemo.xcodeproj">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !canImport(Darwin)
|
#if !canImport(Darwin)
|
||||||
@@ -94,8 +92,8 @@ public struct Configuration: Sendable {
|
|||||||
/// The default configuration label is nil.
|
/// The default configuration label is nil.
|
||||||
public var label: String?
|
public var label: String?
|
||||||
|
|
||||||
/// A boolean value indicating whether SQLite interprets double-quoted
|
/// A boolean value indicating whether SQLite 3.29+ interprets
|
||||||
/// strings as string literals when they do not match any
|
/// double-quoted strings as string literals when they do not match any
|
||||||
/// valid identifier.
|
/// valid identifier.
|
||||||
///
|
///
|
||||||
/// The default and recommended value is false:
|
/// The default and recommended value is false:
|
||||||
@@ -107,9 +105,9 @@ public struct Configuration: Sendable {
|
|||||||
/// """)
|
/// """)
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// When true, double-quoted strings that do not match any valid
|
/// When true, or before SQLite version 3.29.0, double-quoted strings that
|
||||||
/// identifier are interpreted as string literals, as in the
|
/// do not match any valid identifier are interpreted as string literals,
|
||||||
/// example below. This is an SQLite
|
/// as in the example below. This is an SQLite
|
||||||
/// [misfeature](https://sqlite.org/quirks.html#double_quoted_string_literals_are_accepted):
|
/// [misfeature](https://sqlite.org/quirks.html#double_quoted_string_literals_are_accepted):
|
||||||
///
|
///
|
||||||
/// ```swift
|
/// ```swift
|
||||||
File renamed without changes.
@@ -1,5 +1,7 @@
|
|||||||
#if SQLITE_HAS_CODEC
|
#if SQLITE_HAS_CODEC
|
||||||
#if SQLCipher
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif SQLCipher
|
||||||
import SQLCipher
|
import SQLCipher
|
||||||
#else
|
#else
|
||||||
#error("No SQLCipher library configured")
|
#error("No SQLCipher library configured")
|
||||||
@@ -123,8 +125,6 @@ extension Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Changes the passphrase used by an SQLCipher encrypted database.
|
/// Changes the passphrase used by an SQLCipher encrypted database.
|
||||||
///
|
|
||||||
/// This method must be called outside of a transaction.
|
|
||||||
public func changePassphrase(_ passphrase: String) throws {
|
public func changePassphrase(_ passphrase: String) throws {
|
||||||
guard var data = passphrase.data(using: .utf8) else {
|
guard var data = passphrase.data(using: .utf8) else {
|
||||||
throw DatabaseError(message: "invalid passphrase")
|
throw DatabaseError(message: "invalid passphrase")
|
||||||
@@ -136,8 +136,6 @@ extension Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Changes the passphrase used by an SQLCipher encrypted database.
|
/// Changes the passphrase used by an SQLCipher encrypted database.
|
||||||
///
|
|
||||||
/// This method must be called outside of a transaction.
|
|
||||||
public func changePassphrase(_ passphrase: Data) throws {
|
public func changePassphrase(_ passphrase: Data) throws {
|
||||||
// FIXME: sqlite3_rekey is discouraged.
|
// FIXME: sqlite3_rekey is discouraged.
|
||||||
//
|
//
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extension Database {
|
extension Database {
|
||||||
@@ -70,35 +68,27 @@ extension Database {
|
|||||||
///
|
///
|
||||||
/// Related SQLite documentation: <https://www.sqlite.org/pragma.html#pragma_schema_version>
|
/// Related SQLite documentation: <https://www.sqlite.org/pragma.html#pragma_schema_version>
|
||||||
public func schemaVersion() throws -> Int32 {
|
public func schemaVersion() throws -> Int32 {
|
||||||
try Int32.fetchOne(cachedStatement(sql: "PRAGMA schema_version"))!
|
try Int32.fetchOne(internalCachedStatement(sql: "PRAGMA schema_version"))!
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clears the database schema cache.
|
/// Clears the database schema cache.
|
||||||
///
|
///
|
||||||
/// GRDB caches information about the database schema, such as the
|
/// If the database schema is modified by another SQLite connection to the
|
||||||
/// columns of tables. When another SQLite connection to the same
|
/// same database file, your application may need to call this method in
|
||||||
/// database file modifies the schema, this information becomes
|
/// order to avoid undesired consequences.
|
||||||
/// 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() {
|
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)
|
SchedulingWatchdog.preconditionValidQueue(self)
|
||||||
schemaCache.clear()
|
schemaCache.clear()
|
||||||
|
|
||||||
// We also clear the statement cache. SQLite automatically
|
// We also clear statement cache despite the automatic statement
|
||||||
// recompiles statements after a schema change (see
|
// recompilation (see https://www.sqlite.org/c3ref/prepare.html)
|
||||||
// https://www.sqlite.org/c3ref/prepare.html), but the recompilation
|
// because the automatic statement recompilation only happens a
|
||||||
// does not update the statement information gathered by
|
// limited number of times (`SQLITE_MAX_SCHEMA_RETRY`).
|
||||||
// `StatementAuthorizer` at compilation time.
|
internalStatementCache.clear()
|
||||||
statementCache.clear()
|
publicStatementCache.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clears the database schema cache if the database schema has changed
|
/// Clears the database schema cache if the database schema has changed
|
||||||
@@ -110,24 +100,8 @@ extension Database {
|
|||||||
// <https://sqlite.org/fileformat2.html#database_header>
|
// <https://sqlite.org/fileformat2.html#database_header>
|
||||||
let schemaVersion = try self.schemaVersion()
|
let schemaVersion = try self.schemaVersion()
|
||||||
if lastSchemaVersion != schemaVersion {
|
if 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
|
lastSchemaVersion = schemaVersion
|
||||||
|
clearSchemaCache()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +160,7 @@ extension Database {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/// Returns information about a table or a view
|
/// Returns information about a table or a view
|
||||||
@available(iOS 15.4, macOS 12.4, tvOS 15.4, *) // SQLite 3.37+
|
@available(iOS 15.4, macOS 12.4, tvOS 15.4, watchOS 8.5, *) // SQLite 3.37+
|
||||||
func table(_ tableName: String) throws -> TableInfo? {
|
func table(_ tableName: String) throws -> TableInfo? {
|
||||||
for schemaID in try fetchSchemaIdentifiers() {
|
for schemaID in try fetchSchemaIdentifiers() {
|
||||||
if let result = try table(for: DatabaseObjectID(name: tableName, schemaID: schemaID)) {
|
if let result = try table(for: DatabaseObjectID(name: tableName, schemaID: schemaID)) {
|
||||||
@@ -197,7 +171,7 @@ extension Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns information about a table or a view
|
/// Returns information about a table or a view
|
||||||
@available(iOS 15.4, macOS 12.4, tvOS 15.4, *) // SQLite 3.37+
|
@available(iOS 15.4, macOS 12.4, tvOS 15.4, watchOS 8.5, *) // SQLite 3.37+
|
||||||
func table(for table: DatabaseObjectID) throws -> TableInfo? {
|
func table(for table: DatabaseObjectID) throws -> TableInfo? {
|
||||||
try _table(for: table)
|
try _table(for: table)
|
||||||
}
|
}
|
||||||
@@ -608,7 +582,7 @@ extension Database {
|
|||||||
return try self.table(for: table)!.isWithoutRowIDTable == false
|
return try self.table(for: table)!.isWithoutRowIDTable == false
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if #available(iOS 15.4, macOS 12.4, tvOS 15.4, *) { // SQLite 3.37+
|
if #available(iOS 15.4, macOS 12.4, tvOS 15.4, watchOS 8.5, *) { // SQLite 3.37+
|
||||||
return try self.table(for: table)!.isWithoutRowIDTable == false
|
return try self.table(for: table)!.isWithoutRowIDTable == false
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1054,12 +1028,58 @@ extension Database {
|
|||||||
/// Fetches the columns in the database table identified by `table`, or
|
/// Fetches the columns in the database table identified by `table`, or
|
||||||
/// returns nil if the database schema does not contain that table.
|
/// returns nil if the database schema does not contain that table.
|
||||||
///
|
///
|
||||||
/// This method relies entirely on SQLite schema introspection. It
|
/// This method relies entirely on SQLite schema introspection. Starting with
|
||||||
/// returns all columns, including
|
/// SQLite 3.26.0, it returns all columns, including
|
||||||
/// [generated columns](https://www.sqlite.org/gencol.html) and
|
/// [generated columns](https://www.sqlite.org/gencol.html) and
|
||||||
/// [hidden columns](https://www.sqlite.org/vtab.html#hiddencol).
|
/// [hidden columns](https://www.sqlite.org/vtab.html#hiddencol).
|
||||||
func fetchPrimitiveColumns(in table: DatabaseObjectID) throws -> [ColumnInfo]? {
|
func fetchPrimitiveColumns(in table: DatabaseObjectID) throws -> [ColumnInfo]? {
|
||||||
let columnInfoQuery = "PRAGMA \(table.schemaID.name).table_xinfo(\(table.name.quotedDatabaseIdentifier))"
|
// 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 columns = try ColumnInfo
|
let columns = try ColumnInfo
|
||||||
.fetchAll(self, sql: columnInfoQuery)
|
.fetchAll(self, sql: columnInfoQuery)
|
||||||
.sorted(by: { $0.cid < $1.cid })
|
.sorted(by: { $0.cid < $1.cid })
|
||||||
@@ -1275,10 +1295,11 @@ public struct DatabaseObjectID: Hashable, Sendable {
|
|||||||
///
|
///
|
||||||
/// Related SQLite documentation:
|
/// 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)
|
/// - [pragma `table_xinfo`](https://www.sqlite.org/pragma.html#pragma_table_xinfo)
|
||||||
public struct ColumnInfo: FetchableRecord, Sendable {
|
public struct ColumnInfo: FetchableRecord, Sendable {
|
||||||
let cid: Int
|
let cid: Int
|
||||||
let hidden: Int
|
let hidden: Int?
|
||||||
|
|
||||||
/// The column name.
|
/// The column name.
|
||||||
public let name: String
|
public let name: String
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
@@ -94,8 +92,8 @@ extension Database {
|
|||||||
/// let moreThanThirtyCount = try Int.fetchOne(statement, arguments: [30])!
|
/// let moreThanThirtyCount = try Int.fetchOne(statement, arguments: [30])!
|
||||||
///
|
///
|
||||||
/// - parameter sql: An SQL string.
|
/// - parameter sql: An SQL string.
|
||||||
/// - parameter prepFlags: Flags for `sqlite3_prepare_v3` see
|
/// - parameter prepFlags: Flags for sqlite3_prepare_v3 (available from
|
||||||
/// <http://www.sqlite.org/c3ref/prepare.html>.
|
/// SQLite 3.20.0, see <http://www.sqlite.org/c3ref/prepare.html>)
|
||||||
/// - returns: A prepared statement.
|
/// - returns: A prepared statement.
|
||||||
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs.
|
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs.
|
||||||
func makeStatement(sql: String, prepFlags: CUnsignedInt) throws -> Statement {
|
func makeStatement(sql: String, prepFlags: CUnsignedInt) throws -> Statement {
|
||||||
@@ -144,19 +142,14 @@ extension Database {
|
|||||||
/// try statement.execute(arguments: ["Barbara"])
|
/// try statement.execute(arguments: ["Barbara"])
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// The returned statement has no argument values.
|
/// The returned statement may have already been used: it may or may not
|
||||||
///
|
/// contain values for its arguments, if any.
|
||||||
/// 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.
|
/// - parameter sql: An SQL string.
|
||||||
/// - returns: A prepared statement.
|
/// - returns: A prepared statement.
|
||||||
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs.
|
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs.
|
||||||
public func cachedStatement(sql: String) throws -> Statement {
|
public func cachedStatement(sql: String) throws -> Statement {
|
||||||
try statementCache.statement(sql)
|
try publicStatementCache.statement(sql)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a prepared statement that can be reused.
|
/// Returns a prepared statement that can be reused.
|
||||||
@@ -192,15 +185,6 @@ 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.
|
/// - parameter sqlLiteral: An ``SQL`` literal.
|
||||||
/// - returns: A prepared statement.
|
/// - returns: A prepared statement.
|
||||||
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs.
|
/// - throws: A ``DatabaseError`` whenever an SQLite error occurs.
|
||||||
@@ -214,6 +198,11 @@ extension Database {
|
|||||||
return statement
|
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.
|
/// Returns a cursor of prepared statements.
|
||||||
///
|
///
|
||||||
/// For example:
|
/// For example:
|
||||||
@@ -488,7 +477,8 @@ extension Database {
|
|||||||
// https://www.sqlite.org/c3ref/reset.html
|
// https://www.sqlite.org/c3ref/reset.html
|
||||||
//
|
//
|
||||||
// So make sure we clear this statement from the cache.
|
// So make sure we clear this statement from the cache.
|
||||||
statementCache.remove(statement)
|
internalStatementCache.remove(statement)
|
||||||
|
publicStatementCache.remove(statement)
|
||||||
|
|
||||||
checkForAutocommitTransition()
|
checkForAutocommitTransition()
|
||||||
|
|
||||||
@@ -564,17 +554,8 @@ extension Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A thread-unsafe statement cache.
|
/// A thread-unsafe statement cache
|
||||||
///
|
struct StatementCache {
|
||||||
/// 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
|
unowned let db: Database
|
||||||
private var statements: [String: Statement] = [:]
|
private var statements: [String: Statement] = [:]
|
||||||
|
|
||||||
@@ -582,20 +563,9 @@ final class StatementCache {
|
|||||||
self.db = database
|
self.db = database
|
||||||
}
|
}
|
||||||
|
|
||||||
/// - precondition: this method is called on a valid dispatch queue.
|
mutating func statement(_ sql: String) throws -> Statement {
|
||||||
func statement(_ sql: String) throws -> Statement {
|
if let statement = statements[sql] {
|
||||||
if let index = statements.index(forKey: sql) {
|
return statement
|
||||||
// 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
|
// http://www.sqlite.org/c3ref/c_prepare_persistent.html#sqlitepreparepersistent
|
||||||
@@ -609,15 +579,15 @@ final class StatementCache {
|
|||||||
return statement
|
return statement
|
||||||
}
|
}
|
||||||
|
|
||||||
func clear() {
|
mutating func clear() {
|
||||||
statements = [:]
|
statements = [:]
|
||||||
}
|
}
|
||||||
|
|
||||||
func remove(_ statement: Statement) {
|
mutating func remove(_ statement: Statement) {
|
||||||
statements.removeFirst { $0.value === statement }
|
statements.removeFirst { $0.value === statement }
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeAll(where shouldBeRemoved: (Statement) -> Bool) {
|
mutating func removeAll(where shouldBeRemoved: (Statement) -> Bool) {
|
||||||
statements = statements.filter { (_, statement) in !shouldBeRemoved(statement) }
|
statements = statements.filter { (_, statement) in !shouldBeRemoved(statement) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,14 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
import GRDBSQLCipher
|
||||||
import GRDBSQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
@@ -300,8 +298,13 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
|
|||||||
/// The cache for the available database schemas (main, temp, attached databases).
|
/// The cache for the available database schemas (main, temp, attached databases).
|
||||||
var schemaCache = SchemaCache()
|
var schemaCache = SchemaCache()
|
||||||
|
|
||||||
/// The cache for statements, used by both GRDB and the user.
|
/// The cache for statements managed by GRDB. It is distinct from
|
||||||
lazy var statementCache = StatementCache(database: self)
|
/// `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 database authorizer provides information about compiled
|
/// The database authorizer provides information about compiled
|
||||||
/// database statements, and prevents the truncate optimization when
|
/// database statements, and prevents the truncate optimization when
|
||||||
@@ -331,7 +334,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
|
|||||||
/// // Prints, for example, "3048000"
|
/// // Prints, for example, "3048000"
|
||||||
/// print(Database.sqliteLibVersionNumber)
|
/// print(Database.sqliteLibVersionNumber)
|
||||||
/// ```
|
/// ```
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public static var sqliteLibVersionNumber: CInt {
|
public static var sqliteLibVersionNumber: CInt {
|
||||||
sqlite3_libversion_number()
|
sqlite3_libversion_number()
|
||||||
@@ -667,7 +670,8 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
|
|||||||
|
|
||||||
// Finalize all cached statements since they would prevent
|
// Finalize all cached statements since they would prevent
|
||||||
// immediate connection closing.
|
// immediate connection closing.
|
||||||
statementCache.clear()
|
internalStatementCache.clear()
|
||||||
|
publicStatementCache.clear()
|
||||||
|
|
||||||
// https://www.sqlite.org/c3ref/close.html
|
// https://www.sqlite.org/c3ref/close.html
|
||||||
// > If the database connection is associated with unfinalized prepared
|
// > If the database connection is associated with unfinalized prepared
|
||||||
@@ -710,7 +714,8 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
|
|||||||
|
|
||||||
// Finalize all cached statements since they would prevent
|
// Finalize all cached statements since they would prevent
|
||||||
// immediate connection closing.
|
// immediate connection closing.
|
||||||
statementCache.clear()
|
internalStatementCache.clear()
|
||||||
|
publicStatementCache.clear()
|
||||||
|
|
||||||
// https://www.sqlite.org/c3ref/close.html
|
// https://www.sqlite.org/c3ref/close.html
|
||||||
// > If sqlite3_close_v2() is called with unfinalized prepared
|
// > If sqlite3_close_v2() is called with unfinalized prepared
|
||||||
@@ -843,7 +848,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
|
|||||||
// concurrent and we can pretend it occurred before or after
|
// concurrent and we can pretend it occurred before or after
|
||||||
// the PRAGMA.
|
// the PRAGMA.
|
||||||
try ignoringInterruption {
|
try ignoringInterruption {
|
||||||
try cachedStatement(sql: "PRAGMA query_only = 1").execute()
|
try internalCachedStatement(sql: "PRAGMA query_only = 1").execute()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
readOnlyDepth += 1
|
readOnlyDepth += 1
|
||||||
@@ -863,7 +868,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
|
|||||||
// concurrent and we can pretend it occurred before or after
|
// concurrent and we can pretend it occurred before or after
|
||||||
// the PRAGMA.
|
// the PRAGMA.
|
||||||
try ignoringInterruption {
|
try ignoringInterruption {
|
||||||
try cachedStatement(sql: "PRAGMA query_only = 0").execute()
|
try internalCachedStatement(sql: "PRAGMA query_only = 0").execute()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1519,7 +1524,6 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
|
|||||||
/// error thrown by `operations`.
|
/// error thrown by `operations`.
|
||||||
public func inTransaction(_ kind: TransactionKind? = nil, _ operations: () throws -> TransactionCompletion) throws {
|
public func inTransaction(_ kind: TransactionKind? = nil, _ operations: () throws -> TransactionCompletion) throws {
|
||||||
// Begin transaction
|
// Begin transaction
|
||||||
let kind = kind ?? defaultTransactionKind
|
|
||||||
try beginTransaction(kind)
|
try beginTransaction(kind)
|
||||||
|
|
||||||
// Support for `checkForAbortedTransaction()`.
|
// Support for `checkForAbortedTransaction()`.
|
||||||
@@ -1535,17 +1539,6 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
|
|||||||
var firstError: Error?
|
var firstError: Error?
|
||||||
let needsRollback: Bool
|
let needsRollback: Bool
|
||||||
do {
|
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()
|
let completion = try operations()
|
||||||
switch completion {
|
switch completion {
|
||||||
case .commit:
|
case .commit:
|
||||||
@@ -1751,17 +1744,11 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
|
|||||||
// cannot be avoided with a busy timeout.
|
// cannot be avoided with a busy timeout.
|
||||||
//
|
//
|
||||||
// See <https://github.com/groue/GRDB.swift/issues/1483>.
|
// See <https://github.com/groue/GRDB.swift/issues/1483>.
|
||||||
let kind = kind ?? defaultTransactionKind
|
let kind = kind ?? (isReadOnly ? .deferred : .immediate)
|
||||||
try execute(sql: "BEGIN \(kind.rawValue) TRANSACTION")
|
try execute(sql: "BEGIN \(kind.rawValue) TRANSACTION")
|
||||||
assert(sqlite3_get_autocommit(sqliteConnection) == 0)
|
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.
|
/// Rolls back a database transaction.
|
||||||
///
|
///
|
||||||
/// Related SQLite documentation: <https://www.sqlite.org/lang_transaction.html>
|
/// Related SQLite documentation: <https://www.sqlite.org/lang_transaction.html>
|
||||||
@@ -1854,7 +1841,8 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
|
|||||||
sqlite3_db_release_memory(sqliteConnection)
|
sqlite3_db_release_memory(sqliteConnection)
|
||||||
}
|
}
|
||||||
schemaCache.clear()
|
schemaCache.clear()
|
||||||
statementCache.clear()
|
internalStatementCache.clear()
|
||||||
|
publicStatementCache.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Erasing
|
// MARK: - Erasing
|
||||||
File renamed without changes.
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
@@ -503,7 +501,7 @@ public final class DatabaseFunction: Identifiable, Sendable {
|
|||||||
/// try Int.fetchOne(db, sql: "SELECT mysum(i) FROM test")! // 3
|
/// try Int.fetchOne(db, sql: "SELECT mysum(i) FROM test")! // 3
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
public protocol DatabaseAggregate: SendableMetatype {
|
public protocol DatabaseAggregate: GRDBSendableMetatype {
|
||||||
/// Creates an aggregate.
|
/// Creates an aggregate.
|
||||||
///
|
///
|
||||||
/// A new instance is created for each aggregation.
|
/// A new instance is created for each aggregation.
|
||||||
@@ -335,6 +335,7 @@ extension DatabasePool: DatabaseReader {
|
|||||||
|
|
||||||
// MARK: - Reading from Database
|
// MARK: - Reading from Database
|
||||||
|
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func read<T>(_ value: (Database) throws -> T) throws -> T {
|
public func read<T>(_ value: (Database) throws -> T) throws -> T {
|
||||||
GRDBPrecondition(currentReader == nil, "Database methods are not reentrant.")
|
GRDBPrecondition(currentReader == nil, "Database methods are not reentrant.")
|
||||||
guard let readerPool else {
|
guard let readerPool else {
|
||||||
@@ -342,52 +343,49 @@ extension DatabasePool: DatabaseReader {
|
|||||||
}
|
}
|
||||||
return try readerPool.get { reader in
|
return try readerPool.get { reader in
|
||||||
try reader.sync { db in
|
try reader.sync { db in
|
||||||
// clearSchemaCacheIfNeeded() is called by the transaction
|
|
||||||
// started by `isolated`.
|
|
||||||
try db.isolated {
|
try db.isolated {
|
||||||
try value(db)
|
try db.clearSchemaCacheIfNeeded()
|
||||||
|
return try value(db)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func read<T>(
|
public func read<T: Sendable>(
|
||||||
_ value: sending (Database) throws -> sending T
|
_ value: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
guard let readerPool else {
|
guard let readerPool else {
|
||||||
throw DatabaseError.connectionIsClosed()
|
throw DatabaseError.connectionIsClosed()
|
||||||
}
|
}
|
||||||
|
|
||||||
let (reader, releaseReader) = try await readerPool.get()
|
return try await readerPool.get { reader in
|
||||||
defer { releaseReader(.reuse) }
|
try await reader.execute { db in
|
||||||
return try await reader.execute { db in
|
defer {
|
||||||
defer {
|
// Commit or rollback, but make sure we leave the read-only transaction
|
||||||
// Commit or rollback, but make sure we leave the read-only transaction
|
// (commit may fail with a CancellationError).
|
||||||
// (commit may fail with a CancellationError).
|
do {
|
||||||
do {
|
try db.commit()
|
||||||
try db.commit()
|
} catch {
|
||||||
} catch {
|
try? db.rollback()
|
||||||
try? db.rollback()
|
}
|
||||||
}
|
assert(!db.isInsideTransaction)
|
||||||
assert(!db.isInsideTransaction)
|
}
|
||||||
}
|
// The block isolation comes from the DEFERRED transaction.
|
||||||
// The block isolation comes from the DEFERRED transaction.
|
try db.beginTransaction(.deferred)
|
||||||
try db.beginTransaction(.deferred)
|
try db.clearSchemaCacheIfNeeded()
|
||||||
try db.clearSchemaCacheIfNeeded()
|
return try value(db)
|
||||||
return try value(db)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func asyncRead(
|
public func asyncRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
guard let readerPool else {
|
guard let readerPool else {
|
||||||
value(.failure(DatabaseError.connectionIsClosed()))
|
value(.failure(DatabaseError.connectionIsClosed()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safe because `value` is sending, and called only once.
|
|
||||||
nonisolated(unsafe) let value = value
|
|
||||||
readerPool.asyncGet { result in
|
readerPool.asyncGet { result in
|
||||||
do {
|
do {
|
||||||
let (reader, releaseReader) = try result.get()
|
let (reader, releaseReader) = try result.get()
|
||||||
@@ -419,6 +417,7 @@ extension DatabasePool: DatabaseReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T {
|
public func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T {
|
||||||
GRDBPrecondition(currentReader == nil, "Database methods are not reentrant.")
|
GRDBPrecondition(currentReader == nil, "Database methods are not reentrant.")
|
||||||
guard let readerPool else {
|
guard let readerPool else {
|
||||||
@@ -432,31 +431,29 @@ extension DatabasePool: DatabaseReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func unsafeRead<T>(
|
public func unsafeRead<T: Sendable>(
|
||||||
_ value: sending (Database) throws -> sending T
|
_ value: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
guard let readerPool else {
|
guard let readerPool else {
|
||||||
throw DatabaseError.connectionIsClosed()
|
throw DatabaseError.connectionIsClosed()
|
||||||
}
|
}
|
||||||
|
|
||||||
let (reader, releaseReader) = try await readerPool.get()
|
return try await readerPool.get { reader in
|
||||||
defer { releaseReader(.reuse) }
|
try await reader.execute { db in
|
||||||
return try await reader.execute { db in
|
try db.clearSchemaCacheIfNeeded()
|
||||||
try db.clearSchemaCacheIfNeeded()
|
return try value(db)
|
||||||
return try value(db)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func asyncUnsafeRead(
|
public func asyncUnsafeRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
guard let readerPool else {
|
guard let readerPool else {
|
||||||
value(.failure(DatabaseError.connectionIsClosed()))
|
value(.failure(DatabaseError.connectionIsClosed()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safe because `value` is sending, and called only once.
|
|
||||||
nonisolated(unsafe) let value = value
|
|
||||||
readerPool.asyncGet { result in
|
readerPool.asyncGet { result in
|
||||||
do {
|
do {
|
||||||
let (reader, releaseReader) = try result.get()
|
let (reader, releaseReader) = try result.get()
|
||||||
@@ -497,7 +494,7 @@ extension DatabasePool: DatabaseReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func spawnConcurrentRead(
|
public func spawnConcurrentRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
asyncConcurrentRead(value)
|
asyncConcurrentRead(value)
|
||||||
}
|
}
|
||||||
@@ -540,7 +537,7 @@ extension DatabasePool: DatabaseReader {
|
|||||||
///
|
///
|
||||||
/// - parameter value: A function that accesses the database.
|
/// - parameter value: A function that accesses the database.
|
||||||
public func asyncConcurrentRead(
|
public func asyncConcurrentRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
// Check that we're on the writer queue...
|
// Check that we're on the writer queue...
|
||||||
writer.execute { db in
|
writer.execute { db in
|
||||||
@@ -712,7 +709,7 @@ extension DatabasePool: DatabaseReader {
|
|||||||
/// - important: The `completion` argument is executed in a serial
|
/// - important: The `completion` argument is executed in a serial
|
||||||
/// dispatch queue, so make sure you use the transaction asynchronously.
|
/// dispatch queue, so make sure you use the transaction asynchronously.
|
||||||
func asyncWALSnapshotTransaction(
|
func asyncWALSnapshotTransaction(
|
||||||
_ completion: sending @escaping (Result<WALSnapshotTransaction, Error>) -> Void
|
_ completion: @escaping @Sendable (Result<WALSnapshotTransaction, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
guard let readerPool else {
|
guard let readerPool else {
|
||||||
completion(.failure(DatabaseError.connectionIsClosed()))
|
completion(.failure(DatabaseError.connectionIsClosed()))
|
||||||
@@ -738,28 +735,28 @@ extension DatabasePool: DatabaseReader {
|
|||||||
|
|
||||||
public func _add<Reducer: ValueReducer>(
|
public func _add<Reducer: ValueReducer>(
|
||||||
observation: ValueObservation<Reducer>,
|
observation: ValueObservation<Reducer>,
|
||||||
scheduler: some ValueObservationScheduler,
|
scheduling scheduler: some ValueObservationScheduler,
|
||||||
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
||||||
) -> AnyDatabaseCancellable {
|
) -> AnyDatabaseCancellable {
|
||||||
if configuration.readonly {
|
if configuration.readonly {
|
||||||
// The easy case: the database does not change
|
// The easy case: the database does not change
|
||||||
return _addReadOnly(
|
return _addReadOnly(
|
||||||
observation: observation,
|
observation: observation,
|
||||||
scheduler: scheduler,
|
scheduling: scheduler,
|
||||||
onChange: onChange)
|
onChange: onChange)
|
||||||
|
|
||||||
} else if observation.requiresWriteAccess {
|
} else if observation.requiresWriteAccess {
|
||||||
// Observe from the writer database connection.
|
// Observe from the writer database connection.
|
||||||
return _addWriteOnly(
|
return _addWriteOnly(
|
||||||
observation: observation,
|
observation: observation,
|
||||||
scheduler: scheduler,
|
scheduling: scheduler,
|
||||||
onChange: onChange)
|
onChange: onChange)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// DatabasePool can perform concurrent observation
|
// DatabasePool can perform concurrent observation
|
||||||
return _addConcurrent(
|
return _addConcurrent(
|
||||||
observation: observation,
|
observation: observation,
|
||||||
scheduler: scheduler,
|
scheduling: scheduler,
|
||||||
onChange: onChange)
|
onChange: onChange)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -768,7 +765,7 @@ extension DatabasePool: DatabaseReader {
|
|||||||
/// the writer.
|
/// the writer.
|
||||||
private func _addConcurrent<Reducer: ValueReducer>(
|
private func _addConcurrent<Reducer: ValueReducer>(
|
||||||
observation: ValueObservation<Reducer>,
|
observation: ValueObservation<Reducer>,
|
||||||
scheduler: some ValueObservationScheduler,
|
scheduling scheduler: some ValueObservationScheduler,
|
||||||
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
||||||
) -> AnyDatabaseCancellable {
|
) -> AnyDatabaseCancellable {
|
||||||
assert(!configuration.readonly, "Use _addReadOnly(observation:) instead")
|
assert(!configuration.readonly, "Use _addReadOnly(observation:) instead")
|
||||||
@@ -787,16 +784,18 @@ extension DatabasePool: DatabaseReader {
|
|||||||
extension DatabasePool: DatabaseWriter {
|
extension DatabasePool: DatabaseWriter {
|
||||||
// MARK: - Writing in Database
|
// MARK: - Writing in Database
|
||||||
|
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T {
|
public func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T {
|
||||||
try writer.sync(updates)
|
try writer.sync(updates)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func writeWithoutTransaction<T>(
|
public func writeWithoutTransaction<T: Sendable>(
|
||||||
_ updates: sending (Database) throws -> sending T
|
_ updates: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
try await writer.execute(updates)
|
try await writer.execute(updates)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) throws -> T {
|
public func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) throws -> T {
|
||||||
guard let readerPool else {
|
guard let readerPool else {
|
||||||
throw DatabaseError.connectionIsClosed()
|
throw DatabaseError.connectionIsClosed()
|
||||||
@@ -806,35 +805,38 @@ extension DatabasePool: DatabaseWriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func barrierWriteWithoutTransaction<T>(
|
public func barrierWriteWithoutTransaction<T: Sendable>(
|
||||||
_ updates: sending (Database) throws -> sending T
|
_ updates: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
guard let readerPool else {
|
guard let readerPool else {
|
||||||
throw DatabaseError.connectionIsClosed()
|
throw DatabaseError.connectionIsClosed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pool.barrier does not support async calls (yet?).
|
||||||
|
// So we perform cancellation checks just as in
|
||||||
|
// the async version of SerializedDatabase.execute().
|
||||||
let cancelMutex = Mutex<(@Sendable () -> Void)?>(nil)
|
let cancelMutex = Mutex<(@Sendable () -> Void)?>(nil)
|
||||||
try Task.checkCancellation()
|
return try await withTaskCancellationHandler {
|
||||||
return try await readerPool.barrier {
|
|
||||||
try Task.checkCancellation()
|
try Task.checkCancellation()
|
||||||
var result = Disconnected<T?>(nil)
|
return try await readerPool.barrier {
|
||||||
try writer.sync { db in
|
|
||||||
defer {
|
|
||||||
cancelMutex.store(nil)
|
|
||||||
db.uncancel()
|
|
||||||
}
|
|
||||||
cancelMutex.store(db.cancel)
|
|
||||||
try Task.checkCancellation()
|
try Task.checkCancellation()
|
||||||
try result.exchange(newValue: updates(db))
|
return try writer.sync { db in
|
||||||
|
defer {
|
||||||
|
cancelMutex.store(nil)
|
||||||
|
db.uncancel()
|
||||||
|
}
|
||||||
|
cancelMutex.store(db.cancel)
|
||||||
|
try Task.checkCancellation()
|
||||||
|
return try updates(db)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result.consume()!
|
|
||||||
} onCancel: {
|
} onCancel: {
|
||||||
cancelMutex.withLock { $0?() }
|
cancelMutex.withLock { $0?() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func asyncBarrierWriteWithoutTransaction(
|
public func asyncBarrierWriteWithoutTransaction(
|
||||||
_ updates: sending @escaping (Result<Database, Error>) -> Void
|
_ updates: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
guard let readerPool else {
|
guard let readerPool else {
|
||||||
updates(.failure(DatabaseError.connectionIsClosed()))
|
updates(.failure(DatabaseError.connectionIsClosed()))
|
||||||
@@ -890,7 +892,7 @@ extension DatabasePool: DatabaseWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func asyncWriteWithoutTransaction(
|
public func asyncWriteWithoutTransaction(
|
||||||
_ updates: sending @escaping (Database) -> Void
|
_ updates: @escaping @Sendable (Database) -> Void
|
||||||
) {
|
) {
|
||||||
writer.async(updates)
|
writer.async(updates)
|
||||||
}
|
}
|
||||||
File renamed without changes.
@@ -224,6 +224,7 @@ extension DatabaseQueue: DatabaseReader {
|
|||||||
|
|
||||||
// MARK: - Reading from Database
|
// MARK: - Reading from Database
|
||||||
|
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func read<T>(_ value: (Database) throws -> T) throws -> T {
|
public func read<T>(_ value: (Database) throws -> T) throws -> T {
|
||||||
try writer.sync { db in
|
try writer.sync { db in
|
||||||
try db.isolated(readOnly: true) {
|
try db.isolated(readOnly: true) {
|
||||||
@@ -232,20 +233,18 @@ extension DatabaseQueue: DatabaseReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func read<T>(
|
public func read<T: Sendable>(
|
||||||
_ value: sending (Database) throws -> sending T
|
_ value: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
try await writer.execute { db in
|
try await writer.execute { db in
|
||||||
var result = Disconnected<T?>(nil)
|
|
||||||
try db.isolated(readOnly: true) {
|
try db.isolated(readOnly: true) {
|
||||||
_ = try result.exchange(newValue: value(db))
|
try value(db)
|
||||||
}
|
}
|
||||||
return result.consume()!
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func asyncRead(
|
public func asyncRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
writer.async { db in
|
writer.async { db in
|
||||||
defer {
|
defer {
|
||||||
@@ -266,7 +265,6 @@ extension DatabaseQueue: DatabaseReader {
|
|||||||
// See <https://github.com/groue/GRDB.swift/pull/1213>.
|
// See <https://github.com/groue/GRDB.swift/pull/1213>.
|
||||||
try db.beginReadOnly()
|
try db.beginReadOnly()
|
||||||
try db.beginTransaction(.deferred)
|
try db.beginTransaction(.deferred)
|
||||||
try db.clearSchemaCacheIfNeeded()
|
|
||||||
value(.success(db))
|
value(.success(db))
|
||||||
} catch {
|
} catch {
|
||||||
value(.failure(error))
|
value(.failure(error))
|
||||||
@@ -274,18 +272,19 @@ extension DatabaseQueue: DatabaseReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func unsafeRead<T>(_ value: (Database) throws -> T) rethrows -> T {
|
public func unsafeRead<T>(_ value: (Database) throws -> T) rethrows -> T {
|
||||||
try writer.sync(value)
|
try writer.sync(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func unsafeRead<T>(
|
public func unsafeRead<T: Sendable>(
|
||||||
_ value: sending (Database) throws -> sending T
|
_ value: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
try await writer.execute(value)
|
try await writer.execute(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func asyncUnsafeRead(
|
public func asyncUnsafeRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
writer.async { value(.success($0)) }
|
writer.async { value(.success($0)) }
|
||||||
}
|
}
|
||||||
@@ -295,7 +294,7 @@ extension DatabaseQueue: DatabaseReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func spawnConcurrentRead(
|
public func spawnConcurrentRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
// Check that we're on the writer queue...
|
// Check that we're on the writer queue...
|
||||||
writer.execute { db in
|
writer.execute { db in
|
||||||
@@ -320,7 +319,6 @@ extension DatabaseQueue: DatabaseReader {
|
|||||||
// See <https://github.com/groue/GRDB.swift/pull/1213>.
|
// See <https://github.com/groue/GRDB.swift/pull/1213>.
|
||||||
try db.beginReadOnly()
|
try db.beginReadOnly()
|
||||||
try db.beginTransaction(.deferred)
|
try db.beginTransaction(.deferred)
|
||||||
try db.clearSchemaCacheIfNeeded()
|
|
||||||
value(.success(db))
|
value(.success(db))
|
||||||
} catch {
|
} catch {
|
||||||
value(.failure(error))
|
value(.failure(error))
|
||||||
@@ -332,20 +330,20 @@ extension DatabaseQueue: DatabaseReader {
|
|||||||
|
|
||||||
public func _add<Reducer: ValueReducer>(
|
public func _add<Reducer: ValueReducer>(
|
||||||
observation: ValueObservation<Reducer>,
|
observation: ValueObservation<Reducer>,
|
||||||
scheduler: some ValueObservationScheduler,
|
scheduling scheduler: some ValueObservationScheduler,
|
||||||
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
||||||
) -> AnyDatabaseCancellable {
|
) -> AnyDatabaseCancellable {
|
||||||
if configuration.readonly {
|
if configuration.readonly {
|
||||||
// The easy case: the database does not change
|
// The easy case: the database does not change
|
||||||
return _addReadOnly(
|
return _addReadOnly(
|
||||||
observation: observation,
|
observation: observation,
|
||||||
scheduler: scheduler,
|
scheduling: scheduler,
|
||||||
onChange: onChange)
|
onChange: onChange)
|
||||||
} else {
|
} else {
|
||||||
// Observe from the writer database connection.
|
// Observe from the writer database connection.
|
||||||
return _addWriteOnly(
|
return _addWriteOnly(
|
||||||
observation: observation,
|
observation: observation,
|
||||||
scheduler: scheduler,
|
scheduling: scheduler,
|
||||||
onChange: onChange)
|
onChange: onChange)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -393,28 +391,30 @@ extension DatabaseQueue: DatabaseWriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T {
|
public func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T {
|
||||||
try writer.sync(updates)
|
try writer.sync(updates)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func writeWithoutTransaction<T>(
|
public func writeWithoutTransaction<T: Sendable>(
|
||||||
_ updates: sending (Database) throws -> sending T
|
_ updates: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
try await writer.execute(updates)
|
try await writer.execute(updates)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) throws -> T {
|
public func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) throws -> T {
|
||||||
try writer.sync(updates)
|
try writer.sync(updates)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func barrierWriteWithoutTransaction<T>(
|
public func barrierWriteWithoutTransaction<T: Sendable>(
|
||||||
_ updates: sending (Database) throws -> sending T
|
_ updates: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
try await writer.execute(updates)
|
try await writer.execute(updates)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func asyncBarrierWriteWithoutTransaction(
|
public func asyncBarrierWriteWithoutTransaction(
|
||||||
_ updates: sending @escaping (Result<Database, Error>) -> Void
|
_ updates: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
writer.async { updates(.success($0)) }
|
writer.async { updates(.success($0)) }
|
||||||
}
|
}
|
||||||
@@ -462,7 +462,7 @@ extension DatabaseQueue: DatabaseWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func asyncWriteWithoutTransaction(
|
public func asyncWriteWithoutTransaction(
|
||||||
_ updates: sending @escaping (Database) -> Void
|
_ updates: @escaping @Sendable (Database) -> Void
|
||||||
) {
|
) {
|
||||||
writer.async(updates)
|
writer.async(updates)
|
||||||
}
|
}
|
||||||
@@ -22,16 +22,14 @@ import Dispatch
|
|||||||
/// ### Reading from the Database
|
/// ### Reading from the Database
|
||||||
///
|
///
|
||||||
/// - ``read(_:)-3806d``
|
/// - ``read(_:)-3806d``
|
||||||
/// - ``read(_:)-40k5v``
|
/// - ``read(_:)-5mfwu``
|
||||||
/// - ``read(_:)-5t1ik``
|
|
||||||
/// - ``readPublisher(receiveOn:value:)``
|
/// - ``readPublisher(receiveOn:value:)``
|
||||||
/// - ``asyncRead(_:)``
|
/// - ``asyncRead(_:)``
|
||||||
///
|
///
|
||||||
/// ### Unsafe Methods
|
/// ### Unsafe Methods
|
||||||
///
|
///
|
||||||
/// - ``unsafeRead(_:)-5i7tf``
|
/// - ``unsafeRead(_:)-5i7tf``
|
||||||
/// - ``unsafeRead(_:)-9e4ug``
|
/// - ``unsafeRead(_:)-90w0p``
|
||||||
/// - ``unsafeRead(_:)-45db3``
|
|
||||||
/// - ``unsafeReentrantRead(_:)``
|
/// - ``unsafeReentrantRead(_:)``
|
||||||
/// - ``asyncUnsafeRead(_:)``
|
/// - ``asyncUnsafeRead(_:)``
|
||||||
///
|
///
|
||||||
@@ -187,6 +185,7 @@ public protocol DatabaseReader: AnyObject, Sendable {
|
|||||||
/// - parameter value: A closure which accesses the database.
|
/// - parameter value: A closure which accesses the database.
|
||||||
/// - throws: The error thrown by `value`, or any ``DatabaseError`` that
|
/// - throws: The error thrown by `value`, or any ``DatabaseError`` that
|
||||||
/// would happen while establishing the database access.
|
/// 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
|
func read<T>(_ value: (Database) throws -> T) throws -> T
|
||||||
|
|
||||||
/// Executes read-only database operations, and returns their result after
|
/// Executes read-only database operations, and returns their result after
|
||||||
@@ -215,9 +214,9 @@ public protocol DatabaseReader: AnyObject, Sendable {
|
|||||||
/// - throws: Any ``DatabaseError`` that happens while establishing the
|
/// - throws: Any ``DatabaseError`` that happens while establishing the
|
||||||
/// database access, or the error thrown by `value`, or
|
/// database access, or the error thrown by `value`, or
|
||||||
/// `CancellationError` if the task is cancelled.
|
/// `CancellationError` if the task is cancelled.
|
||||||
func read<T>(
|
func read<T: Sendable>(
|
||||||
_ value: sending (Database) throws -> sending T
|
_ value: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T
|
) async throws -> T
|
||||||
|
|
||||||
/// Schedules read-only database operations for execution, and
|
/// Schedules read-only database operations for execution, and
|
||||||
/// returns immediately.
|
/// returns immediately.
|
||||||
@@ -246,7 +245,7 @@ public protocol DatabaseReader: AnyObject, Sendable {
|
|||||||
/// is a `Result` that provides the database connection, or the failure
|
/// is a `Result` that provides the database connection, or the failure
|
||||||
/// that would prevent establishing the read access to the database.
|
/// that would prevent establishing the read access to the database.
|
||||||
func asyncRead(
|
func asyncRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
)
|
)
|
||||||
|
|
||||||
/// Executes database operations, and returns their result after they have
|
/// Executes database operations, and returns their result after they have
|
||||||
@@ -284,6 +283,7 @@ public protocol DatabaseReader: AnyObject, Sendable {
|
|||||||
/// - parameter value: A closure which accesses the database.
|
/// - parameter value: A closure which accesses the database.
|
||||||
/// - throws: The error thrown by `value`, or any ``DatabaseError`` that
|
/// - throws: The error thrown by `value`, or any ``DatabaseError`` that
|
||||||
/// would happen while establishing the database access.
|
/// 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
|
func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T
|
||||||
|
|
||||||
/// Executes database operations, and returns their result after they have
|
/// Executes database operations, and returns their result after they have
|
||||||
@@ -318,9 +318,9 @@ public protocol DatabaseReader: AnyObject, Sendable {
|
|||||||
/// - throws: Any ``DatabaseError`` that happens while establishing the
|
/// - throws: Any ``DatabaseError`` that happens while establishing the
|
||||||
/// database access, or the error thrown by `value`, or
|
/// database access, or the error thrown by `value`, or
|
||||||
/// `CancellationError` if the task is cancelled.
|
/// `CancellationError` if the task is cancelled.
|
||||||
func unsafeRead<T>(
|
func unsafeRead<T: Sendable>(
|
||||||
_ value: sending (Database) throws -> sending T
|
_ value: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T
|
) async throws -> T
|
||||||
|
|
||||||
/// Schedules database operations for execution, and returns immediately.
|
/// Schedules database operations for execution, and returns immediately.
|
||||||
///
|
///
|
||||||
@@ -354,7 +354,7 @@ public protocol DatabaseReader: AnyObject, Sendable {
|
|||||||
/// is a `Result` that provides the database connection, or the failure
|
/// is a `Result` that provides the database connection, or the failure
|
||||||
/// that would prevent establishing the read access to the database.
|
/// that would prevent establishing the read access to the database.
|
||||||
func asyncUnsafeRead(
|
func asyncUnsafeRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
)
|
)
|
||||||
|
|
||||||
/// Executes database operations, and returns their result after they have
|
/// Executes database operations, and returns their result after they have
|
||||||
@@ -405,75 +405,18 @@ public protocol DatabaseReader: AnyObject, Sendable {
|
|||||||
|
|
||||||
/// Starts a value observation.
|
/// Starts a value observation.
|
||||||
///
|
///
|
||||||
/// Use the ``ValueObservation/start(in:scheduling:isolation:onError:onChange:)``
|
/// Use the ``ValueObservation/start(in:scheduling:onError:onChange:)``
|
||||||
/// method instead.
|
/// method instead.
|
||||||
///
|
///
|
||||||
/// - parameter observation: a ValueObservation.
|
/// - parameter observation: a ValueObservation.
|
||||||
/// - returns: A DatabaseCancellable that can stop the observation.
|
/// - returns: A DatabaseCancellable that can stop the observation.
|
||||||
func _add<Reducer: ValueReducer>(
|
func _add<Reducer: ValueReducer>(
|
||||||
observation: ValueObservation<Reducer>,
|
observation: ValueObservation<Reducer>,
|
||||||
scheduler: some ValueObservationScheduler,
|
scheduling scheduler: some ValueObservationScheduler,
|
||||||
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
||||||
) -> AnyDatabaseCancellable
|
) -> AnyDatabaseCancellable
|
||||||
}
|
}
|
||||||
|
|
||||||
extension DatabaseReader {
|
|
||||||
|
|
||||||
// MARK: - Asynchronous Database Access
|
|
||||||
|
|
||||||
/// Executes read-only database operations, and returns their `Sendable`
|
|
||||||
/// result after they have finished executing.
|
|
||||||
///
|
|
||||||
/// This method supports the shorthand closure notation, where a
|
|
||||||
/// `Sendable` function such as `Player.fetchAll` is given instead of
|
|
||||||
/// a closure. For example:
|
|
||||||
///
|
|
||||||
/// ```swift
|
|
||||||
/// let players = try await reader.read(Player.fetchAll)
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
/// Apart from its `Sendable` requirements, this method behaves exactly
|
|
||||||
/// like ``DatabaseReader/read(_:)-40k5v``. See
|
|
||||||
/// <doc:SwiftConcurrency#Shorthand-Closure-Notation> for more information.
|
|
||||||
///
|
|
||||||
/// - parameter value: A function which accesses the database.
|
|
||||||
/// - throws: Any ``DatabaseError`` that happens while establishing the
|
|
||||||
/// database access, or the error thrown by `value`, or
|
|
||||||
/// `CancellationError` if the task is cancelled.
|
|
||||||
@_disfavoredOverload
|
|
||||||
public func read<T: Sendable>(
|
|
||||||
_ value: @Sendable (Database) throws -> T
|
|
||||||
) async throws -> T {
|
|
||||||
try await read { db in try value(db) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Executes database operations, and returns their `Sendable` result
|
|
||||||
/// after they have finished executing.
|
|
||||||
///
|
|
||||||
/// This method supports the shorthand closure notation, where a
|
|
||||||
/// `Sendable` function such as `Player.fetchAll` is given instead of
|
|
||||||
/// a closure. For example:
|
|
||||||
///
|
|
||||||
/// ```swift
|
|
||||||
/// let players = try await reader.unsafeRead(Player.fetchAll)
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
/// Apart from its `Sendable` requirements, this method behaves exactly
|
|
||||||
/// like ``DatabaseReader/unsafeRead(_:)-9e4ug``. See
|
|
||||||
/// <doc:SwiftConcurrency#Shorthand-Closure-Notation> for more information.
|
|
||||||
///
|
|
||||||
/// - parameter value: A function which accesses the database.
|
|
||||||
/// - throws: Any ``DatabaseError`` that happens while establishing the
|
|
||||||
/// database access, or the error thrown by `value`, or
|
|
||||||
/// `CancellationError` if the task is cancelled.
|
|
||||||
@_disfavoredOverload
|
|
||||||
public func unsafeRead<T: Sendable>(
|
|
||||||
_ value: @Sendable (Database) throws -> T
|
|
||||||
) async throws -> T {
|
|
||||||
try await unsafeRead { db in try value(db) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension DatabaseReader {
|
extension DatabaseReader {
|
||||||
|
|
||||||
// MARK: - Backup
|
// MARK: - Backup
|
||||||
@@ -632,10 +575,10 @@ extension DatabaseReader {
|
|||||||
/// initial value.
|
/// initial value.
|
||||||
func _addReadOnly<Reducer: ValueReducer>(
|
func _addReadOnly<Reducer: ValueReducer>(
|
||||||
observation: ValueObservation<Reducer>,
|
observation: ValueObservation<Reducer>,
|
||||||
scheduler: some ValueObservationScheduler,
|
scheduling scheduler: some ValueObservationScheduler,
|
||||||
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
||||||
) -> AnyDatabaseCancellable {
|
) -> AnyDatabaseCancellable {
|
||||||
if scheduler.isImmediate {
|
if scheduler.immediateInitialValue() {
|
||||||
do {
|
do {
|
||||||
// Perform a reentrant read, in case the observation would be
|
// Perform a reentrant read, in case the observation would be
|
||||||
// started from a database access.
|
// started from a database access.
|
||||||
@@ -703,34 +646,36 @@ extension AnyDatabaseReader: DatabaseReader {
|
|||||||
base.interrupt()
|
base.interrupt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func read<T>(_ value: (Database) throws -> T) throws -> T {
|
public func read<T>(_ value: (Database) throws -> T) throws -> T {
|
||||||
try base.read(value)
|
try base.read(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func read<T>(
|
public func read<T: Sendable>(
|
||||||
_ value: sending (Database) throws -> sending T
|
_ value: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
try await base.read(value)
|
try await base.read(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func asyncRead(
|
public func asyncRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
base.asyncRead(value)
|
base.asyncRead(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T {
|
public func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T {
|
||||||
try base.unsafeRead(value)
|
try base.unsafeRead(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func unsafeRead<T>(
|
public func unsafeRead<T: Sendable>(
|
||||||
_ value: sending (Database) throws -> sending T
|
_ value: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
try await base.unsafeRead(value)
|
try await base.unsafeRead(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func asyncUnsafeRead(
|
public func asyncUnsafeRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
base.asyncUnsafeRead(value)
|
base.asyncUnsafeRead(value)
|
||||||
}
|
}
|
||||||
@@ -741,12 +686,12 @@ extension AnyDatabaseReader: DatabaseReader {
|
|||||||
|
|
||||||
public func _add<Reducer: ValueReducer>(
|
public func _add<Reducer: ValueReducer>(
|
||||||
observation: ValueObservation<Reducer>,
|
observation: ValueObservation<Reducer>,
|
||||||
scheduler: some ValueObservationScheduler,
|
scheduling scheduler: some ValueObservationScheduler,
|
||||||
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
||||||
) -> AnyDatabaseCancellable {
|
) -> AnyDatabaseCancellable {
|
||||||
base._add(
|
base._add(
|
||||||
observation: observation,
|
observation: observation,
|
||||||
scheduler: scheduler,
|
scheduling: scheduler,
|
||||||
onChange: onChange)
|
onChange: onChange)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -796,13 +741,14 @@ extension DatabaseSnapshotReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// There is no such thing as an unsafe access to a snapshot.
|
// 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 {
|
public func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T {
|
||||||
try read(value)
|
try read(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is no such thing as an unsafe access to a snapshot.
|
// There is no such thing as an unsafe access to a snapshot.
|
||||||
public func asyncUnsafeRead(
|
public func asyncUnsafeRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
asyncRead(value)
|
asyncRead(value)
|
||||||
}
|
}
|
||||||
File renamed without changes.
+6
-6
@@ -86,8 +86,8 @@ extension DatabaseRegionObservation {
|
|||||||
@preconcurrency // For RxGRDB, see <https://github.com/RxSwiftCommunity/RxGRDB/issues/72#issuecomment-2631125658>
|
@preconcurrency // For RxGRDB, see <https://github.com/RxSwiftCommunity/RxGRDB/issues/72#issuecomment-2631125658>
|
||||||
public func start(
|
public func start(
|
||||||
in writer: any DatabaseWriter,
|
in writer: any DatabaseWriter,
|
||||||
onError: sending @escaping (Error) -> Void,
|
onError: @escaping @Sendable (Error) -> Void,
|
||||||
onChange: sending @escaping (Database) -> Void)
|
onChange: @escaping @Sendable (Database) -> Void)
|
||||||
-> AnyDatabaseCancellable
|
-> AnyDatabaseCancellable
|
||||||
{
|
{
|
||||||
let stateMutex = Mutex(ObservationState.pending)
|
let stateMutex = Mutex(ObservationState.pending)
|
||||||
@@ -148,10 +148,10 @@ extension DatabaseRegionObservation {
|
|||||||
|
|
||||||
private class DatabaseRegionObserver: TransactionObserver {
|
private class DatabaseRegionObserver: TransactionObserver {
|
||||||
let region: DatabaseRegion
|
let region: DatabaseRegion
|
||||||
let onChange: (Database) -> Void
|
let onChange: @Sendable (Database) -> Void
|
||||||
var isChanged = false
|
var isChanged = false
|
||||||
|
|
||||||
init(region: DatabaseRegion, onChange: @escaping (Database) -> Void) {
|
init(region: DatabaseRegion, onChange: @escaping @Sendable (Database) -> Void) {
|
||||||
self.region = region
|
self.region = region
|
||||||
self.onChange = onChange
|
self.onChange = onChange
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ extension DatabasePublishers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func receive<S>(subscriber: S)
|
public func receive<S>(subscriber: S)
|
||||||
where S: Subscriber & SendableMetatype,
|
where S: Subscriber & GRDBSendableMetatype,
|
||||||
Failure == S.Failure,
|
Failure == S.Failure,
|
||||||
Output == S.Input
|
Output == S.Input
|
||||||
{
|
{
|
||||||
@@ -216,7 +216,7 @@ extension DatabasePublishers {
|
|||||||
|
|
||||||
private class DatabaseRegionSubscription<Downstream>:
|
private class DatabaseRegionSubscription<Downstream>:
|
||||||
Subscription, @unchecked Sendable
|
Subscription, @unchecked Sendable
|
||||||
where Downstream: Subscriber & SendableMetatype,
|
where Downstream: Subscriber & GRDBSendableMetatype,
|
||||||
Downstream.Failure == Error,
|
Downstream.Failure == Error,
|
||||||
Downstream.Input == Database
|
Downstream.Input == Database
|
||||||
{
|
{
|
||||||
File renamed without changes.
File renamed without changes.
@@ -153,22 +153,24 @@ extension DatabaseSnapshot: DatabaseSnapshotReader {
|
|||||||
|
|
||||||
// MARK: - Reading from Database
|
// MARK: - Reading from Database
|
||||||
|
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func read<T>(_ block: (Database) throws -> T) rethrows -> T {
|
public func read<T>(_ block: (Database) throws -> T) rethrows -> T {
|
||||||
try reader.sync(block)
|
try reader.sync(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func read<T>(
|
public func read<T: Sendable>(
|
||||||
_ value: sending (Database) throws -> sending T
|
_ value: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
try await reader.execute(value)
|
try await reader.execute(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func asyncRead(
|
public func asyncRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
reader.async { value(.success($0)) }
|
reader.async { value(.success($0)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func unsafeRead<T>(_ value: (Database) throws -> T) rethrows -> T {
|
public func unsafeRead<T>(_ value: (Database) throws -> T) rethrows -> T {
|
||||||
try reader.sync(value)
|
try reader.sync(value)
|
||||||
}
|
}
|
||||||
@@ -177,14 +179,14 @@ extension DatabaseSnapshot: DatabaseSnapshotReader {
|
|||||||
// We can't provide this as a default implementation in
|
// We can't provide this as a default implementation in
|
||||||
// `DatabaseSnapshotReader`, because of
|
// `DatabaseSnapshotReader`, because of
|
||||||
// <https://github.com/apple/swift/issues/74469>.
|
// <https://github.com/apple/swift/issues/74469>.
|
||||||
public func unsafeRead<T>(
|
public func unsafeRead<T: Sendable>(
|
||||||
_ value: sending (Database) throws -> sending T
|
_ value: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
try await read(value)
|
try await read(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func asyncUnsafeRead(
|
public func asyncUnsafeRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
reader.async { value(.success($0)) }
|
reader.async { value(.success($0)) }
|
||||||
}
|
}
|
||||||
@@ -197,12 +199,12 @@ extension DatabaseSnapshot: DatabaseSnapshotReader {
|
|||||||
|
|
||||||
public func _add<Reducer: ValueReducer>(
|
public func _add<Reducer: ValueReducer>(
|
||||||
observation: ValueObservation<Reducer>,
|
observation: ValueObservation<Reducer>,
|
||||||
scheduler: some ValueObservationScheduler,
|
scheduling scheduler: some ValueObservationScheduler,
|
||||||
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
||||||
) -> AnyDatabaseCancellable {
|
) -> AnyDatabaseCancellable {
|
||||||
_addReadOnly(
|
_addReadOnly(
|
||||||
observation: observation,
|
observation: observation,
|
||||||
scheduler: scheduler,
|
scheduling: scheduler,
|
||||||
onChange: onChange)
|
onChange: onChange)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+19
-32
@@ -1,16 +1,14 @@
|
|||||||
#if SQLITE_ENABLE_SNAPSHOT && !SQLITE_DISABLE_SNAPSHOT
|
#if SQLITE_ENABLE_SNAPSHOT && !SQLITE_DISABLE_SNAPSHOT
|
||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// A database connection that allows concurrent accesses to unchanging
|
/// A database connection that allows concurrent accesses to unchanging
|
||||||
@@ -274,6 +272,7 @@ extension DatabaseSnapshotPool: DatabaseSnapshotReader {
|
|||||||
readerPool?.forEach { $0.interrupt() }
|
readerPool?.forEach { $0.interrupt() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func read<T>(_ value: (Database) throws -> T) throws -> T {
|
public func read<T>(_ value: (Database) throws -> T) throws -> T {
|
||||||
GRDBPrecondition(currentReader == nil, "Database methods are not reentrant.")
|
GRDBPrecondition(currentReader == nil, "Database methods are not reentrant.")
|
||||||
guard let readerPool else {
|
guard let readerPool else {
|
||||||
@@ -297,9 +296,9 @@ extension DatabaseSnapshotPool: DatabaseSnapshotReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func read<T>(
|
public func read<T: Sendable>(
|
||||||
_ value: sending (Database) throws -> sending T
|
_ value: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
guard let readerPool else {
|
guard let readerPool else {
|
||||||
throw DatabaseError.connectionIsClosed()
|
throw DatabaseError.connectionIsClosed()
|
||||||
}
|
}
|
||||||
@@ -311,34 +310,22 @@ extension DatabaseSnapshotPool: DatabaseSnapshotReader {
|
|||||||
releaseReader(readerCompletion ?? .reuse)
|
releaseReader(readerCompletion ?? .reuse)
|
||||||
}
|
}
|
||||||
let (result, completion) = try await reader.execute { db in
|
let (result, completion) = try await reader.execute { db in
|
||||||
let result: Result<T, any Error>
|
let result = Result { try value(db) }
|
||||||
do {
|
|
||||||
result = try .success(value(db))
|
|
||||||
} catch {
|
|
||||||
result = .failure(error)
|
|
||||||
}
|
|
||||||
let completion = poolCompletion(db)
|
let completion = poolCompletion(db)
|
||||||
return (result, completion)
|
return (result, completion)
|
||||||
}
|
}
|
||||||
readerCompletion = completion
|
readerCompletion = completion
|
||||||
switch result {
|
return try result.get()
|
||||||
case let .success(output):
|
|
||||||
return output
|
|
||||||
case let .failure(error):
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func asyncRead(
|
public func asyncRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
guard let readerPool else {
|
guard let readerPool else {
|
||||||
value(.failure(DatabaseError.connectionIsClosed()))
|
value(.failure(DatabaseError.connectionIsClosed()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safe because `value` is sending, and called only once.
|
|
||||||
nonisolated(unsafe) let value = value
|
|
||||||
readerPool.asyncGet { result in
|
readerPool.asyncGet { result in
|
||||||
do {
|
do {
|
||||||
let (reader, releaseReader) = try result.get()
|
let (reader, releaseReader) = try result.get()
|
||||||
@@ -357,9 +344,9 @@ extension DatabaseSnapshotPool: DatabaseSnapshotReader {
|
|||||||
// We can't provide this as a default implementation in
|
// We can't provide this as a default implementation in
|
||||||
// `DatabaseSnapshotReader`, because of
|
// `DatabaseSnapshotReader`, because of
|
||||||
// <https://github.com/apple/swift/issues/74469>.
|
// <https://github.com/apple/swift/issues/74469>.
|
||||||
public func unsafeRead<T>(
|
public func unsafeRead<T: Sendable>(
|
||||||
_ value: sending (Database) throws -> sending T
|
_ value: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
try await read(value)
|
try await read(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,10 +367,10 @@ extension DatabaseSnapshotPool: DatabaseSnapshotReader {
|
|||||||
|
|
||||||
public func _add<Reducer>(
|
public func _add<Reducer>(
|
||||||
observation: ValueObservation<Reducer>,
|
observation: ValueObservation<Reducer>,
|
||||||
scheduler: some ValueObservationScheduler,
|
scheduling scheduler: some ValueObservationScheduler,
|
||||||
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
||||||
) -> AnyDatabaseCancellable where Reducer: ValueReducer {
|
) -> AnyDatabaseCancellable where Reducer: ValueReducer {
|
||||||
_addReadOnly(observation: observation, scheduler: scheduler, onChange: onChange)
|
_addReadOnly(observation: observation, scheduling: scheduler, onChange: onChange)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a reader that can be used from the current dispatch queue,
|
/// Returns a reader that can be used from the current dispatch queue,
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
@@ -239,7 +237,8 @@ extension DatabaseValue: StatementBinding {
|
|||||||
|
|
||||||
extension DatabaseValue: Sendable { }
|
extension DatabaseValue: Sendable { }
|
||||||
|
|
||||||
extension DatabaseValue.Storage: Sendable { }
|
// @unchecked Sendable because Data is not Sendable in all target OS
|
||||||
|
extension DatabaseValue.Storage: @unchecked Sendable { }
|
||||||
|
|
||||||
// MARK: - Hashable & Equatable
|
// MARK: - Hashable & Equatable
|
||||||
|
|
||||||
File renamed without changes.
@@ -22,21 +22,18 @@ import Dispatch
|
|||||||
/// ### Writing into the Database
|
/// ### Writing into the Database
|
||||||
///
|
///
|
||||||
/// - ``write(_:)-76inz``
|
/// - ``write(_:)-76inz``
|
||||||
/// - ``write(_:)-7mrav``
|
|
||||||
/// - ``write(_:)-4gnqx``
|
/// - ``write(_:)-4gnqx``
|
||||||
/// - ``writePublisher(receiveOn:updates:)``
|
/// - ``writePublisher(receiveOn:updates:)``
|
||||||
/// - ``writePublisher(receiveOn:updates:thenRead:)``
|
/// - ``writePublisher(receiveOn:updates:thenRead:)``
|
||||||
/// - ``writeWithoutTransaction(_:)-4qh1w``
|
/// - ``writeWithoutTransaction(_:)-4qh1w``
|
||||||
/// - ``writeWithoutTransaction(_:)-7oqlh``
|
/// - ``writeWithoutTransaction(_:)-18zhj``
|
||||||
/// - ``writeWithoutTransaction(_:)-1b250``
|
|
||||||
/// - ``asyncWrite(_:completion:)``
|
/// - ``asyncWrite(_:completion:)``
|
||||||
/// - ``asyncWriteWithoutTransaction(_:)``
|
/// - ``asyncWriteWithoutTransaction(_:)``
|
||||||
///
|
///
|
||||||
/// ### Exclusive Access to the Database
|
/// ### Exclusive Access to the Database
|
||||||
///
|
///
|
||||||
/// - ``barrierWriteWithoutTransaction(_:)-280j1``
|
/// - ``barrierWriteWithoutTransaction(_:)-280j1``
|
||||||
/// - ``barrierWriteWithoutTransaction(_:)-5u7gc``
|
/// - ``barrierWriteWithoutTransaction(_:)-11q6c``
|
||||||
/// - ``barrierWriteWithoutTransaction(_:)-1dvaq``
|
|
||||||
/// - ``asyncBarrierWriteWithoutTransaction(_:)``
|
/// - ``asyncBarrierWriteWithoutTransaction(_:)``
|
||||||
///
|
///
|
||||||
/// ### Reading from the Latest Committed Database State
|
/// ### Reading from the Latest Committed Database State
|
||||||
@@ -100,6 +97,7 @@ public protocol DatabaseWriter: DatabaseReader {
|
|||||||
///
|
///
|
||||||
/// - parameter updates: A closure which accesses the database.
|
/// - parameter updates: A closure which accesses the database.
|
||||||
/// - throws: The error thrown by `updates`.
|
/// - throws: The error thrown by `updates`.
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T
|
func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T
|
||||||
|
|
||||||
/// Executes database operations, and returns their result after they have
|
/// Executes database operations, and returns their result after they have
|
||||||
@@ -131,9 +129,9 @@ public protocol DatabaseWriter: DatabaseReader {
|
|||||||
/// - throws: Any ``DatabaseError`` that happens while establishing the
|
/// - throws: Any ``DatabaseError`` that happens while establishing the
|
||||||
/// database access, or the error thrown by `updates`, or
|
/// database access, or the error thrown by `updates`, or
|
||||||
/// `CancellationError` if the task is cancelled.
|
/// `CancellationError` if the task is cancelled.
|
||||||
func writeWithoutTransaction<T>(
|
func writeWithoutTransaction<T: Sendable>(
|
||||||
_ updates: sending (Database) throws -> sending T
|
_ updates: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T
|
) async throws -> T
|
||||||
|
|
||||||
/// Executes database operations, and returns their result after they have
|
/// Executes database operations, and returns their result after they have
|
||||||
/// finished executing.
|
/// finished executing.
|
||||||
@@ -172,6 +170,7 @@ public protocol DatabaseWriter: DatabaseReader {
|
|||||||
///
|
///
|
||||||
/// - parameter updates: A closure which accesses the database.
|
/// - parameter updates: A closure which accesses the database.
|
||||||
/// - throws: The error thrown by `updates`.
|
/// - throws: The error thrown by `updates`.
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) throws -> T
|
func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) throws -> T
|
||||||
|
|
||||||
/// Executes database operations, and returns their result after they have
|
/// Executes database operations, and returns their result after they have
|
||||||
@@ -213,9 +212,9 @@ public protocol DatabaseWriter: DatabaseReader {
|
|||||||
/// - throws: Any ``DatabaseError`` that happens while establishing the
|
/// - throws: Any ``DatabaseError`` that happens while establishing the
|
||||||
/// database access, or the error thrown by `updates`, or
|
/// database access, or the error thrown by `updates`, or
|
||||||
/// `CancellationError` if the task is cancelled.
|
/// `CancellationError` if the task is cancelled.
|
||||||
func barrierWriteWithoutTransaction<T>(
|
func barrierWriteWithoutTransaction<T: Sendable>(
|
||||||
_ updates: sending (Database) throws -> sending T
|
_ updates: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T
|
) async throws -> T
|
||||||
|
|
||||||
/// Schedules database operations for execution, and returns immediately.
|
/// Schedules database operations for execution, and returns immediately.
|
||||||
///
|
///
|
||||||
@@ -257,7 +256,7 @@ public protocol DatabaseWriter: DatabaseReader {
|
|||||||
/// is a `Result` that provides the database connection, or the failure
|
/// is a `Result` that provides the database connection, or the failure
|
||||||
/// that would prevent establishing the barrier access to the database.
|
/// that would prevent establishing the barrier access to the database.
|
||||||
func asyncBarrierWriteWithoutTransaction(
|
func asyncBarrierWriteWithoutTransaction(
|
||||||
_ updates: sending @escaping (Result<Database, Error>) -> Void
|
_ updates: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
)
|
)
|
||||||
|
|
||||||
/// Schedules database operations for execution, and returns immediately.
|
/// Schedules database operations for execution, and returns immediately.
|
||||||
@@ -291,7 +290,7 @@ public protocol DatabaseWriter: DatabaseReader {
|
|||||||
///
|
///
|
||||||
/// - parameter updates: A closure which accesses the database.
|
/// - parameter updates: A closure which accesses the database.
|
||||||
func asyncWriteWithoutTransaction(
|
func asyncWriteWithoutTransaction(
|
||||||
_ updates: sending @escaping (Database) -> Void
|
_ updates: @escaping @Sendable (Database) -> Void
|
||||||
)
|
)
|
||||||
|
|
||||||
/// Executes database operations, and returns their result after they have
|
/// Executes database operations, and returns their result after they have
|
||||||
@@ -375,7 +374,7 @@ public protocol DatabaseWriter: DatabaseReader {
|
|||||||
/// is a `Result` that provides the database connection, or the failure
|
/// is a `Result` that provides the database connection, or the failure
|
||||||
/// that would prevent establishing the read access to the database.
|
/// that would prevent establishing the read access to the database.
|
||||||
func spawnConcurrentRead(
|
func spawnConcurrentRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,6 +412,7 @@ extension DatabaseWriter {
|
|||||||
/// - throws: The error thrown by `updates`, or any ``DatabaseError`` that
|
/// - throws: The error thrown by `updates`, or any ``DatabaseError`` that
|
||||||
/// would happen while establishing the database access or committing
|
/// would happen while establishing the database access or committing
|
||||||
/// the transaction.
|
/// the transaction.
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func write<T>(_ updates: (Database) throws -> T) throws -> T {
|
public func write<T>(_ updates: (Database) throws -> T) throws -> T {
|
||||||
try writeWithoutTransaction { db in
|
try writeWithoutTransaction { db in
|
||||||
var result: T?
|
var result: T?
|
||||||
@@ -462,8 +462,8 @@ extension DatabaseWriter {
|
|||||||
/// - parameter updates: A closure which accesses the database.
|
/// - parameter updates: A closure which accesses the database.
|
||||||
/// - parameter completion: A closure called with the transaction result.
|
/// - parameter completion: A closure called with the transaction result.
|
||||||
public func asyncWrite<T>(
|
public func asyncWrite<T>(
|
||||||
_ updates: sending @escaping (Database) throws -> T,
|
_ updates: @escaping @Sendable (Database) throws -> T,
|
||||||
completion: sending @escaping (Database, Result<T, Error>) -> Void
|
completion: @escaping @Sendable (Database, Result<T, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
asyncWriteWithoutTransaction { db in
|
asyncWriteWithoutTransaction { db in
|
||||||
do {
|
do {
|
||||||
@@ -527,6 +527,7 @@ extension DatabaseWriter {
|
|||||||
// MARK: - Erasing the content of the database
|
// MARK: - Erasing the content of the database
|
||||||
|
|
||||||
/// Erase the database: delete all content, drop all tables, etc.
|
/// Erase the database: delete all content, drop all tables, etc.
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func erase() throws {
|
public func erase() throws {
|
||||||
try barrierWriteWithoutTransaction { try $0.erase() }
|
try barrierWriteWithoutTransaction { try $0.erase() }
|
||||||
}
|
}
|
||||||
@@ -537,10 +538,22 @@ extension DatabaseWriter {
|
|||||||
/// disk space.
|
/// disk space.
|
||||||
///
|
///
|
||||||
/// Related SQLite documentation: <https://www.sqlite.org/lang_vacuum.html>
|
/// Related SQLite documentation: <https://www.sqlite.org/lang_vacuum.html>
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func vacuum() throws {
|
public func vacuum() throws {
|
||||||
try writeWithoutTransaction { try $0.execute(sql: "VACUUM") }
|
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
|
/// Creates a new database file at the specified path with a minimum
|
||||||
/// amount of disk space.
|
/// amount of disk space.
|
||||||
///
|
///
|
||||||
@@ -550,11 +563,27 @@ extension DatabaseWriter {
|
|||||||
/// Related SQLite documentation: <https://www.sqlite.org/lang_vacuum.html#vacuuminto>
|
/// Related SQLite documentation: <https://www.sqlite.org/lang_vacuum.html#vacuuminto>
|
||||||
///
|
///
|
||||||
/// - Parameter filePath: file path for new database
|
/// - Parameter filePath: file path for new database
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func vacuum(into filePath: String) throws {
|
public func vacuum(into filePath: String) throws {
|
||||||
try writeWithoutTransaction {
|
try writeWithoutTransaction {
|
||||||
try $0.execute(sql: "VACUUM INTO ?", arguments: [filePath])
|
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
|
// MARK: - Database Observation
|
||||||
|
|
||||||
@@ -563,7 +592,7 @@ extension DatabaseWriter {
|
|||||||
/// was modified.
|
/// was modified.
|
||||||
func _addWriteOnly<Reducer: ValueReducer>(
|
func _addWriteOnly<Reducer: ValueReducer>(
|
||||||
observation: ValueObservation<Reducer>,
|
observation: ValueObservation<Reducer>,
|
||||||
scheduler: some ValueObservationScheduler,
|
scheduling scheduler: some ValueObservationScheduler,
|
||||||
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
||||||
) -> AnyDatabaseCancellable {
|
) -> AnyDatabaseCancellable {
|
||||||
assert(!configuration.readonly, "Use _addReadOnly(observation:) instead")
|
assert(!configuration.readonly, "Use _addReadOnly(observation:) instead")
|
||||||
@@ -611,97 +640,17 @@ extension DatabaseWriter {
|
|||||||
/// - throws: Any ``DatabaseError`` that happens while establishing the
|
/// - throws: Any ``DatabaseError`` that happens while establishing the
|
||||||
/// database access, or the error thrown by `updates`, or
|
/// database access, or the error thrown by `updates`, or
|
||||||
/// `CancellationError` if the task is cancelled.
|
/// `CancellationError` if the task is cancelled.
|
||||||
public func write<T>(
|
|
||||||
_ updates: sending (Database) throws -> sending T
|
|
||||||
) async throws -> sending T {
|
|
||||||
try await writeWithoutTransaction { db in
|
|
||||||
var result = Disconnected<T?>(nil)
|
|
||||||
try db.inTransaction {
|
|
||||||
try result.exchange(newValue: updates(db))
|
|
||||||
return .commit
|
|
||||||
}
|
|
||||||
return result.consume()!
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Executes database operations wrapped in a transaction, and returns
|
|
||||||
/// their `Sendable` result after they have finished executing.
|
|
||||||
///
|
|
||||||
/// This method supports the shorthand closure notation, where a
|
|
||||||
/// `Sendable` function such as `Player.deleteAll` is given instead of
|
|
||||||
/// a closure. For example:
|
|
||||||
///
|
|
||||||
/// ```swift
|
|
||||||
/// let deletedCount = try await writer.write(Player.deleteAll)
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
/// Apart from its `Sendable` requirements, this method behaves exactly
|
|
||||||
/// like ``DatabaseWriter/write(_:)-7mrav``. See
|
|
||||||
/// <doc:SwiftConcurrency#Shorthand-Closure-Notation> for more information.
|
|
||||||
///
|
|
||||||
/// - parameter updates: A function which accesses the database.
|
|
||||||
/// - throws: Any ``DatabaseError`` that happens while establishing the
|
|
||||||
/// database access, or the error thrown by `updates`, or
|
|
||||||
/// `CancellationError` if the task is cancelled.
|
|
||||||
@_disfavoredOverload
|
|
||||||
public func write<T: Sendable>(
|
public func write<T: Sendable>(
|
||||||
_ updates: @Sendable (Database) throws -> T
|
_ updates: @Sendable (Database) throws -> T
|
||||||
) async throws -> T {
|
) async throws -> T {
|
||||||
try await write { db in try updates(db) }
|
try await writeWithoutTransaction { db in
|
||||||
}
|
var result: T?
|
||||||
|
try db.inTransaction {
|
||||||
/// Executes database operations outside of any transaction, and returns
|
result = try updates(db)
|
||||||
/// their `Sendable` result after they have finished executing.
|
return .commit
|
||||||
///
|
}
|
||||||
/// This method supports the shorthand closure notation, where a
|
return result!
|
||||||
/// `Sendable` function such as `Player.fetchCount` is given instead of
|
}
|
||||||
/// a closure. For example:
|
|
||||||
///
|
|
||||||
/// ```swift
|
|
||||||
/// let count = try await writer.writeWithoutTransaction(Player.fetchCount)
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
/// Apart from its `Sendable` requirements, this method behaves exactly
|
|
||||||
/// like ``DatabaseWriter/writeWithoutTransaction(_:)-7oqlh``. See
|
|
||||||
/// <doc:SwiftConcurrency#Shorthand-Closure-Notation> for more information.
|
|
||||||
///
|
|
||||||
/// - parameter updates: A function which accesses the database.
|
|
||||||
/// - throws: Any ``DatabaseError`` that happens while establishing the
|
|
||||||
/// database access, or the error thrown by `updates`, or
|
|
||||||
/// `CancellationError` if the task is cancelled.
|
|
||||||
@_disfavoredOverload
|
|
||||||
public func writeWithoutTransaction<T: Sendable>(
|
|
||||||
_ updates: @Sendable (Database) throws -> T
|
|
||||||
) async throws -> T {
|
|
||||||
try await writeWithoutTransaction { db in try updates(db) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Executes database operations with exclusive access to the database,
|
|
||||||
/// and returns their `Sendable` result after they have
|
|
||||||
/// finished executing.
|
|
||||||
///
|
|
||||||
/// This method supports the shorthand closure notation, where a
|
|
||||||
/// `Sendable` function such as `Player.fetchCount` is given instead of
|
|
||||||
/// a closure. For example:
|
|
||||||
///
|
|
||||||
/// ```swift
|
|
||||||
/// let count = try await writer.barrierWriteWithoutTransaction(
|
|
||||||
/// Player.fetchCount)
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
/// Apart from its `Sendable` requirements, this method behaves exactly
|
|
||||||
/// like ``DatabaseWriter/barrierWriteWithoutTransaction(_:)-5u7gc``. See
|
|
||||||
/// <doc:SwiftConcurrency#Shorthand-Closure-Notation> for more information.
|
|
||||||
///
|
|
||||||
/// - parameter updates: A function which accesses the database.
|
|
||||||
/// - throws: Any ``DatabaseError`` that happens while establishing the
|
|
||||||
/// database access, or the error thrown by `updates`, or
|
|
||||||
/// `CancellationError` if the task is cancelled.
|
|
||||||
@_disfavoredOverload
|
|
||||||
public func barrierWriteWithoutTransaction<T: Sendable>(
|
|
||||||
_ updates: @Sendable (Database) throws -> T
|
|
||||||
) async throws -> T {
|
|
||||||
try await barrierWriteWithoutTransaction { db in try updates(db) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Erase the database: delete all content, drop all tables, etc.
|
/// Erase the database: delete all content, drop all tables, etc.
|
||||||
@@ -717,6 +666,7 @@ extension DatabaseWriter {
|
|||||||
try await writeWithoutTransaction { try $0.execute(sql: "VACUUM") }
|
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
|
/// Creates a new database file at the specified path with a minimum
|
||||||
/// amount of disk space.
|
/// amount of disk space.
|
||||||
///
|
///
|
||||||
@@ -731,6 +681,19 @@ extension DatabaseWriter {
|
|||||||
try $0.execute(sql: "VACUUM INTO ?", arguments: [filePath])
|
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)
|
#if canImport(Combine)
|
||||||
@@ -773,22 +736,6 @@ extension DatabaseWriter {
|
|||||||
receiveOn scheduler: some Combine.Scheduler = DispatchQueue.main,
|
receiveOn scheduler: some Combine.Scheduler = DispatchQueue.main,
|
||||||
updates: @escaping @Sendable (Database) throws -> Output
|
updates: @escaping @Sendable (Database) throws -> Output
|
||||||
) -> DatabasePublishers.Write<Output> {
|
) -> DatabasePublishers.Write<Output> {
|
||||||
// `updates` is Sendable, and not `sending`, because `Output` is
|
|
||||||
// not `sending`: a `sending` closure could return a non-Sendable
|
|
||||||
// value it has captured. Such a value would be published to all
|
|
||||||
// subscriptions, and race with the next execution of `updates` on
|
|
||||||
// the writer dispatch queue.
|
|
||||||
//
|
|
||||||
// `Output` is not `sending` because otherwise users could not
|
|
||||||
// publish non-Sendable records fetched from the database (region
|
|
||||||
// isolation ties them to the `db` argument).
|
|
||||||
//
|
|
||||||
// The price is a possible data race when `updates` returns a
|
|
||||||
// non-Sendable value that the database connection keeps alive
|
|
||||||
// across calls, such as a cached statement: a subscriber could
|
|
||||||
// use it while another subscription executes `updates`. This never
|
|
||||||
// happens in practice, because people do not publish values that
|
|
||||||
// contain the database instance.
|
|
||||||
OnDemandFuture { fulfill in
|
OnDemandFuture { fulfill in
|
||||||
self.asyncWrite(updates, completion: { _, result in
|
self.asyncWrite(updates, completion: { _, result in
|
||||||
fulfill(result)
|
fulfill(result)
|
||||||
@@ -848,29 +795,25 @@ extension DatabaseWriter {
|
|||||||
/// - parameter scheduler: A Combine Scheduler.
|
/// - parameter scheduler: A Combine Scheduler.
|
||||||
/// - parameter updates: A closure which writes in the database.
|
/// - parameter updates: A closure which writes in the database.
|
||||||
/// - parameter value: A closure which reads from the database.
|
/// - parameter value: A closure which reads from the database.
|
||||||
public func writePublisher<T, Output>(
|
public func writePublisher<T: Sendable, Output>(
|
||||||
receiveOn scheduler: some Combine.Scheduler = DispatchQueue.main,
|
receiveOn scheduler: some Combine.Scheduler = DispatchQueue.main,
|
||||||
updates: sending @escaping (Database) throws -> sending T,
|
updates: @escaping @Sendable (Database) throws -> T,
|
||||||
thenRead value: @escaping @Sendable (Database, T) throws -> Output
|
thenRead value: @escaping @Sendable (Database, T) throws -> Output
|
||||||
) -> DatabasePublishers.Write<Output> {
|
) -> DatabasePublishers.Write<Output> {
|
||||||
// Safe because `updates` is sending, and only called from the
|
OnDemandFuture { fulfill in
|
||||||
// writer dispatch queue (once per subscription, serially).
|
|
||||||
nonisolated(unsafe) let updates = updates
|
|
||||||
return OnDemandFuture { fulfill in
|
|
||||||
self.asyncWriteWithoutTransaction { db in
|
self.asyncWriteWithoutTransaction { db in
|
||||||
var result = Disconnected<T?>(nil)
|
var updatesValue: T?
|
||||||
do {
|
do {
|
||||||
try db.inTransaction {
|
try db.inTransaction {
|
||||||
try result.exchange(newValue: updates(db))
|
updatesValue = try updates(db)
|
||||||
return .commit
|
return .commit
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
fulfill(.failure(error))
|
fulfill(.failure(error))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let updatesValue = result.consume()!
|
self.spawnConcurrentRead { [updatesValue] dbResult in
|
||||||
self.spawnConcurrentRead { dbResult in
|
fulfill(dbResult.flatMap { db in Result { try value(db, updatesValue!) } })
|
||||||
fulfill(dbResult.flatMap { db in Result { try value(db, updatesValue) } })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -937,34 +880,36 @@ extension AnyDatabaseWriter: DatabaseReader {
|
|||||||
base.interrupt()
|
base.interrupt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func read<T>(_ value: (Database) throws -> T) throws -> T {
|
public func read<T>(_ value: (Database) throws -> T) throws -> T {
|
||||||
try base.read(value)
|
try base.read(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func read<T>(
|
public func read<T: Sendable>(
|
||||||
_ value: sending (Database) throws -> sending T
|
_ value: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
try await base.read(value)
|
try await base.read(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func asyncRead(
|
public func asyncRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
base.asyncRead(value)
|
base.asyncRead(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T {
|
public func unsafeRead<T>(_ value: (Database) throws -> T) throws -> T {
|
||||||
try base.unsafeRead(value)
|
try base.unsafeRead(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func unsafeRead<T>(
|
public func unsafeRead<T: Sendable>(
|
||||||
_ value: sending (Database) throws -> sending T
|
_ value: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
try await base.unsafeRead(value)
|
try await base.unsafeRead(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func asyncUnsafeRead(
|
public func asyncUnsafeRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
base.asyncUnsafeRead(value)
|
base.asyncUnsafeRead(value)
|
||||||
}
|
}
|
||||||
@@ -975,45 +920,47 @@ extension AnyDatabaseWriter: DatabaseReader {
|
|||||||
|
|
||||||
public func _add<Reducer: ValueReducer>(
|
public func _add<Reducer: ValueReducer>(
|
||||||
observation: ValueObservation<Reducer>,
|
observation: ValueObservation<Reducer>,
|
||||||
scheduler: some ValueObservationScheduler,
|
scheduling scheduler: some ValueObservationScheduler,
|
||||||
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
onChange: @escaping @Sendable (Reducer.Value) -> Void
|
||||||
) -> AnyDatabaseCancellable {
|
) -> AnyDatabaseCancellable {
|
||||||
base._add(
|
base._add(
|
||||||
observation: observation,
|
observation: observation,
|
||||||
scheduler: scheduler,
|
scheduling: scheduler,
|
||||||
onChange: onChange)
|
onChange: onChange)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension AnyDatabaseWriter: DatabaseWriter {
|
extension AnyDatabaseWriter: DatabaseWriter {
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T {
|
public func writeWithoutTransaction<T>(_ updates: (Database) throws -> T) rethrows -> T {
|
||||||
try base.writeWithoutTransaction(updates)
|
try base.writeWithoutTransaction(updates)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func writeWithoutTransaction<T>(
|
public func writeWithoutTransaction<T: Sendable>(
|
||||||
_ updates: sending (Database) throws -> sending T
|
_ updates: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
try await base.writeWithoutTransaction(updates)
|
try await base.writeWithoutTransaction(updates)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@_disfavoredOverload // SR-15150 Async overloading in protocol implementation fails
|
||||||
public func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) throws -> T {
|
public func barrierWriteWithoutTransaction<T>(_ updates: (Database) throws -> T) throws -> T {
|
||||||
try base.barrierWriteWithoutTransaction(updates)
|
try base.barrierWriteWithoutTransaction(updates)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func barrierWriteWithoutTransaction<T>(
|
public func barrierWriteWithoutTransaction<T: Sendable>(
|
||||||
_ updates: sending (Database) throws -> sending T
|
_ updates: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
try await base.barrierWriteWithoutTransaction(updates)
|
try await base.barrierWriteWithoutTransaction(updates)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func asyncBarrierWriteWithoutTransaction(
|
public func asyncBarrierWriteWithoutTransaction(
|
||||||
_ updates: sending @escaping (Result<Database, Error>) -> Void
|
_ updates: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
base.asyncBarrierWriteWithoutTransaction(updates)
|
base.asyncBarrierWriteWithoutTransaction(updates)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func asyncWriteWithoutTransaction(
|
public func asyncWriteWithoutTransaction(
|
||||||
_ updates: sending @escaping (Database) -> Void
|
_ updates: @escaping @Sendable (Database) -> Void
|
||||||
) {
|
) {
|
||||||
base.asyncWriteWithoutTransaction(updates)
|
base.asyncWriteWithoutTransaction(updates)
|
||||||
}
|
}
|
||||||
@@ -1023,7 +970,7 @@ extension AnyDatabaseWriter: DatabaseWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func spawnConcurrentRead(
|
public func spawnConcurrentRead(
|
||||||
_ value: sending @escaping (Result<Database, Error>) -> Void
|
_ value: @escaping @Sendable (Result<Database, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
base.spawnConcurrentRead(value)
|
base.spawnConcurrentRead(value)
|
||||||
}
|
}
|
||||||
@@ -19,24 +19,9 @@ actor DispatchQueueActor {
|
|||||||
executor.asUnownedSerialExecutor()
|
executor.asUnownedSerialExecutor()
|
||||||
}
|
}
|
||||||
|
|
||||||
func execute<T>(_ work: () throws -> sending T) rethrows -> sending T {
|
func execute<T>(_ work: () throws -> T) rethrows -> T {
|
||||||
try work()
|
try work()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Executes `work`, and calls `onCancel` if the current task is
|
|
||||||
/// cancelled during its execution.
|
|
||||||
func execute<T>(
|
|
||||||
_ work: () throws -> sending T,
|
|
||||||
onCancel: sending () -> Void
|
|
||||||
) async rethrows -> sending T {
|
|
||||||
var result = Disconnected<T?>(nil)
|
|
||||||
try await withTaskCancellationHandler {
|
|
||||||
_ = try result.exchange(newValue: work())
|
|
||||||
} onCancel: {
|
|
||||||
onCancel()
|
|
||||||
}
|
|
||||||
return result.consume()!
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class DispatchQueueExecutor: SerialExecutor {
|
private final class DispatchQueueExecutor: SerialExecutor {
|
||||||
File renamed without changes.
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
@@ -60,6 +58,7 @@ import Foundation
|
|||||||
/// - ``decode(_:atIndex:)-33ykh``
|
/// - ``decode(_:atIndex:)-33ykh``
|
||||||
/// - ``decode(_:atIndex:)-3btwn``
|
/// - ``decode(_:atIndex:)-3btwn``
|
||||||
/// - ``withUnsafeData(atIndex:_:)``
|
/// - ``withUnsafeData(atIndex:_:)``
|
||||||
|
/// - ``dataNoCopy(atIndex:)``
|
||||||
///
|
///
|
||||||
/// ### Accessing Row Values by Column Name
|
/// ### Accessing Row Values by Column Name
|
||||||
///
|
///
|
||||||
@@ -70,6 +69,7 @@ import Foundation
|
|||||||
/// - ``decode(_:forColumn:)-4i1o4``
|
/// - ``decode(_:forColumn:)-4i1o4``
|
||||||
/// - ``decode(_:forColumn:)-4rhs4``
|
/// - ``decode(_:forColumn:)-4rhs4``
|
||||||
/// - ``withUnsafeData(named:_:)``
|
/// - ``withUnsafeData(named:_:)``
|
||||||
|
/// - ``dataNoCopy(named:)``
|
||||||
///
|
///
|
||||||
/// ### Accessing Row Values by Column
|
/// ### Accessing Row Values by Column
|
||||||
///
|
///
|
||||||
@@ -80,6 +80,7 @@ import Foundation
|
|||||||
/// - ``decode(_:forColumn:)-1ljuo``
|
/// - ``decode(_:forColumn:)-1ljuo``
|
||||||
/// - ``decode(_:forColumn:)-47qeg``
|
/// - ``decode(_:forColumn:)-47qeg``
|
||||||
/// - ``withUnsafeData(at:_:)``
|
/// - ``withUnsafeData(at:_:)``
|
||||||
|
/// - ``dataNoCopy(_:)``
|
||||||
///
|
///
|
||||||
/// ### Row Scopes & Associated Rows
|
/// ### Row Scopes & Associated Rows
|
||||||
///
|
///
|
||||||
@@ -320,8 +321,8 @@ extension Row {
|
|||||||
// MARK: - Extracting Values
|
// MARK: - Extracting Values
|
||||||
|
|
||||||
/// Fatal errors if index is out of bounds
|
/// Fatal errors if index is out of bounds
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@usableFromInline
|
||||||
/* private */ func _checkIndex(_ index: Int, file: StaticString = #file, line: UInt = #line) {
|
/* 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)
|
GRDBPrecondition(index >= 0 && index < count, "row index out of range", file: file, line: line)
|
||||||
}
|
}
|
||||||
@@ -424,7 +425,7 @@ extension Row {
|
|||||||
/// let row = try Row.fetchOne(db, sql: "SELECT NULL")!
|
/// let row = try Row.fetchOne(db, sql: "SELECT NULL")!
|
||||||
/// let name: String? = row[0] // nil
|
/// let name: String? = row[0] // nil
|
||||||
/// ```
|
/// ```
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public subscript<Value: DatabaseValueConvertible & StatementColumnConvertible>(_ index: Int) -> Value {
|
public subscript<Value: DatabaseValueConvertible & StatementColumnConvertible>(_ index: Int) -> Value {
|
||||||
try! decode(Value.self, atIndex: index)
|
try! decode(Value.self, atIndex: index)
|
||||||
@@ -653,6 +654,56 @@ extension Row {
|
|||||||
try withUnsafeData(named: column.name, body)
|
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.
|
/// Returns the first non-null value, if any. Identical to SQL `COALESCE` function.
|
||||||
///
|
///
|
||||||
/// For example:
|
/// For example:
|
||||||
@@ -1202,7 +1253,7 @@ extension Row {
|
|||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// - throws: Any error that happens during the decoding.
|
/// - throws: Any error that happens during the decoding.
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public func decode<Value: DatabaseValueConvertible & StatementColumnConvertible>(
|
public func decode<Value: DatabaseValueConvertible & StatementColumnConvertible>(
|
||||||
_ type: Value.Type = Value.self,
|
_ type: Value.Type = Value.self,
|
||||||
@@ -2356,6 +2407,9 @@ extension Row: ExpressibleByDictionaryLiteral {
|
|||||||
|
|
||||||
// MARK: - Index
|
// MARK: - Index
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed: "Row.Index")
|
||||||
|
typealias RowIndex = Row.Index
|
||||||
|
|
||||||
extension Row {
|
extension Row {
|
||||||
/// An index to a (column, value) pair in a ``Row``.
|
/// An index to a (column, value) pair in a ``Row``.
|
||||||
public struct Index: Sendable {
|
public struct Index: Sendable {
|
||||||
File renamed without changes.
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// A key that is used to decode a value in a row
|
/// A key that is used to decode a value in a row
|
||||||
File renamed without changes.
File renamed without changes.
@@ -45,21 +45,33 @@
|
|||||||
/// - ``init(sql:arguments:adapter:cached:)-3qq8t``
|
/// - ``init(sql:arguments:adapter:cached:)-3qq8t``
|
||||||
/// - ``init(sql:arguments:adapter:cached:)-5ecx2``
|
/// - ``init(sql:arguments:adapter:cached:)-5ecx2``
|
||||||
public struct SQLRequest<RowDecoder> {
|
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.
|
/// The row adapter.
|
||||||
public var adapter: (any RowAdapter)?
|
public var adapter: (any RowAdapter)?
|
||||||
|
|
||||||
private(set) var sqlLiteral: SQL
|
private(set) var sqlLiteral: SQL
|
||||||
let cached: Bool
|
let cache: Cache?
|
||||||
|
|
||||||
private init(
|
private init(
|
||||||
literal sqlLiteral: SQL,
|
literal sqlLiteral: SQL,
|
||||||
adapter: (any RowAdapter)?,
|
adapter: (any RowAdapter)?,
|
||||||
cached: Bool,
|
fromCache cache: Cache?,
|
||||||
type: RowDecoder.Type)
|
type: RowDecoder.Type)
|
||||||
{
|
{
|
||||||
self.sqlLiteral = sqlLiteral
|
self.sqlLiteral = sqlLiteral
|
||||||
self.adapter = adapter
|
self.adapter = adapter
|
||||||
self.cached = cached
|
self.cache = cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +102,7 @@ extension SQLRequest {
|
|||||||
self.init(
|
self.init(
|
||||||
literal: SQL(sql: sql, arguments: arguments),
|
literal: SQL(sql: sql, arguments: arguments),
|
||||||
adapter: adapter,
|
adapter: adapter,
|
||||||
cached: cached,
|
fromCache: cached ? .public : nil,
|
||||||
type: RowDecoder.self)
|
type: RowDecoder.self)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +127,7 @@ extension SQLRequest {
|
|||||||
self.init(
|
self.init(
|
||||||
literal: sqlLiteral,
|
literal: sqlLiteral,
|
||||||
adapter: adapter,
|
adapter: adapter,
|
||||||
cached: cached,
|
fromCache: cached ? .public : nil,
|
||||||
type: RowDecoder.self)
|
type: RowDecoder.self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,7 +156,7 @@ extension SQLRequest<Row> {
|
|||||||
self.init(
|
self.init(
|
||||||
literal: SQL(sql: sql, arguments: arguments),
|
literal: SQL(sql: sql, arguments: arguments),
|
||||||
adapter: adapter,
|
adapter: adapter,
|
||||||
cached: cached,
|
fromCache: cached ? .public : nil,
|
||||||
type: Row.self)
|
type: Row.self)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +181,7 @@ extension SQLRequest<Row> {
|
|||||||
self.init(
|
self.init(
|
||||||
literal: sqlLiteral,
|
literal: sqlLiteral,
|
||||||
adapter: adapter,
|
adapter: adapter,
|
||||||
cached: cached,
|
fromCache: cached ? .public : nil,
|
||||||
type: Row.self)
|
type: Row.self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,9 +202,15 @@ extension SQLRequest: FetchRequest {
|
|||||||
{
|
{
|
||||||
let context = SQLGenerationContext(db)
|
let context = SQLGenerationContext(db)
|
||||||
let sql = try sqlLiteral.sql(context)
|
let sql = try sqlLiteral.sql(context)
|
||||||
let statement = try cached
|
let statement: Statement
|
||||||
? db.cachedStatement(sql: sql)
|
switch cache {
|
||||||
: db.makeStatement(sql: sql)
|
case .none:
|
||||||
|
statement = try db.makeStatement(sql: sql)
|
||||||
|
case .public:
|
||||||
|
statement = try db.cachedStatement(sql: sql)
|
||||||
|
case .internal:
|
||||||
|
statement = try db.internalCachedStatement(sql: sql)
|
||||||
|
}
|
||||||
try statement.setArguments(context.arguments)
|
try statement.setArguments(context.arguments)
|
||||||
return PreparedRequest(statement: statement, adapter: adapter)
|
return PreparedRequest(statement: statement, adapter: adapter)
|
||||||
}
|
}
|
||||||
File renamed without changes.
@@ -228,10 +228,7 @@ final class SerializedDatabase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Schedules database operations for execution, and returns immediately.
|
/// Schedules database operations for execution, and returns immediately.
|
||||||
func async(_ block: sending @escaping (Database) -> Void) {
|
func async(_ block: @escaping @Sendable (Database) -> Void) {
|
||||||
// The block is `sending`, and executed only once: it is safe to
|
|
||||||
// execute it on the database dispatch queue.
|
|
||||||
nonisolated(unsafe) let block = block
|
|
||||||
queue.async {
|
queue.async {
|
||||||
block(self.db)
|
block(self.db)
|
||||||
self.preconditionNoUnsafeTransactionLeft(self.db)
|
self.preconditionNoUnsafeTransactionLeft(self.db)
|
||||||
@@ -252,19 +249,21 @@ final class SerializedDatabase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Asynchronously executes the block.
|
/// Asynchronously executes the block.
|
||||||
func execute<T>(
|
func execute<T: Sendable>(
|
||||||
_ block: sending (Database) throws -> sending T
|
_ block: @Sendable (Database) throws -> T
|
||||||
) async throws -> sending T {
|
) async throws -> T {
|
||||||
let cancelMutex = Mutex<(@Sendable () -> Void)?>(nil)
|
let cancelMutex = Mutex<(@Sendable () -> Void)?>(nil)
|
||||||
return try await actor.execute {
|
return try await withTaskCancellationHandler {
|
||||||
defer {
|
try await actor.execute {
|
||||||
cancelMutex.store(nil)
|
defer {
|
||||||
db.uncancel()
|
cancelMutex.store(nil)
|
||||||
preconditionNoUnsafeTransactionLeft(db)
|
db.uncancel()
|
||||||
|
preconditionNoUnsafeTransactionLeft(db)
|
||||||
|
}
|
||||||
|
cancelMutex.store(db.cancel)
|
||||||
|
try Task.checkCancellation()
|
||||||
|
return try block(db)
|
||||||
}
|
}
|
||||||
cancelMutex.store(db.cancel)
|
|
||||||
try Task.checkCancellation()
|
|
||||||
return try block(db)
|
|
||||||
} onCancel: {
|
} onCancel: {
|
||||||
cancelMutex.withLock { $0?() }
|
cancelMutex.withLock { $0?() }
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
@@ -165,8 +163,8 @@ public final class Statement {
|
|||||||
/// containing SQL.
|
/// containing SQL.
|
||||||
/// - parameter statementEnd: Upon success, the pointer to the next
|
/// - parameter statementEnd: Upon success, the pointer to the next
|
||||||
/// statement in the C string.
|
/// statement in the C string.
|
||||||
/// - parameter prepFlags: Flags for `sqlite3_prepare_v3` see
|
/// - parameter prepFlags: Flags for sqlite3_prepare_v3 (available from
|
||||||
/// <http://www.sqlite.org/c3ref/prepare.html>.
|
/// SQLite 3.20.0, see <http://www.sqlite.org/c3ref/prepare.html>)
|
||||||
/// - throws: DatabaseError in case of compilation error.
|
/// - throws: DatabaseError in case of compilation error.
|
||||||
required init?(
|
required init?(
|
||||||
database: Database,
|
database: Database,
|
||||||
@@ -467,20 +465,6 @@ 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
|
// MARK: Execution
|
||||||
|
|
||||||
func reset() throws {
|
func reset() throws {
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if canImport(string_h)
|
#if canImport(string_h)
|
||||||
@@ -215,7 +213,7 @@ final class StatementAuthorizer {
|
|||||||
|
|
||||||
private func insertUpdateEventKind(tableName: String, columnName: String) {
|
private func insertUpdateEventKind(tableName: String, columnName: String) {
|
||||||
for (index, eventKind) in databaseEventKinds.enumerated() {
|
for (index, eventKind) in databaseEventKinds.enumerated() {
|
||||||
if case let .update(t, columnNames) = eventKind, t == tableName {
|
if case .update(let t, let columnNames) = eventKind, t == tableName {
|
||||||
var columnNames = columnNames
|
var columnNames = columnNames
|
||||||
columnNames.insert(columnName)
|
columnNames.insert(columnName)
|
||||||
databaseEventKinds[index] = .update(tableName: tableName, columnNames: columnNames)
|
databaseEventKinds[index] = .update(tableName: tableName, columnNames: columnNames)
|
||||||
+11
-13
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// A type that can decode itself from the low-level C interface to
|
/// A type that can decode itself from the low-level C interface to
|
||||||
@@ -128,7 +126,7 @@ public protocol StatementColumnConvertible {
|
|||||||
extension StatementColumnConvertible {
|
extension StatementColumnConvertible {
|
||||||
// `Optional` overrides this default behavior.
|
// `Optional` overrides this default behavior.
|
||||||
/// Default implementation fails on decoding NULL.
|
/// Default implementation fails on decoding NULL.
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public static func fromStatement(_ sqliteStatement: SQLiteStatement, atUncheckedIndex index: CInt) -> Self? {
|
public static func fromStatement(_ sqliteStatement: SQLiteStatement, atUncheckedIndex index: CInt) -> Self? {
|
||||||
if sqlite3_column_type(sqliteStatement, index) == SQLITE_NULL {
|
if sqlite3_column_type(sqliteStatement, index) == SQLITE_NULL {
|
||||||
@@ -155,7 +153,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
|
|||||||
context: context())
|
context: context())
|
||||||
}
|
}
|
||||||
|
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
static func fastDecode(
|
static func fastDecode(
|
||||||
fromRow row: Row,
|
fromRow row: Row,
|
||||||
@@ -172,7 +170,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
|
|||||||
return try row.fastDecode(Self.self, atUncheckedIndex: index)
|
return try row.fastDecode(Self.self, atUncheckedIndex: index)
|
||||||
}
|
}
|
||||||
|
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
static func fastDecode(
|
static func fastDecode(
|
||||||
fromStatement sqliteStatement: SQLiteStatement,
|
fromStatement sqliteStatement: SQLiteStatement,
|
||||||
@@ -188,7 +186,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Support for Decodable
|
// Support for Decodable
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
static func fastDecodeIfPresent(
|
static func fastDecodeIfPresent(
|
||||||
fromRow row: Row,
|
fromRow row: Row,
|
||||||
File renamed without changes.
+7
-9
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
+8
-10
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
@@ -81,7 +79,7 @@ extension DatabaseDateComponents: StatementColumnConvertible {
|
|||||||
/// - parameters:
|
/// - parameters:
|
||||||
/// - sqliteStatement: A pointer to an SQLite statement.
|
/// - sqliteStatement: A pointer to an SQLite statement.
|
||||||
/// - index: The column index.
|
/// - index: The column index.
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
||||||
guard let cString = sqlite3_column_text(sqliteStatement, index) else {
|
guard let cString = sqlite3_column_text(sqliteStatement, index) else {
|
||||||
File renamed without changes.
+8
-10
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
@@ -134,7 +132,7 @@ extension Date: StatementColumnConvertible {
|
|||||||
/// - parameters:
|
/// - parameters:
|
||||||
/// - sqliteStatement: A pointer to an SQLite statement.
|
/// - sqliteStatement: A pointer to an SQLite statement.
|
||||||
/// - index: The column index.
|
/// - index: The column index.
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
||||||
switch sqlite3_column_type(sqliteStatement, index) {
|
switch sqlite3_column_type(sqliteStatement, index) {
|
||||||
+8
-10
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
@@ -49,7 +47,7 @@ extension Decimal: DatabaseValueConvertible {
|
|||||||
|
|
||||||
/// Decimal adopts StatementColumnConvertible
|
/// Decimal adopts StatementColumnConvertible
|
||||||
extension Decimal: StatementColumnConvertible {
|
extension Decimal: StatementColumnConvertible {
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
||||||
switch sqlite3_column_type(sqliteStatement, index) {
|
switch sqlite3_column_type(sqliteStatement, index) {
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+8
-10
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
@@ -86,7 +84,7 @@ extension UUID: DatabaseValueConvertible {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension UUID: StatementColumnConvertible {
|
extension UUID: StatementColumnConvertible {
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
||||||
switch sqlite3_column_type(sqliteStatement, index) {
|
switch sqlite3_column_type(sqliteStatement, index) {
|
||||||
File renamed without changes.
File renamed without changes.
+1
-1
@@ -39,7 +39,7 @@ extension StatementBinding where Self: RawRepresentable, Self.RawValue: Statemen
|
|||||||
/// // adopt StatementColumnConvertible:
|
/// // adopt StatementColumnConvertible:
|
||||||
/// extension Color: StatementColumnConvertible { }
|
/// extension Color: StatementColumnConvertible { }
|
||||||
extension StatementColumnConvertible where Self: RawRepresentable, Self.RawValue: StatementColumnConvertible {
|
extension StatementColumnConvertible where Self: RawRepresentable, Self.RawValue: StatementColumnConvertible {
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
||||||
guard let rawValue = RawValue(sqliteStatement: sqliteStatement, index: index) else {
|
guard let rawValue = RawValue(sqliteStatement: sqliteStatement, index: index) else {
|
||||||
File renamed without changes.
+8
-10
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extension Optional: StatementBinding where Wrapped: StatementBinding {
|
extension Optional: StatementBinding where Wrapped: StatementBinding {
|
||||||
@@ -87,7 +85,7 @@ extension Optional: DatabaseValueConvertible where Wrapped: DatabaseValueConvert
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension Optional: StatementColumnConvertible where Wrapped: StatementColumnConvertible {
|
extension Optional: StatementColumnConvertible where Wrapped: StatementColumnConvertible {
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public static func fromStatement(_ sqliteStatement: SQLiteStatement, atUncheckedIndex index: CInt) -> Self? {
|
public static func fromStatement(_ sqliteStatement: SQLiteStatement, atUncheckedIndex index: CInt) -> Self? {
|
||||||
if let value = Wrapped.fromStatement(sqliteStatement, atUncheckedIndex: index) {
|
if let value = Wrapped.fromStatement(sqliteStatement, atUncheckedIndex: index) {
|
||||||
+16
-18
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
@@ -119,7 +117,7 @@ extension Int: DatabaseValueConvertible, StatementColumnConvertible {
|
|||||||
/// - parameters:
|
/// - parameters:
|
||||||
/// - sqliteStatement: A pointer to an SQLite statement.
|
/// - sqliteStatement: A pointer to an SQLite statement.
|
||||||
/// - index: The column index.
|
/// - index: The column index.
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
||||||
let int64 = sqlite3_column_int64(sqliteStatement, index)
|
let int64 = sqlite3_column_int64(sqliteStatement, index)
|
||||||
@@ -158,7 +156,7 @@ extension Int8: DatabaseValueConvertible, StatementColumnConvertible {
|
|||||||
/// - parameters:
|
/// - parameters:
|
||||||
/// - sqliteStatement: A pointer to an SQLite statement.
|
/// - sqliteStatement: A pointer to an SQLite statement.
|
||||||
/// - index: The column index.
|
/// - index: The column index.
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
||||||
let int64 = sqlite3_column_int64(sqliteStatement, index)
|
let int64 = sqlite3_column_int64(sqliteStatement, index)
|
||||||
@@ -197,7 +195,7 @@ extension Int16: DatabaseValueConvertible, StatementColumnConvertible {
|
|||||||
/// - parameters:
|
/// - parameters:
|
||||||
/// - sqliteStatement: A pointer to an SQLite statement.
|
/// - sqliteStatement: A pointer to an SQLite statement.
|
||||||
/// - index: The column index.
|
/// - index: The column index.
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
||||||
let int64 = sqlite3_column_int64(sqliteStatement, index)
|
let int64 = sqlite3_column_int64(sqliteStatement, index)
|
||||||
@@ -236,7 +234,7 @@ extension Int32: DatabaseValueConvertible, StatementColumnConvertible {
|
|||||||
/// - parameters:
|
/// - parameters:
|
||||||
/// - sqliteStatement: A pointer to an SQLite statement.
|
/// - sqliteStatement: A pointer to an SQLite statement.
|
||||||
/// - index: The column index.
|
/// - index: The column index.
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
||||||
let int64 = sqlite3_column_int64(sqliteStatement, index)
|
let int64 = sqlite3_column_int64(sqliteStatement, index)
|
||||||
@@ -318,7 +316,7 @@ extension UInt: DatabaseValueConvertible, StatementColumnConvertible {
|
|||||||
/// - parameters:
|
/// - parameters:
|
||||||
/// - sqliteStatement: A pointer to an SQLite statement.
|
/// - sqliteStatement: A pointer to an SQLite statement.
|
||||||
/// - index: The column index.
|
/// - index: The column index.
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
||||||
let int64 = sqlite3_column_int64(sqliteStatement, index)
|
let int64 = sqlite3_column_int64(sqliteStatement, index)
|
||||||
@@ -357,7 +355,7 @@ extension UInt8: DatabaseValueConvertible, StatementColumnConvertible {
|
|||||||
/// - parameters:
|
/// - parameters:
|
||||||
/// - sqliteStatement: A pointer to an SQLite statement.
|
/// - sqliteStatement: A pointer to an SQLite statement.
|
||||||
/// - index: The column index.
|
/// - index: The column index.
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
||||||
let int64 = sqlite3_column_int64(sqliteStatement, index)
|
let int64 = sqlite3_column_int64(sqliteStatement, index)
|
||||||
@@ -396,7 +394,7 @@ extension UInt16: DatabaseValueConvertible, StatementColumnConvertible {
|
|||||||
/// - parameters:
|
/// - parameters:
|
||||||
/// - sqliteStatement: A pointer to an SQLite statement.
|
/// - sqliteStatement: A pointer to an SQLite statement.
|
||||||
/// - index: The column index.
|
/// - index: The column index.
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
||||||
let int64 = sqlite3_column_int64(sqliteStatement, index)
|
let int64 = sqlite3_column_int64(sqliteStatement, index)
|
||||||
@@ -435,7 +433,7 @@ extension UInt32: DatabaseValueConvertible, StatementColumnConvertible {
|
|||||||
/// - parameters:
|
/// - parameters:
|
||||||
/// - sqliteStatement: A pointer to an SQLite statement.
|
/// - sqliteStatement: A pointer to an SQLite statement.
|
||||||
/// - index: The column index.
|
/// - index: The column index.
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
||||||
let int64 = sqlite3_column_int64(sqliteStatement, index)
|
let int64 = sqlite3_column_int64(sqliteStatement, index)
|
||||||
@@ -474,7 +472,7 @@ extension UInt64: DatabaseValueConvertible, StatementColumnConvertible {
|
|||||||
/// - parameters:
|
/// - parameters:
|
||||||
/// - sqliteStatement: A pointer to an SQLite statement.
|
/// - sqliteStatement: A pointer to an SQLite statement.
|
||||||
/// - index: The column index.
|
/// - index: The column index.
|
||||||
@inline(always)
|
@inline(__always)
|
||||||
@inlinable
|
@inlinable
|
||||||
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
public init?(sqliteStatement: SQLiteStatement, index: CInt) {
|
||||||
let int64 = sqlite3_column_int64(sqliteStatement, index)
|
let int64 = sqlite3_column_int64(sqliteStatement, index)
|
||||||
File renamed without changes.
@@ -1,15 +1,13 @@
|
|||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extension Database {
|
extension Database {
|
||||||
@@ -43,7 +41,8 @@ extension Database {
|
|||||||
|
|
||||||
// Drop cached statements that delete, because the addition of an
|
// Drop cached statements that delete, because the addition of an
|
||||||
// observer may change the need for truncate optimization prevention.
|
// observer may change the need for truncate optimization prevention.
|
||||||
statementCache.removeAll { $0.canDeleteRows }
|
publicStatementCache.removeAll { $0.canDeleteRows }
|
||||||
|
internalStatementCache.removeAll { $0.canDeleteRows }
|
||||||
|
|
||||||
observationBroker.add(transactionObserver: transactionObserver, extent: extent)
|
observationBroker.add(transactionObserver: transactionObserver, extent: extent)
|
||||||
}
|
}
|
||||||
@@ -64,7 +63,8 @@ extension Database {
|
|||||||
|
|
||||||
// Drop cached statements that delete, because the removal of an
|
// Drop cached statements that delete, because the removal of an
|
||||||
// observer may change the need for truncate optimization prevention.
|
// observer may change the need for truncate optimization prevention.
|
||||||
statementCache.removeAll { $0.canDeleteRows }
|
publicStatementCache.removeAll { $0.canDeleteRows }
|
||||||
|
internalStatementCache.removeAll { $0.canDeleteRows }
|
||||||
|
|
||||||
observationBroker.remove(transactionObserver: transactionObserver)
|
observationBroker.remove(transactionObserver: transactionObserver)
|
||||||
}
|
}
|
||||||
@@ -113,16 +113,16 @@ extension Database {
|
|||||||
/// - parameter onCommit: A closure executed on transaction commit.
|
/// - parameter onCommit: A closure executed on transaction commit.
|
||||||
/// - parameter onRollback: A closure executed on transaction rollback.
|
/// - parameter onRollback: A closure executed on transaction rollback.
|
||||||
public func afterNextTransaction(
|
public func afterNextTransaction(
|
||||||
onCommit: sending @escaping (Database) -> Void,
|
onCommit: @escaping @Sendable (Database) -> Void,
|
||||||
onRollback: sending @escaping (Database) -> Void = { _ in })
|
onRollback: @escaping @Sendable (Database) -> Void = { _ in })
|
||||||
{
|
{
|
||||||
class TransactionHandler: TransactionObserver {
|
class TransactionHandler: TransactionObserver {
|
||||||
let onCommit: (Database) -> Void
|
let onCommit: @Sendable (Database) -> Void
|
||||||
let onRollback: (Database) -> Void
|
let onRollback: @Sendable (Database) -> Void
|
||||||
|
|
||||||
init(
|
init(
|
||||||
onCommit: @escaping (Database) -> Void,
|
onCommit: @escaping @Sendable (Database) -> Void,
|
||||||
onRollback: @escaping (Database) -> Void
|
onRollback: @escaping @Sendable (Database) -> Void
|
||||||
) {
|
) {
|
||||||
self.onCommit = onCommit
|
self.onCommit = onCommit
|
||||||
self.onRollback = onRollback
|
self.onRollback = onRollback
|
||||||
@@ -1028,8 +1028,7 @@ final class TransactionObservation {
|
|||||||
guard let observer else {
|
guard let observer else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return !observer.databaseEventObservationStrategy.requiresDatabaseEventKind ||
|
return !observer.databaseEventObservationStrategy.requiresDatabaseEventKind || observer.observes(eventsOfKind: eventKind)
|
||||||
observer.observes(eventsOfKind: eventKind)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func statementObservation(for statement: Statement) -> StatementObservation? {
|
func statementObservation(for statement: Statement) -> StatementObservation? {
|
||||||
@@ -1,16 +1,14 @@
|
|||||||
#if SQLITE_ENABLE_SNAPSHOT && !SQLITE_DISABLE_SNAPSHOT
|
#if SQLITE_ENABLE_SNAPSHOT && !SQLITE_DISABLE_SNAPSHOT
|
||||||
// Import C SQLite functions
|
// Import C SQLite functions
|
||||||
#if GRDBFRAMEWORK // GRDB.xcodeproj
|
#if GRDBCIPHER // CocoaPods (SQLCipher subspec)
|
||||||
|
import SQLCipher
|
||||||
|
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
|
||||||
import SQLite3
|
import SQLite3
|
||||||
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
|
||||||
#else // SPM
|
#elseif SQLCipher
|
||||||
#if SQLCipher // Takes precedence over SystemSQLite
|
import SQLCipher
|
||||||
import SQLCipher
|
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
|
||||||
#elseif SystemSQLite
|
import GRDBSQLite
|
||||||
import GRDBSQLite
|
|
||||||
#else
|
|
||||||
#error("Enable a GRDB trait that provides SQLite.")
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// An instance of WALSnapshot records the state of a WAL mode database for some
|
/// An instance of WALSnapshot records the state of a WAL mode database for some
|
||||||
+1
-4
@@ -103,9 +103,7 @@ final class WALSnapshotTransaction: @unchecked Sendable {
|
|||||||
|
|
||||||
/// Schedules database operations for execution, and
|
/// Schedules database operations for execution, and
|
||||||
/// returns immediately.
|
/// returns immediately.
|
||||||
func asyncRead(_ value: sending @escaping (Result<Database, Error>) -> Void) {
|
func asyncRead(_ value: @escaping @Sendable (Result<Database, Error>) -> Void) {
|
||||||
// Safe because `value` is sending, and called only once.
|
|
||||||
nonisolated(unsafe) let value = value
|
|
||||||
databaseAccessMutex.withLock { databaseAccess in
|
databaseAccessMutex.withLock { databaseAccess in
|
||||||
guard let databaseAccess else {
|
guard let databaseAccess else {
|
||||||
value(.failure(DatabaseError.snapshotIsLost()))
|
value(.failure(DatabaseError.snapshotIsLost()))
|
||||||
@@ -117,7 +115,6 @@ final class WALSnapshotTransaction: @unchecked Sendable {
|
|||||||
// At least check if self was closed:
|
// At least check if self was closed:
|
||||||
if self.databaseAccessMutex.load() == nil {
|
if self.databaseAccessMutex.load() == nil {
|
||||||
value(.failure(DatabaseError.snapshotIsLost()))
|
value(.failure(DatabaseError.snapshotIsLost()))
|
||||||
return
|
|
||||||
}
|
}
|
||||||
value(.success(db))
|
value(.success(db))
|
||||||
}
|
}
|
||||||
+1
-1
@@ -97,7 +97,7 @@ try dbQueue.write { db in
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
See ``DatabaseReader/read(_:)-40k5v`` and ``DatabaseWriter/write(_:)-7mrav``.
|
See ``DatabaseReader/read(_:)-5mfwu`` and ``DatabaseWriter/write(_:)-4gnqx``.
|
||||||
|
|
||||||
Note the identical method names: `read`, `write`. The async version is only available in async Swift functions.
|
Note the identical method names: `read`, `write`. The async version is only available in async Swift functions.
|
||||||
|
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 617 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user