mirror of
https://github.com/groue/GRDB.swift
synced 2026-12-06 05:28:44 +00:00
Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c93ba4fba8 | ||
|
|
ec40855466 | ||
|
|
1cca3686f5 | ||
|
|
1e354ba79c | ||
|
|
0ea5471b56 | ||
|
|
b2e808b9e4 | ||
|
|
ac0c085a4a | ||
|
|
9f9f0d37dd | ||
|
|
898e7b6abe | ||
|
|
0fb599812f | ||
|
|
77a4d17940 | ||
|
|
c865a847fd | ||
|
|
832bc1aa74 | ||
|
|
910ca2d0ce | ||
|
|
3ecb5c5455 | ||
|
|
84d25dfc9d | ||
|
|
5664c5a829 | ||
|
|
334a63aa4a | ||
|
|
7e506f6488 | ||
|
|
5341f139e5 | ||
|
|
917b7ecc90 |
No files matched your search
+8
-2
@@ -7,7 +7,7 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception:
|
||||
|
||||
#### 7.x Releases
|
||||
|
||||
- `7.0.0` Betas - [7.0.0-beta](#700-beta) - [7.0.0-beta.2](#700-beta2) - [7.0.0-beta.3](#700-beta3) - [7.0.0-beta.4](#700-beta4) - [7.0.0-beta.5](#700-beta5)
|
||||
- `7.0.0` Betas - [7.0.0-beta](#700-beta) - [7.0.0-beta.2](#700-beta2) - [7.0.0-beta.3](#700-beta3) - [7.0.0-beta.4](#700-beta4) - [7.0.0-beta.5](#700-beta5) - [7.0.0-beta.6](#700-beta6)
|
||||
|
||||
#### 6.x Releases
|
||||
|
||||
@@ -131,6 +131,12 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception:
|
||||
|
||||
---
|
||||
|
||||
## 7.0.0-beta.6
|
||||
|
||||
Released October 13, 2024
|
||||
|
||||
- **New**: Bump custom SQLite builds to 3.46.1 by [@groue](https://github.com/groue) in [#1654](https://github.com/groue/GRDB.swift/pull/1654)
|
||||
|
||||
## 7.0.0-beta.5
|
||||
|
||||
Released October 13, 2024
|
||||
@@ -166,7 +172,7 @@ Released September 29, 2024
|
||||
|
||||
[Migrating From GRDB 6 to GRDB 7](Documentation/GRDB7MigrationGuide.md) describes in detail how to bump the GRDB version in your application.
|
||||
|
||||
The new [Swift Concurrency and GRDB](https://swiftpackageindex.com/groue/grdb.swift/v7.0.0-beta.5/documentation/grdb/swiftconcurrency) guide explains how to best integrate GRDB and Swift Concurrency.
|
||||
The new [Swift Concurrency and GRDB](https://swiftpackageindex.com/groue/grdb.swift/v7.0.0-beta.6/documentation/grdb/swiftconcurrency) guide explains how to best integrate GRDB and Swift Concurrency.
|
||||
|
||||
The [demo app](Documentation/DemoApps/) was rewritten from scratch in a brand new Xcode 16 project.
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ Custom SQLite Builds
|
||||
|
||||
By default, GRDB uses the version of SQLite that ships with the target operating system.
|
||||
|
||||
**You can build GRDB with a custom build of [SQLite 3.44.0](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](../../../#full-text-search), and [SQLite Pre-Update Hooks](https://swiftpackageindex.com/groue/grdb.swift/documentation/grdb/transactionobserver).
|
||||
|
||||
|
||||
@@ -67,18 +67,15 @@ extension AppDatabase {
|
||||
|
||||
/// Returns a database configuration suited for `AppDatabase`.
|
||||
///
|
||||
/// SQL statements are logged if the `SQL_TRACE` environment variable
|
||||
/// is set.
|
||||
///
|
||||
/// - parameter base: A base configuration.
|
||||
static func makeConfiguration(_ base: Configuration = Configuration()) -> Configuration {
|
||||
var config = base
|
||||
|
||||
/// - parameter config: A base configuration.
|
||||
static func makeConfiguration(_ config: Configuration = Configuration()) -> Configuration {
|
||||
// var config = config
|
||||
//
|
||||
// Add custom SQL functions or collations, if needed:
|
||||
// config.prepareDatabase { db in
|
||||
// db.add(function: ...)
|
||||
// }
|
||||
|
||||
//
|
||||
// Uncomment for enabling SQL logging if the `SQL_TRACE` environment variable is set.
|
||||
// See <https://swiftpackageindex.com/groue/grdb.swift/documentation/grdb/database/trace(options:_:)>
|
||||
// if ProcessInfo.processInfo.environment["SQL_TRACE"] != nil {
|
||||
|
||||
@@ -3,7 +3,7 @@ FTS5 Tokenizers
|
||||
|
||||
**[FTS5](https://www.sqlite.org/fts5.html) is an extensible full-text search engine.**
|
||||
|
||||
GRDB lets you define your own custom FST5 tokenizers, and extend SQLite built-in tokenizers. Possible use cases are:
|
||||
GRDB lets you define your own custom FTS5 tokenizers, and extend SQLite built-in tokenizers. Possible use cases are:
|
||||
|
||||
- Have "fi" match the ligature "fi" (U+FB01)
|
||||
- Have "first" match "1st"
|
||||
@@ -95,7 +95,7 @@ let documents = try Document.matching(pattern).fetchAll(db)
|
||||
|
||||
## FTS5Tokenizer
|
||||
|
||||
**FST5Tokenizer** is the protocol for all FTS5 tokenizers.
|
||||
**FTS5Tokenizer** is the protocol for all FTS5 tokenizers.
|
||||
|
||||
It only requires a tokenization method that matches the low-level `xTokenize` C function documented at https://www.sqlite.org/fts5.html#custom_tokenizers. We'll discuss it more when describing custom tokenizers.
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ Generally speaking, FTS5 is better than FTS4 which improves on FTS3. But this do
|
||||
|
||||
- **The location of the indexed text in your database schema.** Only FTS4 and FTS5 support "contentless" and "external content" tables.
|
||||
|
||||
- See [FST3 vs. FTS4](https://www.sqlite.org/fts3.html#differences_between_fts3_and_fts4) and [FTS5 vs. FTS3/4](https://www.sqlite.org/fts5.html#appendix_a) for more differences.
|
||||
- See [FTS3 vs. FTS4](https://www.sqlite.org/fts3.html#differences_between_fts3_and_fts4) and [FTS5 vs. FTS3/4](https://www.sqlite.org/fts5.html#appendix_a) for more differences.
|
||||
|
||||
> **Note**: In case you were still wondering, it is recommended to read the SQLite documentation: [FTS3 & FTS4](https://www.sqlite.org/fts3.html) and [FTS5](https://www.sqlite.org/fts5.html).
|
||||
|
||||
|
||||
@@ -228,7 +228,7 @@ Do not miss [Swift Concurrency and GRDB], for more recommendations regarding non
|
||||
- The async sequence returned by [`ValueObservation.values`](https://swiftpackageindex.com/groue/grdb.swiftdocumentation/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
|
||||
[Sharing a Database]: https://swiftpackageindex.com/groue/grdb.swift/v7.0.0-beta.5/documentation/grdb/databasesharing
|
||||
[Transaction Kinds]: https://swiftpackageindex.com/groue/grdb.swift/v7.0.0-beta.5/documentation/grdb/transactions#Transaction-Kinds
|
||||
[Swift Concurrency and GRDB]: https://swiftpackageindex.com/groue/grdb.swift/v7.0.0-beta.5/documentation/grdb/swiftconcurrency
|
||||
[Record]: https://swiftpackageindex.com/groue/grdb.swift/v7.0.0-beta.5/documentation/grdb/record
|
||||
[Sharing a Database]: https://swiftpackageindex.com/groue/grdb.swift/v7.0.0-beta.6/documentation/grdb/databasesharing
|
||||
[Transaction Kinds]: https://swiftpackageindex.com/groue/grdb.swift/v7.0.0-beta.6/documentation/grdb/transactions#Transaction-Kinds
|
||||
[Swift Concurrency and GRDB]: https://swiftpackageindex.com/groue/grdb.swift/v7.0.0-beta.6/documentation/grdb/swiftconcurrency
|
||||
[Record]: https://swiftpackageindex.com/groue/grdb.swift/v7.0.0-beta.6/documentation/grdb/record
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'GRDB.swift'
|
||||
s.version = '7.0.0-beta.5'
|
||||
s.version = '7.0.0-beta.6'
|
||||
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
s.summary = 'A toolkit for SQLite databases, with a focus on application development.'
|
||||
|
||||
@@ -13,6 +13,8 @@ import string_h
|
||||
import Glibc
|
||||
#elseif os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS)
|
||||
import Darwin
|
||||
#elseif os(Windows)
|
||||
import ucrt
|
||||
#endif
|
||||
|
||||
/// `StatementAuthorizer` provides information about compiled database
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#if !os(Linux)
|
||||
#if !os(Linux) && !os(Windows)
|
||||
import Foundation
|
||||
|
||||
private let integerRoundingBehavior = NSDecimalNumberHandler(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Foundation
|
||||
|
||||
#if !os(Linux)
|
||||
#if !os(Linux) && !os(Windows)
|
||||
/// NSURL stores its absoluteString in the database.
|
||||
extension NSURL: DatabaseValueConvertible {
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import SQLite3
|
||||
|
||||
import Foundation
|
||||
|
||||
#if !os(Linux)
|
||||
#if !os(Linux) && !os(Windows)
|
||||
/// NSUUID adopts DatabaseValueConvertible
|
||||
extension NSUUID: DatabaseValueConvertible {
|
||||
/// Returns a BLOB database value containing the uuid bytes.
|
||||
|
||||
@@ -4,11 +4,17 @@ GRDB helps your app deal with Swift and SQLite concurrency.
|
||||
|
||||
## Overview
|
||||
|
||||
If your app moves slow database jobs off the main thread, so that the user interface remains responsive, then this guide is for you. In the case of apps that share a database with other processes, such as an iOS app and its extensions, don't miss the dedicated <doc:DatabaseSharing> guide after this one.
|
||||
If your app moves slow database jobs off the main thread, so that the user interface remains responsive, then this guide is for you.
|
||||
|
||||
**In all cases, and first and foremost, follow the <doc:Concurrency#Concurrency-Rules> right from the start.**
|
||||
It is extended with three articles that focus on particular aspects of concurrency:
|
||||
|
||||
The other chapters cover, with more details, the fundamentals of SQLite concurrency, and how GRDB makes it manageable from your Swift code.
|
||||
- <doc:DatabaseSharing>: for apps that **share a database** with other processes, such as an iOS app and its extensions
|
||||
- <doc:SwiftConcurrency>: the relationships between GRDB and **Swift 6 Concurrency**
|
||||
- <doc:MainThread>: everything you have to known about GRDB and the main thread.
|
||||
|
||||
**In all cases, and first and foremost, follow the Concurrency-Rules, below, right from the start.**
|
||||
|
||||
The following chapters cover the fundamentals of SQLite concurrency, and how GRDB makes it manageable from your Swift code.
|
||||
|
||||
## Concurrency Rules
|
||||
|
||||
@@ -322,7 +328,7 @@ Types that conform to ``TransactionObserver`` can also use those methods in thei
|
||||
|
||||
- <doc:SwiftConcurrency>
|
||||
- <doc:DatabaseSharing>
|
||||
|
||||
- <doc:MainThread>
|
||||
|
||||
[demo apps]: https://github.com/groue/GRDB.swift/tree/master/Documentation/DemoApps
|
||||
[`SQLITE_BUSY`]: https://www.sqlite.org/rescode.html#busy
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# Using or Avoiding the Main Thread
|
||||
|
||||
Everything you have to known about GRDB and the main thread.
|
||||
|
||||
## Overview
|
||||
|
||||
**This guide describes the relationship between GRDB and the main thread.** It complements the <doc:Concurrency> guide, that you should read first.
|
||||
|
||||
Accessing the database from the main thread is handy. Graphical applications, for example, do not need to show a loading screen until values are fetched and ready for display. They do not need to spawn tasks or any other asynchronous constructs in response to user actions.
|
||||
|
||||
There are only two things one should think about when accessing the database from the main thread:
|
||||
- How long does it take to start the database access?
|
||||
- How long does it take to execute the database requests?
|
||||
|
||||
The first delay depends on *database contention*
|
||||
The first delay can be slowed down if the database is already busy
|
||||
|
||||
SQLite is very fast, and many database accesses are so fast that the user has no time to notice them. In a graphical application, performing fast database accesses from the main thread is handy, because the application does not need to show a loading screen until values are fetched and ready for display.
|
||||
|
||||
Other database accesses should be performed in a background thread, in order to avoid user interface freezes.
|
||||
|
||||
In the end, accessing the database on or off the main thread is a choice left to the application.
|
||||
|
||||
The database can be accessed from the main thread, or from a background thread, at the application convenience. In this guide we explain what you have to know when you intend to access the database from the main thread, or when you want to make sure a database access does not block the main thread. We will discuss plain database accesses (`read`, `write`), as well a database observation with ``ValueObservation``.
|
||||
|
||||
### Avoiding the Main Thread
|
||||
|
||||
To avoid performing database accesses from the main thread,
|
||||
|
||||
<!--@START_MENU_TOKEN@-->Text<!--@END_MENU_TOKEN@-->
|
||||
@@ -4,6 +4,8 @@ How to best integrate GRDB and Swift Concurrency
|
||||
|
||||
## Overview
|
||||
|
||||
**This guide describes the relationship between GRDB and Swift 6 Concurrency.** It complements the <doc:Concurrency> guide, that you should read first.
|
||||
|
||||
GRDB’s primary goal is to leverage SQLite’s concurrency features for the benefit of application developers. Swift 6 makes it possible to achieve this goal while ensuring data-race safety.
|
||||
|
||||
For example, the ``DatabasePool`` connection allows applications to fetch and display database values on screen, even while a background task is writing the results of a network request to disk.
|
||||
@@ -39,11 +41,73 @@ All safety guarantees of Swift 6 are enforced during database accesses. They are
|
||||
|
||||
The following sections describe, with more details, how GRDB interacts with Swift Concurrency.
|
||||
|
||||
- <doc:SwiftConcurrency#Non-Sendable-Record-Types>
|
||||
- <doc:SwiftConcurrency#Shorthand-Closure-Notation>
|
||||
- <doc:SwiftConcurrency#Non-Sendable-Configuration-of-Record-Types>
|
||||
- <doc:SwiftConcurrency#Non-Sendable-Record-Types>
|
||||
- <doc:SwiftConcurrency#Choosing-between-Synchronous-and-Asynchronous-Database-Accesses>
|
||||
|
||||
### Shorthand Closure Notation
|
||||
|
||||
In the Swift 5 language mode, the compiler emits a warning when a database access is written with the shorthand closure notation:
|
||||
|
||||
```swift
|
||||
// Standard closure:
|
||||
let count = try await writer.read { db in
|
||||
try Player.fetchCount(db)
|
||||
}
|
||||
|
||||
// Shorthand notation:
|
||||
// ⚠️ Converting non-sendable function value to '@Sendable (Database)
|
||||
// throws -> Int' may introduce data races.
|
||||
let count = try await writer.read(Player.fetchCount)
|
||||
```
|
||||
|
||||
**You can remove this warning** by enabling [SE-0418: Inferring `Sendable` for methods and key path literals](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0418-inferring-sendable-for-methods.md), as below:
|
||||
|
||||
- **Using Xcode**
|
||||
|
||||
Set `SWIFT_UPCOMING_FEATURE_INFER_SENDABLE_FROM_CAPTURES` to `YES` in the build settings of your target.
|
||||
|
||||
- **In a SwiftPM package manifest**
|
||||
|
||||
Enable the `InferSendableFromCaptures` upcoming feature:
|
||||
|
||||
```swift
|
||||
.target(
|
||||
name: "MyTarget",
|
||||
swiftSettings: [
|
||||
.enableUpcomingFeature("InferSendableFromCaptures")
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
This language feature is not enabled by default, because it can potentially [affect source compatibility](https://www.swift.org/migration/documentation/swift-6-concurrency-migration-guide/sourcecompatibility#Inferring-Sendable-for-methods-and-key-path-literals).
|
||||
|
||||
### Non-Sendable Configuration of Record Types
|
||||
|
||||
In the Swift 6 language mode, and in the Swift 5 language mode with strict concurrency checkings, the compiler emits an error or a warning when a record type specifies which columns it fetches from the database, with the ``TableRecord/databaseSelection-7iphs`` static property:
|
||||
|
||||
```swift
|
||||
extension Player: FetchableRecord, PersistableRecord {
|
||||
// ❌ Static property 'databaseSelection' is not concurrency-safe
|
||||
// because non-'Sendable' type '[any SQLSelectable]'
|
||||
// may have shared mutable state
|
||||
static let databaseSelection: [any SQLSelectable] = [
|
||||
Column("id"), Column("name"), Column("score")
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**To fix this error**, replace the stored property with a computed property:
|
||||
|
||||
```swift
|
||||
extension Player: FetchableRecord, PersistableRecord {
|
||||
static var databaseSelection: [any SQLSelectable] {
|
||||
[Column("id"), Column("name"), Column("score")]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Non-Sendable Record Types
|
||||
|
||||
In the Swift 6 language mode, and in the Swift 5 language mode with strict concurrency checkings, the compiler emits an error or a warning when the application reads, writes, or observes a non-[`Sendable`](https://developer.apple.com/documentation/swift/sendable) type.
|
||||
@@ -128,97 +192,6 @@ You do not need to perform this refactoring right away: you can compile your app
|
||||
|
||||
Yes. Classes that can not be modified, made of constant `let` properties, are Sendable. Those immutable classes will not make it easy to modify the database, though.
|
||||
|
||||
#### FAQ: Why this Sendable requirement?
|
||||
|
||||
**GRDB needs new features in the Swift language and the SDKs in order to deal with non-Sendable types.**
|
||||
|
||||
[SE-0430: `sending` parameter and result values](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0430-transferring-parameters-and-results.md) looks like the language feature we need, but:
|
||||
|
||||
- `DispatchQueue.async` does not accept a `sending` closure. GRDB needs this in order to accept non-Sendable records to be sent to the database, as below:
|
||||
|
||||
```swift
|
||||
let nonSendableRecord: Player
|
||||
try await writer.write { db in
|
||||
try nonSendableRecord.insert(db)
|
||||
}
|
||||
```
|
||||
|
||||
Please [file a feedback](http://feedbackassistant.apple.com) for requesting this DispatchQueue improvement. The more the merrier. I personally filed FB15270949.
|
||||
|
||||
- Database access methods taint the values they fetch. In the code below, the rules of [SE-0414: Region based Isolation](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0414-region-based-isolation.md) have the compiler refuse that the fetched player is sent back to the caller:
|
||||
|
||||
```swift
|
||||
let player = try await writer.read { db in
|
||||
try Player.fetchOne(db, id: 42)
|
||||
}
|
||||
```
|
||||
|
||||
Strictly speaking, the compiler diagnostic is correct: one could copy the non-Sendable `db` argument into the fetched `Player` instance, making it unsuitable for later use. In practice, nobody does that. Copying `db` is a programmer error, and GRDB promptly raises a fatal error whenever a `db` copy would be improperly used. But there is no way to tell the compiler about this practice.
|
||||
|
||||
For all those reasons, GRDB has to require values that are asynchronously written and read from the database to be `Sendable`.
|
||||
|
||||
### Shorthand Closure Notation
|
||||
|
||||
In the Swift 5 language mode, the compiler emits a warning when a database access is written with the shorthand closure notation:
|
||||
|
||||
```swift
|
||||
// Standard closure:
|
||||
let count = try await writer.read { db in
|
||||
try Player.fetchCount(db)
|
||||
}
|
||||
|
||||
// Shorthand notation:
|
||||
// ⚠️ Converting non-sendable function value to '@Sendable (Database)
|
||||
// throws -> Int' may introduce data races.
|
||||
let count = try await writer.read(Player.fetchCount)
|
||||
```
|
||||
|
||||
**You can remove this warning** by enabling [SE-0418: Inferring `Sendable` for methods and key path literals](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0418-inferring-sendable-for-methods.md), as below:
|
||||
|
||||
- **Using Xcode**
|
||||
|
||||
Set `SWIFT_UPCOMING_FEATURE_INFER_SENDABLE_FROM_CAPTURES` to `YES` in the build settings of your target.
|
||||
|
||||
- **In a SwiftPM package manifest**
|
||||
|
||||
Enable the `InferSendableFromCaptures` upcoming feature:
|
||||
|
||||
```swift
|
||||
.target(
|
||||
name: "MyTarget",
|
||||
swiftSettings: [
|
||||
.enableUpcomingFeature("InferSendableFromCaptures")
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
This language feature is not enabled by default, because it can potentially [affect source compatibility](https://www.swift.org/migration/documentation/swift-6-concurrency-migration-guide/sourcecompatibility#Inferring-Sendable-for-methods-and-key-path-literals).
|
||||
|
||||
### Non-Sendable Configuration of Record Types
|
||||
|
||||
In the Swift 6 language mode, and in the Swift 5 language mode with strict concurrency checkings, the compiler emits an error or a warning when a record type specifies which columns it fetches from the database, with the ``TableRecord/databaseSelection-7iphs`` static property:
|
||||
|
||||
```swift
|
||||
extension Player: FetchableRecord, MutablePersistableRecord {
|
||||
// ❌ Static property 'databaseSelection' is not concurrency-safe
|
||||
// because non-'Sendable' type '[any SQLSelectable]'
|
||||
// may have shared mutable state
|
||||
static let databaseSelection: [any SQLSelectable] = [
|
||||
Column("id"), Column("name"), Column("score")
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**To fix this error**, replace the stored property with a computed property:
|
||||
|
||||
```swift
|
||||
extension Player: FetchableRecord, MutablePersistableRecord {
|
||||
static var databaseSelection: [any SQLSelectable] {
|
||||
[Column("id"), Column("name"), Column("score")]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Choosing between Synchronous and Asynchronous Database Accesses
|
||||
|
||||
GRDB connections provide two versions of `read` and `write`, one that is synchronous, and one that is asynchronous. It might not be clear how to choose one or the other.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (C) 2015-2024 Gwendal Roué
|
||||
Copyright (C) 2015-2025 Gwendal Roué
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://developer.apple.com/swift/"><img alt="Swift 5.7" src="https://img.shields.io/badge/swift-5.7-orange.svg?style=flat"></a>
|
||||
<a href="https://developer.apple.com/swift/"><img alt="Swift 6" src="https://img.shields.io/badge/swift-6-orange.svg?style=flat"></a>
|
||||
<a href="https://github.com/groue/GRDB.swift/blob/master/LICENSE"><img alt="License" src="https://img.shields.io/github/license/groue/GRDB.swift.svg?maxAge=2592000"></a>
|
||||
<a href="https://github.com/groue/GRDB.swift/actions/workflows/CI.yml"><img alt="CI Status" src="https://github.com/groue/GRDB.swift/actions/workflows/CI.yml/badge.svg?branch=master"></a>
|
||||
</p>
|
||||
|
||||
**Latest release**: October 12, 2024 • [version 7.0.0-beta.5](https://github.com/groue/GRDB.swift/tree/v7.0.0-beta.5) • [CHANGELOG](CHANGELOG.md) • [Migrating From GRDB 6 to GRDB 7](Documentation/GRDB7MigrationGuide.md)
|
||||
**Latest release**: October 13, 2024 • [version 7.0.0-beta.6](https://github.com/groue/GRDB.swift/tree/v7.0.0-beta.6) • [CHANGELOG](CHANGELOG.md) • [Migrating From GRDB 6 to GRDB 7](Documentation/GRDB7MigrationGuide.md)
|
||||
|
||||
**Requirements**: iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 7.0+ • SQLite 3.20.0+ • Swift 6+ / Xcode 16+
|
||||
|
||||
@@ -295,7 +295,7 @@ Documentation
|
||||
#### Records and the Query Interface
|
||||
|
||||
- [Records](#records): Fetching and persistence methods for your custom structs and class hierarchies
|
||||
- [Query Interface](#the-query-interface): A swift way to generate SQL • [create tables](https://swiftpackageindex.com/groue/grdb.swift/documentation/grdb/databaseschema) • [requests](#requests) • [associations between record types](Documentation/AssociationsBasics.md)
|
||||
- [Query Interface](#the-query-interface): A swift way to generate SQL • [create tables, indexes, etc](https://swiftpackageindex.com/groue/grdb.swift/v7.0.0-beta.6/documentation/grdb/databaseschema) • [requests](#requests) • [associations between record types](Documentation/AssociationsBasics.md)
|
||||
|
||||
#### Application Tools
|
||||
|
||||
@@ -441,7 +441,7 @@ Advanced topics:
|
||||
|
||||
- [Prepared Statements]
|
||||
- [Custom SQL Functions and Aggregates](#custom-sql-functions-and-aggregates)
|
||||
- [Database Schema Introspection](#database-schema-introspection)
|
||||
- [Database Schema Introspection](https://swiftpackageindex.com/groue/grdb.swift/v7.0.0-beta.6/documentation/grdb/databaseschemaintrospection)
|
||||
- [Row Adapters](https://swiftpackageindex.com/groue/grdb.swift/documentation/grdb/rowadapter)
|
||||
- [Raw SQLite Pointers](#raw-sqlite-pointers)
|
||||
|
||||
@@ -1596,41 +1596,6 @@ try Int.fetchOne(db, request) // Int?
|
||||
```
|
||||
|
||||
|
||||
## Database Schema Introspection
|
||||
|
||||
GRDB comes with a set of schema introspection methods:
|
||||
|
||||
```swift
|
||||
try dbQueue.read { db in
|
||||
// Bool, true if the table exists
|
||||
try db.tableExists("player")
|
||||
|
||||
// [ColumnInfo], the columns in the table
|
||||
try db.columns(in: "player")
|
||||
|
||||
// PrimaryKeyInfo
|
||||
try db.primaryKey("player")
|
||||
|
||||
// [ForeignKeyInfo], the foreign keys defined on the table
|
||||
try db.foreignKeys(on: "player")
|
||||
|
||||
// [IndexInfo], the indexes defined on the table
|
||||
try db.indexes(on: "player")
|
||||
|
||||
// Bool, true if column(s) is a unique key (primary key or unique index)
|
||||
try db.table("player", hasUniqueKey: ["email"])
|
||||
}
|
||||
|
||||
// Bool, true if argument is the name of an internal SQLite table
|
||||
Database.isSQLiteInternalTable(...)
|
||||
|
||||
// Bool, true if argument is the name of an internal GRDB table
|
||||
Database.isGRDBInternalTable(...)
|
||||
```
|
||||
|
||||
For more information, see [`tableExists(_:)`](https://swiftpackageindex.com/groue/grdb.swift/documentation/grdb/database/tableexists(_:)) and related methods.
|
||||
|
||||
|
||||
## Raw SQLite Pointers
|
||||
|
||||
**If not all SQLite APIs are exposed in GRDB, you can still use the [SQLite C Interface](https://www.sqlite.org/c3ref/intro.html) and call [SQLite C functions](https://www.sqlite.org/c3ref/funclist.html).**
|
||||
@@ -1678,14 +1643,14 @@ try dbQueue.write { db in
|
||||
}
|
||||
```
|
||||
|
||||
Of course, you need to open a [database connection], and [create database tables](https://swiftpackageindex.com/groue/grdb.swift/documentation/grdb/databaseschema) first.
|
||||
Of course, you need to open a [database connection], and [create database tables](https://swiftpackageindex.com/groue/grdb.swift/v7.0.0-beta.6/documentation/grdb/databaseschema) first.
|
||||
|
||||
To define a record type, define a type and extend it with protocols that come with focused sets of features.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
struct Player: {
|
||||
```swift
|
||||
struct Player {
|
||||
var id: Int64
|
||||
var name: String
|
||||
var score: Int
|
||||
@@ -3285,7 +3250,7 @@ So don't miss the [SQL API](#sqlite-api).
|
||||
|
||||
> **Note**: the generated SQL may change between GRDB releases, without notice: don't have your application rely on any specific SQL output.
|
||||
|
||||
- [The Database Schema](https://swiftpackageindex.com/groue/grdb.swift/documentation/grdb/databaseschema)
|
||||
- [The Database Schema](https://swiftpackageindex.com/groue/grdb.swift/v7.0.0-beta.6/documentation/grdb/databaseschema)
|
||||
- [Requests](#requests)
|
||||
- [Expressions](#expressions)
|
||||
- [SQL Operators](#sql-operators)
|
||||
|
||||
+1
-1
Submodule SQLiteCustom/src updated: 31e6aa6618...69395d1f72.
+1
-1
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>7.0.0-beta.5</string>
|
||||
<string>7.0.0-beta.6</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
Reference in new issue
Block a user