Merge branch 'development'

This commit is contained in:
Gwendal Roué committed 2021-08-22 16:18:55 +02:00
commit ba41c22304
52 files changed
+395 -378

No files matched your search

+12
View File
@@ -7,6 +7,7 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception:
#### 5.x Releases
- `5.10.x` Releases - [5.10.0](#5100)
- `5.9.x` Releases - [5.9.0](#590)
- `5.8.x` Releases - [5.8.0](#580)
- `5.7.x` Releases - [5.7.0](#570) | [5.7.1](#571) | [5.7.2](#572) | [5.7.3](#573) | [5.7.4](#574)
@@ -76,6 +77,17 @@ GRDB adheres to [Semantic Versioning](https://semver.org/), with one exception:
---
## 5.10.0
Released August 22, 2021 • [diff](https://github.com/groue/GRDB.swift/compare/v5.9.0...v5.10.0)
- **New**: [#1036](https://github.com/groue/GRDB.swift/pull/1036) by [@groue](https://github.com/groue): Restore minimal CI tests
- **New**: [#1037](https://github.com/groue/GRDB.swift/pull/1037) by [@groue](https://github.com/groue): Support BUILD_LIBRARY_FOR_DISTRIBUTION
- **New**: [#1038](https://github.com/groue/GRDB.swift/pull/1038) by [@GetToSet](https://github.com/GetToSet): Add match operator in ColumnExpression for FTS5
- **New**: With Swift 5.5+, enhance access to `Column.rowID`. Row and PersistenceContainer subscripts now accept `row[.rowID]` and `container[.rowID]` ([SE-0299](https://github.com/apple/swift-evolution/blob/main/proposals/0299-extend-generic-static-member-lookup.md))
- **Documentation Update**: A new [Combine and Data Consistency](Documentation/Combine.md#combine-and-data-consistency) chapter explains how to make sure database publishers do not break important database invariants.
## 5.9.0
Released August 15, 2021 • [diff](https://github.com/groue/GRDB.swift/compare/v5.8.0...v5.9.0)
+75 -31
View File
@@ -7,6 +7,7 @@ GRDB ❤️ Combine
- [Demo Application]
- [Asynchronous Database Access]
- [Database Observation]
- [Combine and Data Consistency]: take care when you combine database publishers together
## Usage
@@ -248,37 +249,6 @@ This publisher has the same behavior as ValueObservation:
See [ValueObservation Scheduling](../README.md#valueobservation-scheduling) for more information.
:warning: **ValueObservation and Data Consistency**
When you compose ValueObservation publishers together with the [combineLatest](https://developer.apple.com/documentation/combine/publisher/3333677-combinelatest) operator, you lose all guarantees of [data consistency](https://en.wikipedia.org/wiki/Consistency_(database_systems)).
Instead, compose requests together into **one single** ValueObservation, as below:
```swift
struct HallOfFame {
var totalPlayerCount: Int
var bestPlayers: [Player]
}
// DATA CONSISTENCY GUARANTEED
let hallOfFamePublisher = ValueObservation
.tracking { db -> HallOfFame in
let totalPlayerCount = try Player.fetchCount(db)
let bestPlayers = try Player
.order(Column("score").desc)
.limit(10)
.fetchAll(db)
return HallOfFame(
totalPlayerCount: totalPlayerCount,
bestPlayers: bestPlayers)
}
.publisher(in: dbQueue)
```
See [ValueObservation] for more information.
#### `DatabaseRegionObservation.publisher(in:)`
@@ -320,12 +290,86 @@ try dbQueue.write { db in
See [DatabaseRegionObservation] for more information.
## Combine and Data Consistency
When you compose database publishers together with Combine operators such as `combineLatest` or `zip`, you lose all guarantees of [data consistency](https://en.wikipedia.org/wiki/Consistency_(database_systems)).
This is because each database publisher is isolated from others: each one of them sees its own state of the database. Whenever some database change is interleaved between publisher operations, publishers will process or publish values that may not fit well together.
In other words, whenever you need to perform some database access or observation that depends on some database invariant, make sure you define one and only one database publisher instead of combining several publishers. This is how you will prevent eventual concurrent database writes from messing with your app, and introduce bugs.
To this end, remember that *all database publishers can perform several requests*.
In the example below, we are totally sure that the published `HallOfFame` values will never contain inconsistent values, because it is produced by one and ony one publisher:
```swift
struct HallOfFame {
// Invariant: bestPlayers.count <= totalPlayerCount
var totalPlayerCount: Int
var bestPlayers: [Player]
}
// CORRECT: DATA CONSISTENCY GUARANTEED
let hallOfFamePublisher = ValueObservation
.tracking { db -> HallOfFame in
// 1st request
let totalPlayerCount = try Player.fetchCount(db)
// 2nd request
let bestPlayers = try Player
.order(Column("score").desc)
.limit(10)
.fetchAll(db)
// 100% guaranteed
assert(bestPlayers.count <= totalPlayerCount)
// Merge results together
return HallOfFame(
totalPlayerCount: totalPlayerCount,
bestPlayers: bestPlayers)
}
.publisher(in: dbQueue)
```
Compare with the incorrect version that combines two database publishers together:
```swift
// OK
let totalPlayerCountPublisher = ValueObservation
.tracking(Player.fetchCount)
.publisher(in: dbQueue)
// OK
let bestPlayerPublisher = ValueObservation
.tracking(Player
.order(Column("score").desc)
.limit(10)
.fetchAll)
.publisher(in: dbQueue)
// NOT OK: DATA CONSISTENCY NOT GUARANTEED
let hallOfFamePublisher = totalPlayerCountPublisher
.combineLatest(bestPlayerPublisher)
.map(HallOfFame.init(totalPlayerCount:bestPlayers))
let cancellable = hallOfFamePublisher.sink(
receiveCompletion: { completion in ... },
receiveValue: { hallOfFame in
// ASSERTION MAY FAIL if some players are deleted
// at the wrong time
assert(hallOfFame.bestPlayers.count <= hallOfFame.totalPlayerCount)
})
```
[Database Connections]: ../README.md#database-connections
[Usage]: #usage
[Asynchronous Database Access]: #asynchronous-database-access
[Combine]: https://developer.apple.com/documentation/combine
[Database Changes Observation]: ../README.md#database-changes-observation
[Database Observation]: #database-observation
[Combine and Data Consistency]: #combine-and-data-consistency
[DatabaseRegionObservation]: ../README.md#databaseregionobservation
[Demo Application]: DemoApps/GRDBCombineDemo/README.md
[SQLite]: http://sqlite.org
+6 -2
View File
@@ -280,7 +280,7 @@ let pattern = FTS3Pattern(matchingAnyTokenIn: "") // nil
let pattern = FTS3Pattern(matchingAnyTokenIn: "*") // nil
```
FTS3Pattern are regular [values](../README.md#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/5.9/Structs/StatementArguments.html):
FTS3Pattern are regular [values](../README.md#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/5.10/Structs/StatementArguments.html):
```swift
let documents = try Document.fetchAll(db,
@@ -529,7 +529,7 @@ let pattern = FTS5Pattern(matchingAnyTokenIn: "") // nil
let pattern = FTS5Pattern(matchingAnyTokenIn: "*") // nil
```
FTS5Pattern are regular [values](../README.md#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/5.9/Structs/StatementArguments.html):
FTS5Pattern are regular [values](../README.md#values). You can use them as query [arguments](http://groue.github.io/GRDB.swift/docs/5.10/Structs/StatementArguments.html):
```swift
let documents = try Document.fetchAll(db,
@@ -540,7 +540,11 @@ let documents = try Document.fetchAll(db,
Use them in the [query interface](../README.md#the-query-interface):
```swift
// Search in all columns
let documents = try Document.matching(pattern).fetchAll(db)
// Search in a specific column:
let documents = try Document.filter(Column("content").match(pattern)).fetchAll(db)
```
+1 -1
View File
@@ -68,7 +68,7 @@ try dbQueue.read { db in
}
```
See the [DatabaseMigrator reference](http://groue.github.io/GRDB.swift/docs/5.9/Structs/DatabaseMigrator.html) for more migrator methods.
See the [DatabaseMigrator reference](http://groue.github.io/GRDB.swift/docs/5.10/Structs/DatabaseMigrator.html) for more migrator methods.
## The `eraseDatabaseOnSchemaChange` Option
@@ -368,15 +368,15 @@ extension MyDatabaseDecoder {
// MARK: - Fetch from SQL
static func fetchCursor(_ db: Database, sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> MapCursor<RowCursor, DecodedType> {
try fetchCursor(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchCursor(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
static func fetchAll(_ db: Database, sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> [DecodedType] {
try fetchAll(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchAll(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
static func fetchOne(_ db: Database, sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> DecodedType? {
try fetchOne(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchOne(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'GRDB.swift'
s.version = '5.9.0'
s.version = '5.10.0'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.summary = 'A toolkit for SQLite databases, with a focus on application development.'
-2
View File
@@ -19,7 +19,6 @@ extension RangeReplaceableCollection {
/// let strings = try Array(cursor)
///
/// - parameter cursor: The cursor whose elements feed the collection.
@inlinable
public init<C: Cursor>(_ cursor: C) throws where C.Element == Element {
self.init()
while let element = try cursor.next() {
@@ -36,7 +35,6 @@ extension RangeReplaceableCollection {
/// - parameter cursor: The cursor whose elements feed the collection.
/// - parameter minimumCapacity: Prepares the returned collection to store
/// the specified number of elements.
@inlinable
public init<C: Cursor>(_ cursor: C, minimumCapacity: Int) throws where C.Element == Element {
self.init()
reserveCapacity(minimumCapacity)
+1 -1
View File
@@ -6,7 +6,6 @@ public typealias SQLiteConnection = OpaquePointer
/// A raw SQLite function argument.
typealias SQLiteValue = OpaquePointer
@usableFromInline
let SQLITE_TRANSIENT = unsafeBitCast(OpaquePointer(bitPattern: -1), to: sqlite3_destructor_type.self)
/// A Database connection.
@@ -1597,6 +1596,7 @@ extension Database {
}
/// Confirms or cancels the changes performed by a transaction or savepoint.
@frozen
public enum TransactionCompletion {
/// Confirms changes
case commit
+1 -4
View File
@@ -13,6 +13,7 @@ public struct DatabaseValue: Hashable, CustomStringConvertible, DatabaseValueCon
public static let null = DatabaseValue(storage: .null)
/// An SQLite storage (NULL, INTEGER, REAL, TEXT, BLOB).
@frozen
public enum Storage: Equatable {
/// The NULL storage class.
case null
@@ -86,7 +87,6 @@ public struct DatabaseValue: Hashable, CustomStringConvertible, DatabaseValueCon
// MARK: - Not Public
@inlinable
init(storage: Storage) {
self.storage = storage
}
@@ -116,7 +116,6 @@ public struct DatabaseValue: Hashable, CustomStringConvertible, DatabaseValueCon
}
/// Returns a DatabaseValue initialized from a raw SQLite statement pointer.
@usableFromInline
init(sqliteStatement: SQLiteStatement, index: Int32) {
switch sqlite3_column_type(sqliteStatement, index) {
case SQLITE_NULL:
@@ -142,7 +141,6 @@ public struct DatabaseValue: Hashable, CustomStringConvertible, DatabaseValueCon
}
extension DatabaseValue: StatementBinding {
@inlinable
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
switch storage {
case .null:
@@ -221,7 +219,6 @@ extension DatabaseValue {
// DatabaseValueConvertible
extension DatabaseValue {
/// Returns self
@inlinable
public var databaseValue: DatabaseValue {
self
}
+17 -22
View File
@@ -27,7 +27,6 @@ extension DatabaseValueConvertible {
.databaseValue(databaseValue)
}
@inlinable
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
databaseValue.bind(to: sqliteStatement, at: index)
}
@@ -48,7 +47,6 @@ extension DatabaseValueConvertible {
}
}
@usableFromInline
static func decode(
fromStatement sqliteStatement: SQLiteStatement,
atUncheckedIndex index: Int32,
@@ -87,7 +85,6 @@ extension DatabaseValueConvertible {
}
}
@usableFromInline
static func decodeIfPresent(
fromStatement sqliteStatement: SQLiteStatement,
atUncheckedIndex index: Int32,
@@ -130,14 +127,14 @@ extension DatabaseValueConvertible {
/// }
/// }
public final class DatabaseValueCursor<Value: DatabaseValueConvertible>: Cursor {
@usableFromInline enum _State {
private enum _State {
case idle, busy, done, failed
}
@usableFromInline let _statement: Statement
@usableFromInline let _sqliteStatement: SQLiteStatement
@usableFromInline let _columnIndex: Int32
@usableFromInline var _state = _State.idle
private let _statement: Statement
private let _sqliteStatement: SQLiteStatement
private let _columnIndex: Int32
private var _state = _State.idle
init(statement: Statement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws {
_statement = statement
@@ -163,7 +160,6 @@ public final class DatabaseValueCursor<Value: DatabaseValueConvertible>: Cursor
try? _statement.reset()
}
@inlinable
public func next() throws -> Value? {
switch _state {
case .done:
@@ -211,14 +207,14 @@ public final class DatabaseValueCursor<Value: DatabaseValueConvertible>: Cursor
/// }
/// }
public final class NullableDatabaseValueCursor<Value: DatabaseValueConvertible>: Cursor {
@usableFromInline enum _State {
private enum _State {
case idle, busy, done, failed
}
@usableFromInline let _statement: Statement
@usableFromInline let _sqliteStatement: SQLiteStatement
@usableFromInline let _columnIndex: Int32
@usableFromInline var _state = _State.idle
private let _statement: Statement
private let _sqliteStatement: SQLiteStatement
private let _columnIndex: Int32
private var _state = _State.idle
init(statement: Statement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws {
_statement = statement
@@ -244,7 +240,6 @@ public final class NullableDatabaseValueCursor<Value: DatabaseValueConvertible>:
try? _statement.reset()
}
@inlinable
public func next() throws -> Value?? {
switch _state {
case .done:
@@ -425,7 +420,7 @@ extension DatabaseValueConvertible {
adapter: RowAdapter? = nil)
throws -> DatabaseValueCursor<Self>
{
try fetchCursor(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchCursor(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
/// Returns an array of values fetched from an SQL query.
@@ -446,7 +441,7 @@ extension DatabaseValueConvertible {
adapter: RowAdapter? = nil)
throws -> [Self]
{
try fetchAll(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchAll(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
/// Returns a single value fetched from an SQL query.
@@ -470,7 +465,7 @@ extension DatabaseValueConvertible {
adapter: RowAdapter? = nil)
throws -> Self?
{
try fetchOne(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchOne(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
@@ -493,7 +488,7 @@ extension DatabaseValueConvertible where Self: Hashable {
adapter: RowAdapter? = nil)
throws -> Set<Self>
{
try fetchSet(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchSet(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
@@ -757,7 +752,7 @@ extension Optional where Wrapped: DatabaseValueConvertible {
adapter: RowAdapter? = nil)
throws -> NullableDatabaseValueCursor<Wrapped>
{
try fetchCursor(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchCursor(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
/// Returns an array of optional values fetched from an SQL query.
@@ -778,7 +773,7 @@ extension Optional where Wrapped: DatabaseValueConvertible {
adapter: RowAdapter? = nil)
throws -> [Wrapped?]
{
try fetchAll(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchAll(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
@@ -801,7 +796,7 @@ extension Optional where Wrapped: DatabaseValueConvertible & Hashable {
adapter: RowAdapter? = nil)
throws -> Set<Wrapped?>
{
try fetchSet(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchSet(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
+22 -25
View File
@@ -14,8 +14,9 @@ public final class Row: Equatable, Hashable, RandomAccessCollection,
///
/// let rows = try Row.fetchCursor(db, sql: "SELECT ...")
/// let players = try Player.fetchAll(db, sql: "SELECT ...")
@usableFromInline let statement: Statement?
@usableFromInline let sqliteStatement: SQLiteStatement?
let statement: Statement?
@usableFromInline
let sqliteStatement: SQLiteStatement?
/// The number of columns in the row.
public let count: Int
@@ -165,8 +166,8 @@ extension Row {
// MARK: - Extracting Values
/// Fatal errors if index is out of bounds
@inlinable
func checkedIndex(_ index: Int, file: StaticString = #file, line: UInt = #line) -> Int {
@usableFromInline
/* private */ func _checkedIndex(_ index: Int, file: StaticString = #file, line: UInt = #line) -> Int {
GRDBPrecondition(index >= 0 && index < count, "row index out of range", file: file, line: line)
return index
}
@@ -203,7 +204,7 @@ extension Row {
/// in performance-critical code because it can avoid decoding database
/// values.
public func hasNull(atIndex index: Int) -> Bool {
impl.hasNull(atUncheckedIndex: checkedIndex(index))
impl.hasNull(atUncheckedIndex: _checkedIndex(index))
}
/// Returns Int64, Double, String, Data or nil, depending on the value
@@ -212,7 +213,7 @@ extension Row {
/// Indexes span from 0 for the leftmost column to (row.count - 1) for the
/// righmost column.
public subscript(_ index: Int) -> DatabaseValueConvertible? {
impl.databaseValue(atUncheckedIndex: checkedIndex(index)).storage.value
impl.databaseValue(atUncheckedIndex: _checkedIndex(index)).storage.value
}
/// Returns the value at given index, converted to the requested type.
@@ -363,7 +364,6 @@ extension Row {
/// the same name, the leftmost column is considered.
///
/// The result is nil if the row does not contain the column.
@inlinable
public subscript<Column: ColumnExpression>(_ column: Column) -> DatabaseValueConvertible? {
self[column.name]
}
@@ -712,7 +712,7 @@ extension Row {
atIndex index: Int)
throws -> Value?
{
try Value.decodeIfPresent(fromRow: self, atUncheckedIndex: checkedIndex(index))
try Value.decodeIfPresent(fromRow: self, atUncheckedIndex: _checkedIndex(index))
}
/// Returns the value at given index, converted to the requested type.
@@ -728,7 +728,7 @@ extension Row {
atIndex index: Int)
throws -> Value
{
try Value.decode(fromRow: self, atUncheckedIndex: checkedIndex(index))
try Value.decode(fromRow: self, atUncheckedIndex: _checkedIndex(index))
}
/// Returns the value at given column, converted to the requested type.
@@ -793,7 +793,7 @@ extension Row {
atIndex index: Int)
throws -> Value?
{
try Value.fastDecodeIfPresent(fromRow: self, atUncheckedIndex: checkedIndex(index))
try Value.fastDecodeIfPresent(fromRow: self, atUncheckedIndex: _checkedIndex(index))
}
/// Returns the value at given index, converted to the requested type.
@@ -813,7 +813,7 @@ extension Row {
atIndex index: Int)
throws -> Value
{
try Value.fastDecode(fromRow: self, atUncheckedIndex: checkedIndex(index))
try Value.fastDecode(fromRow: self, atUncheckedIndex: _checkedIndex(index))
}
/// Returns the value at given column, converted to the requested type.
@@ -899,7 +899,7 @@ extension Row {
/// The returned data does not owns its bytes: it must not be used longer
/// than the row's lifetime.
func decodeDataNoCopyIfPresent(atIndex index: Int) throws -> Data? {
try impl.fastDecodeDataNoCopyIfPresent(atUncheckedIndex: checkedIndex(index))
try impl.fastDecodeDataNoCopyIfPresent(atUncheckedIndex: _checkedIndex(index))
}
/// Returns the Data at given index.
@@ -913,7 +913,7 @@ extension Row {
/// The returned data does not owns its bytes: it must not be used longer
/// than the row's lifetime.
func decodeDataNoCopy(atIndex index: Int) throws -> Data {
try impl.fastDecodeDataNoCopy(atUncheckedIndex: checkedIndex(index))
try impl.fastDecodeDataNoCopy(atUncheckedIndex: _checkedIndex(index))
}
/// Returns the optional Data at given column.
@@ -953,13 +953,11 @@ extension Row {
}
// Support for fast decoding in scoped rows
@usableFromInline
func fastDecodeDataNoCopy(atUncheckedIndex index: Int) throws -> Data {
try impl.fastDecodeDataNoCopy(atUncheckedIndex: index)
}
// Support for fast decoding in scoped rows
@usableFromInline
func fastDecodeDataNoCopyIfPresent(atUncheckedIndex index: Int) throws -> Data? {
try impl.fastDecodeDataNoCopyIfPresent(atUncheckedIndex: index)
}
@@ -1189,15 +1187,15 @@ extension Row {
/// let rows: RowCursor = try Row.fetchCursor(db, sql: "SELECT * FROM player")
/// }
public final class RowCursor: Cursor {
@usableFromInline enum _State {
private enum _State {
case idle, busy, done, failed
}
/// The statement iterated by this cursor
public let statement: Statement
@usableFromInline let _sqliteStatement: SQLiteStatement
@usableFromInline let _row: Row // Reused for performance
@usableFromInline var _state = _State.idle
private let _sqliteStatement: SQLiteStatement
private let _row: Row // Reused for performance
private var _state = _State.idle
init(statement: Statement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws {
self.statement = statement
@@ -1218,7 +1216,6 @@ public final class RowCursor: Cursor {
try? statement.reset()
}
@inlinable
public func next() throws -> Row? {
switch _state {
case .done:
@@ -1400,7 +1397,7 @@ extension Row {
adapter: RowAdapter? = nil)
throws -> RowCursor
{
try fetchCursor(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchCursor(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
/// Returns an array of rows fetched from an SQL query.
@@ -1425,7 +1422,7 @@ extension Row {
adapter: RowAdapter? = nil)
throws -> [Row]
{
try fetchAll(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchAll(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
/// Returns a set of rows fetched from an SQL query.
@@ -1450,7 +1447,7 @@ extension Row {
adapter: RowAdapter? = nil)
throws -> Set<Row>
{
try fetchSet(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchSet(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
/// Returns a single row fetched from an SQL query.
@@ -1475,7 +1472,7 @@ extension Row {
adapter: RowAdapter? = nil)
throws -> Row?
{
try fetchOne(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchOne(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
@@ -1660,7 +1657,7 @@ extension Row {
/// Accesses the (ColumnName, DatabaseValue) pair at given index.
public subscript(position: RowIndex) -> (String, DatabaseValue) {
let index = checkedIndex(position.index)
let index = _checkedIndex(position.index)
return (
impl.columnName(atUncheckedIndex: index),
impl.databaseValue(atUncheckedIndex: index))
-2
View File
@@ -35,7 +35,6 @@ enum RowDecodingError: Error {
/// The SQL query arguments
let statementArguments: StatementArguments?
@usableFromInline
init(decodingContext: RowDecodingContext, debugDescription: String) {
self.debugDescription = debugDescription
self.row = decodingContext.row
@@ -89,7 +88,6 @@ enum RowDecodingError: Error {
/// Convenience method that builds the
/// `could not decode <Type> from database value <value>` error message.
@usableFromInline
static func valueMismatch(
_ type: Any.Type,
statement: Statement,
+7 -14
View File
@@ -129,7 +129,6 @@ public final class Statement {
sqlite3_finalize(sqliteStatement)
}
@usableFromInline
final func reset() throws {
SchedulingWatchdog.preconditionValidQueue(database)
let code = sqlite3_reset(sqliteStatement)
@@ -141,11 +140,9 @@ public final class Statement {
// MARK: Arguments
@usableFromInline
var argumentsNeedValidation = true
private var argumentsNeedValidation = true
@usableFromInline
var _arguments = StatementArguments()
private var _arguments = StatementArguments()
lazy var sqliteArgumentCount: Int = {
Int(sqlite3_bind_parameter_count(self.sqliteStatement))
@@ -260,7 +257,6 @@ public final class Statement {
}
// 1-based index
@inlinable
func bind<T: StatementBinding>(_ value: T, at index: CInt) {
let code = value.bind(to: sqliteStatement, at: index)
@@ -272,7 +268,6 @@ public final class Statement {
}
// Don't make this one public unless we keep the arguments property in sync.
@usableFromInline
func clearBindings() {
// It looks like sqlite3_clear_bindings() does not access the file system.
// This function call should thus succeed, unless a GRDB bug: there is
@@ -340,13 +335,13 @@ extension Statement {
/// try cursor.next()
/// }
final class StatementCursor: Cursor {
@usableFromInline enum _State {
private enum _State {
case idle, busy, done, failed
}
let _statement: Statement
let _sqliteStatement: SQLiteStatement
var _state = _State.idle
/* private, internal for testability */ let _statement: Statement
private let _sqliteStatement: SQLiteStatement
private var _state = _State.idle
// Use Statement.makeCursor() instead
init(statement: Statement, arguments: StatementArguments? = nil) throws {
@@ -368,7 +363,6 @@ final class StatementCursor: Cursor {
}
/// :nodoc:
@inlinable
func next() throws -> Void? {
switch _state {
case .done:
@@ -592,8 +586,7 @@ public struct StatementArguments: CustomStringConvertible, Equatable,
self.init(values)
}
@usableFromInline
mutating func set(databaseValues: [DatabaseValue]) {
private mutating func set(databaseValues: [DatabaseValue]) {
self.values = databaseValues
namedValues.removeAll(keepingCapacity: true)
}
+11 -9
View File
@@ -129,7 +129,8 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
/// }
/// }
public final class FastDatabaseValueCursor<Value: DatabaseValueConvertible & StatementColumnConvertible> : Cursor {
@usableFromInline enum _State {
@usableFromInline
enum _State {
case idle, busy, done, failed
}
@@ -213,7 +214,8 @@ public final class FastDatabaseValueCursor<Value: DatabaseValueConvertible & Sta
public final class FastNullableDatabaseValueCursor<Value>: Cursor
where Value: DatabaseValueConvertible & StatementColumnConvertible
{
@usableFromInline enum _State {
@usableFromInline
enum _State {
case idle, busy, done, failed
}
@@ -419,7 +421,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
adapter: RowAdapter? = nil)
throws -> FastDatabaseValueCursor<Self>
{
try fetchCursor(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchCursor(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
/// Returns an array of values fetched from an SQL query.
@@ -440,7 +442,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
adapter: RowAdapter? = nil)
throws -> [Self]
{
try fetchAll(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchAll(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
/// Returns a single value fetched from an SQL query.
@@ -461,7 +463,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible {
adapter: RowAdapter? = nil)
throws -> Self?
{
try fetchOne(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchOne(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
@@ -484,7 +486,7 @@ extension DatabaseValueConvertible where Self: StatementColumnConvertible & Hash
adapter: RowAdapter? = nil)
throws -> Set<Self>
{
try fetchSet(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchSet(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
@@ -747,7 +749,7 @@ extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConv
adapter: RowAdapter? = nil)
throws -> FastNullableDatabaseValueCursor<Wrapped>
{
try fetchCursor(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchCursor(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
/// Returns an array of optional values fetched from an SQL query.
@@ -768,7 +770,7 @@ extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConv
adapter: RowAdapter? = nil)
throws -> [Wrapped?]
{
try fetchAll(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchAll(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
@@ -791,7 +793,7 @@ extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConv
adapter: RowAdapter? = nil)
throws -> Set<Wrapped?>
{
try fetchSet(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchSet(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
-7
View File
@@ -2,7 +2,6 @@ import Foundation
/// Data is convertible to and from DatabaseValue.
extension Data: DatabaseValueConvertible, StatementColumnConvertible {
@inlinable
public init(sqliteStatement: SQLiteStatement, index: Int32) {
if let bytes = sqlite3_column_blob(sqliteStatement, index) {
let count = Int(sqlite3_column_bytes(sqliteStatement, index))
@@ -13,7 +12,6 @@ extension Data: DatabaseValueConvertible, StatementColumnConvertible {
}
/// Returns a value that can be stored in the database.
@inlinable
public var databaseValue: DatabaseValue {
DatabaseValue(storage: .blob(self))
}
@@ -33,7 +31,6 @@ extension Data: DatabaseValueConvertible, StatementColumnConvertible {
}
}
@inlinable
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
withUnsafeBytes {
sqlite3_bind_blob(sqliteStatement, index, $0.baseAddress, Int32($0.count), SQLITE_TRANSIENT)
@@ -44,7 +41,6 @@ extension Data: DatabaseValueConvertible, StatementColumnConvertible {
// MARK: - Conversions
extension Data {
@inlinable
static func fastDecodeNoCopy(
fromStatement sqliteStatement: SQLiteStatement,
atUncheckedIndex index: Int32,
@@ -65,7 +61,6 @@ extension Data {
return Data(bytesNoCopy: UnsafeMutableRawPointer(mutating: bytes), count: count, deallocator: .none)
}
@inlinable
static func fastDecodeNoCopy(
fromRow row: Row,
atUncheckedIndex index: Int)
@@ -81,7 +76,6 @@ extension Data {
return try row.fastDecodeDataNoCopy(atUncheckedIndex: index)
}
@inlinable
static func fastDecodeNoCopyIfPresent(
fromStatement sqliteStatement: SQLiteStatement,
atUncheckedIndex index: Int32,
@@ -98,7 +92,6 @@ extension Data {
return Data(bytesNoCopy: UnsafeMutableRawPointer(mutating: bytes), count: count, deallocator: .none)
}
@inlinable
static func fastDecodeNoCopyIfPresent(
fromRow row: Row,
atUncheckedIndex index: Int)
-2
View File
@@ -58,7 +58,6 @@ extension Date: DatabaseValueConvertible {
return nil
}
@usableFromInline
init?(databaseDateComponents: DatabaseDateComponents) {
guard databaseDateComponents.format.hasYMDComponents else {
// Refuse to turn hours without any date information into Date:
@@ -118,7 +117,6 @@ extension Date: StatementColumnConvertible {
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
@inlinable
public init?(sqliteStatement: SQLiteStatement, index: Int32) {
switch sqlite3_column_type(sqliteStatement, index) {
case SQLITE_INTEGER, SQLITE_FLOAT:
@@ -161,13 +161,11 @@ final class SQLiteDateParser {
var cString: UnsafePointer<CChar>
var length: Int
@inline(__always)
private mutating func shift() {
cString += 1
length -= 1
}
@inline(__always)
mutating func parse(_ scalar: Unicode.Scalar) -> Bool {
guard length > 0, cString[0] == UInt8(ascii: scalar) else {
return false
@@ -176,7 +174,6 @@ final class SQLiteDateParser {
return true
}
@inline(__always)
mutating func parseDigit() -> Int? {
guard length > 0 else {
return nil
@@ -190,7 +187,6 @@ final class SQLiteDateParser {
return Int(digit)
}
@inline(__always)
mutating func parseDigit(into number: inout Int) -> Bool {
guard let digit = parseDigit() else {
return false
@@ -199,7 +195,6 @@ final class SQLiteDateParser {
return true
}
@inline(__always)
mutating func parseNNNN() -> Int? {
var number = 0
guard parseDigit(into: &number)
@@ -213,7 +208,6 @@ final class SQLiteDateParser {
return number
}
@inline(__always)
mutating func parseNN() -> Int? {
var number = 0
guard parseDigit(into: &number)
-1
View File
@@ -49,7 +49,6 @@ extension UUID: DatabaseValueConvertible {
}
extension UUID: StatementColumnConvertible {
@inlinable
public init?(sqliteStatement: SQLiteStatement, index: Int32) {
switch sqlite3_column_type(sqliteStatement, index) {
case SQLITE_TEXT:
@@ -18,7 +18,6 @@ extension SQLExpressible where Self: RawRepresentable, Self.RawValue: SQLExpress
}
extension StatementBinding where Self: RawRepresentable, Self.RawValue: StatementBinding {
@inlinable
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
rawValue.bind(to: sqliteStatement, at: index)
}
@@ -38,7 +37,6 @@ extension StatementBinding where Self: RawRepresentable, Self.RawValue: Statemen
/// // adopt DatabaseValueConvertible:
/// extension Color: DatabaseValueConvertible { }
extension DatabaseValueConvertible where Self: RawRepresentable, Self.RawValue: DatabaseValueConvertible {
@inlinable
public var databaseValue: DatabaseValue {
rawValue.databaseValue
}
@@ -8,13 +8,11 @@ extension Bool: DatabaseValueConvertible, StatementColumnConvertible {
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
@inlinable
public init(sqliteStatement: SQLiteStatement, index: Int32) {
self = sqlite3_column_int64(sqliteStatement, index) != 0
}
/// Returns a value that can be stored in the database.
@inlinable
public var databaseValue: DatabaseValue {
(self ? 1 : 0).databaseValue
}
@@ -87,7 +85,6 @@ extension Bool: DatabaseValueConvertible, StatementColumnConvertible {
}
}
@inlinable
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
sqlite3_bind_int64(sqliteStatement, index, self ? 1 : 0)
}
@@ -101,7 +98,6 @@ extension Int: DatabaseValueConvertible, StatementColumnConvertible {
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
@inlinable
public init?(sqliteStatement: SQLiteStatement, index: Int32) {
let int64 = sqlite3_column_int64(sqliteStatement, index)
guard let v = Int(exactly: int64) else { return nil }
@@ -109,7 +105,6 @@ extension Int: DatabaseValueConvertible, StatementColumnConvertible {
}
/// Returns a value that can be stored in the database.
@inlinable
public var databaseValue: DatabaseValue {
Int64(self).databaseValue
}
@@ -119,7 +114,6 @@ extension Int: DatabaseValueConvertible, StatementColumnConvertible {
Int64.fromDatabaseValue(dbValue).flatMap { Int(exactly: $0) }
}
@inlinable
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
sqlite3_bind_int64(sqliteStatement, index, Int64(self))
}
@@ -133,7 +127,6 @@ extension Int8: DatabaseValueConvertible, StatementColumnConvertible {
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
@inlinable
public init?(sqliteStatement: SQLiteStatement, index: Int32) {
let int64 = sqlite3_column_int64(sqliteStatement, index)
guard let v = Int8(exactly: int64) else { return nil }
@@ -141,7 +134,6 @@ extension Int8: DatabaseValueConvertible, StatementColumnConvertible {
}
/// Returns a value that can be stored in the database.
@inlinable
public var databaseValue: DatabaseValue {
Int64(self).databaseValue
}
@@ -151,7 +143,6 @@ extension Int8: DatabaseValueConvertible, StatementColumnConvertible {
Int64.fromDatabaseValue(dbValue).flatMap { Int8(exactly: $0) }
}
@inlinable
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
sqlite3_bind_int64(sqliteStatement, index, Int64(self))
}
@@ -165,7 +156,6 @@ extension Int16: DatabaseValueConvertible, StatementColumnConvertible {
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
@inlinable
public init?(sqliteStatement: SQLiteStatement, index: Int32) {
let int64 = sqlite3_column_int64(sqliteStatement, index)
guard let v = Int16(exactly: int64) else { return nil }
@@ -173,7 +163,6 @@ extension Int16: DatabaseValueConvertible, StatementColumnConvertible {
}
/// Returns a value that can be stored in the database.
@inlinable
public var databaseValue: DatabaseValue {
Int64(self).databaseValue
}
@@ -183,7 +172,6 @@ extension Int16: DatabaseValueConvertible, StatementColumnConvertible {
Int64.fromDatabaseValue(dbValue).flatMap { Int16(exactly: $0) }
}
@inlinable
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
sqlite3_bind_int64(sqliteStatement, index, Int64(self))
}
@@ -197,7 +185,6 @@ extension Int32: DatabaseValueConvertible, StatementColumnConvertible {
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
@inlinable
public init?(sqliteStatement: SQLiteStatement, index: Int32) {
let int64 = sqlite3_column_int64(sqliteStatement, index)
guard let v = Int32(exactly: int64) else { return nil }
@@ -205,7 +192,6 @@ extension Int32: DatabaseValueConvertible, StatementColumnConvertible {
}
/// Returns a value that can be stored in the database.
@inlinable
public var databaseValue: DatabaseValue {
Int64(self).databaseValue
}
@@ -215,7 +201,6 @@ extension Int32: DatabaseValueConvertible, StatementColumnConvertible {
Int64.fromDatabaseValue(dbValue).flatMap { Int32(exactly: $0) }
}
@inlinable
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
sqlite3_bind_int64(sqliteStatement, index, Int64(self))
}
@@ -229,13 +214,11 @@ extension Int64: DatabaseValueConvertible, StatementColumnConvertible {
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
@inlinable
public init(sqliteStatement: SQLiteStatement, index: Int32) {
self = sqlite3_column_int64(sqliteStatement, index)
}
/// Returns a value that can be stored in the database.
@inlinable
public var databaseValue: DatabaseValue {
DatabaseValue(storage: .int64(self))
}
@@ -254,7 +237,6 @@ extension Int64: DatabaseValueConvertible, StatementColumnConvertible {
}
}
@inlinable
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
sqlite3_bind_int64(sqliteStatement, index, self)
}
@@ -268,7 +250,6 @@ extension UInt: DatabaseValueConvertible, StatementColumnConvertible {
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
@inlinable
public init?(sqliteStatement: SQLiteStatement, index: Int32) {
let int64 = sqlite3_column_int64(sqliteStatement, index)
guard let v = UInt(exactly: int64) else { return nil }
@@ -276,7 +257,6 @@ extension UInt: DatabaseValueConvertible, StatementColumnConvertible {
}
/// Returns a value that can be stored in the database.
@inlinable
public var databaseValue: DatabaseValue {
Int64(self).databaseValue
}
@@ -286,7 +266,6 @@ extension UInt: DatabaseValueConvertible, StatementColumnConvertible {
Int64.fromDatabaseValue(dbValue).flatMap { UInt(exactly: $0) }
}
@inlinable
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
sqlite3_bind_int64(sqliteStatement, index, Int64(self))
}
@@ -300,7 +279,6 @@ extension UInt8: DatabaseValueConvertible, StatementColumnConvertible {
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
@inlinable
public init?(sqliteStatement: SQLiteStatement, index: Int32) {
let int64 = sqlite3_column_int64(sqliteStatement, index)
guard let v = UInt8(exactly: int64) else { return nil }
@@ -308,7 +286,6 @@ extension UInt8: DatabaseValueConvertible, StatementColumnConvertible {
}
/// Returns a value that can be stored in the database.
@inlinable
public var databaseValue: DatabaseValue {
Int64(self).databaseValue
}
@@ -318,7 +295,6 @@ extension UInt8: DatabaseValueConvertible, StatementColumnConvertible {
Int64.fromDatabaseValue(dbValue).flatMap { UInt8(exactly: $0) }
}
@inlinable
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
sqlite3_bind_int64(sqliteStatement, index, Int64(self))
}
@@ -332,7 +308,6 @@ extension UInt16: DatabaseValueConvertible, StatementColumnConvertible {
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
@inlinable
public init?(sqliteStatement: SQLiteStatement, index: Int32) {
let int64 = sqlite3_column_int64(sqliteStatement, index)
guard let v = UInt16(exactly: int64) else { return nil }
@@ -340,7 +315,6 @@ extension UInt16: DatabaseValueConvertible, StatementColumnConvertible {
}
/// Returns a value that can be stored in the database.
@inlinable
public var databaseValue: DatabaseValue {
Int64(self).databaseValue
}
@@ -350,7 +324,6 @@ extension UInt16: DatabaseValueConvertible, StatementColumnConvertible {
Int64.fromDatabaseValue(dbValue).flatMap { UInt16(exactly: $0) }
}
@inlinable
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
sqlite3_bind_int64(sqliteStatement, index, Int64(self))
}
@@ -364,7 +337,6 @@ extension UInt32: DatabaseValueConvertible, StatementColumnConvertible {
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
@inlinable
public init?(sqliteStatement: SQLiteStatement, index: Int32) {
let int64 = sqlite3_column_int64(sqliteStatement, index)
guard let v = UInt32(exactly: int64) else { return nil }
@@ -372,7 +344,6 @@ extension UInt32: DatabaseValueConvertible, StatementColumnConvertible {
}
/// Returns a value that can be stored in the database.
@inlinable
public var databaseValue: DatabaseValue {
Int64(self).databaseValue
}
@@ -382,7 +353,6 @@ extension UInt32: DatabaseValueConvertible, StatementColumnConvertible {
Int64.fromDatabaseValue(dbValue).flatMap { UInt32(exactly: $0) }
}
@inlinable
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
sqlite3_bind_int64(sqliteStatement, index, Int64(self))
}
@@ -396,7 +366,6 @@ extension UInt64: DatabaseValueConvertible, StatementColumnConvertible {
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
@inlinable
public init?(sqliteStatement: SQLiteStatement, index: Int32) {
let int64 = sqlite3_column_int64(sqliteStatement, index)
guard let v = UInt64(exactly: int64) else { return nil }
@@ -404,7 +373,6 @@ extension UInt64: DatabaseValueConvertible, StatementColumnConvertible {
}
/// Returns a value that can be stored in the database.
@inlinable
public var databaseValue: DatabaseValue {
Int64(self).databaseValue
}
@@ -414,7 +382,6 @@ extension UInt64: DatabaseValueConvertible, StatementColumnConvertible {
Int64.fromDatabaseValue(dbValue).flatMap { UInt64(exactly: $0) }
}
@inlinable
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
sqlite3_bind_int64(sqliteStatement, index, Int64(self))
}
@@ -428,13 +395,11 @@ extension Double: DatabaseValueConvertible, StatementColumnConvertible {
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
@inlinable
public init(sqliteStatement: SQLiteStatement, index: Int32) {
self = sqlite3_column_double(sqliteStatement, index)
}
/// Returns a value that can be stored in the database.
@inlinable
public var databaseValue: DatabaseValue {
DatabaseValue(storage: .double(self))
}
@@ -451,7 +416,6 @@ extension Double: DatabaseValueConvertible, StatementColumnConvertible {
}
}
@inlinable
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
sqlite3_bind_double(sqliteStatement, index, self)
}
@@ -465,13 +429,11 @@ extension Float: DatabaseValueConvertible, StatementColumnConvertible {
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
@inlinable
public init(sqliteStatement: SQLiteStatement, index: Int32) {
self = Float(sqlite3_column_double(sqliteStatement, index))
}
/// Returns a value that can be stored in the database.
@inlinable
public var databaseValue: DatabaseValue {
Double(self).databaseValue
}
@@ -488,7 +450,6 @@ extension Float: DatabaseValueConvertible, StatementColumnConvertible {
}
}
@inlinable
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
sqlite3_bind_double(sqliteStatement, index, Double(self))
}
@@ -502,13 +463,11 @@ extension String: DatabaseValueConvertible, StatementColumnConvertible {
/// - parameters:
/// - sqliteStatement: A pointer to an SQLite statement.
/// - index: The column index.
@inlinable
public init(sqliteStatement: SQLiteStatement, index: Int32) {
self = String(cString: sqlite3_column_text(sqliteStatement, index)!)
}
/// Returns a value that can be stored in the database.
@inlinable
public var databaseValue: DatabaseValue {
DatabaseValue(storage: .string(self))
}
@@ -527,7 +486,6 @@ extension String: DatabaseValueConvertible, StatementColumnConvertible {
}
}
@inlinable
public func bind(to sqliteStatement: SQLiteStatement, at index: CInt) -> CInt {
sqlite3_bind_text(sqliteStatement, index, self, -1, SQLITE_TRANSIENT)
}
+1
View File
@@ -881,6 +881,7 @@ typealias StatementObservation = (TransactionObservation, DatabaseEventPredicate
/// A kind of database event. See the `TransactionObserver` protocol for
/// more information.
@frozen
public enum DatabaseEventKind {
/// The insertion of a row in a database table
case insert(tableName: String)
@@ -41,4 +41,15 @@ extension TableRecord {
all().matching(pattern)
}
}
extension ColumnExpression {
/// A matching SQL expression with the `MATCH` SQL operator.
///
/// // content MATCH '...'
/// Column("content").match(pattern)
public func match(_ pattern: FTS5Pattern) -> SQLExpression {
.binary(.match, sqlExpression, pattern.sqlExpression)
}
}
#endif
@@ -45,7 +45,6 @@ public protocol Association: _Association, DerivableRequest {
extension Association {
/// Returns self modified with the *update* function.
@inline(__always)
func with(_ update: (inout Self) throws -> Void) rethrows -> Self {
var result = self
try update(&result)
@@ -53,7 +52,6 @@ extension Association {
}
/// Returns self with destination relation modified with the *update* function.
@inline(__always)
fileprivate func withDestinationRelation(_ update: (inout SQLRelation) throws -> Void) rethrows -> Self {
var result = self
try update(&result._sqlAssociation.destination.relation)
@@ -19,14 +19,16 @@ public struct CommonTableExpression<RowDecoder> {
/// For example:
///
/// // WITH p AS (SELECT * FROM player) ...
/// let p = CommonTableExpression<Void>(
/// let p = CommonTableExpression(
/// named: "p",
/// request: Player.all())
/// request: Player.all(),
/// type: Void.self)
///
/// // WITH p AS (SELECT * FROM player) ...
/// let p = CommonTableExpression<Void>(
/// let p = CommonTableExpression(
/// named: "p",
/// request: SQLRequest<Player>(sql: "SELECT * FROM player"))
/// request: SQLRequest<Player>(sql: "SELECT * FROM player"),
/// type: Void.self)
///
/// - parameter recursive: Whether this common table expression needs a
/// `WITH RECURSIVE` sql clause.
@@ -113,7 +115,7 @@ extension CommonTableExpression {
recursive: recursive,
named: tableName,
columns: columns,
request: SQLRequest<Void>(sql: sql, arguments: arguments),
request: SQLRequest(sql: sql, arguments: arguments),
type: RowDecoder.self)
}
@@ -144,7 +146,7 @@ extension CommonTableExpression {
recursive: recursive,
named: tableName,
columns: columns,
request: SQLRequest<Void>(literal: sqlLiteral),
request: SQLRequest(literal: sqlLiteral),
type: RowDecoder.self)
}
}
@@ -213,7 +215,7 @@ extension CommonTableExpression where RowDecoder == Row {
recursive: recursive,
named: tableName,
columns: columns,
request: SQLRequest<Void>(sql: sql, arguments: arguments),
request: SQLRequest(sql: sql, arguments: arguments),
type: Row.self)
}
@@ -244,7 +246,7 @@ extension CommonTableExpression where RowDecoder == Row {
recursive: recursive,
named: tableName,
columns: columns,
request: SQLRequest<Void>(literal: sqlLiteral),
request: SQLRequest(literal: sqlLiteral),
type: Row.self)
}
}
@@ -405,7 +405,11 @@ extension TableRequest where Self: AggregatingRequest {
return [Column(rowIDColumn)]
} else if primaryKey.tableHasRowID {
// Prefer the rowid
#if compiler(>=5.5)
return [.rowID]
#else
return [Column.rowID]
#endif
} else {
// WITHOUT ROWID table: group by primary key columns
return primaryKey.columns.map { Column($0) }
+13
View File
@@ -30,6 +30,13 @@ extension ColumnExpression {
}
}
#if compiler(>=5.5)
extension ColumnExpression where Self == Column {
/// The hidden rowID column
public static var rowID: Self { Column.rowID }
}
#endif
/// A column in a database table.
///
/// When you need to introduce your own column type, don't wrap a Column.
@@ -52,6 +59,12 @@ public struct Column: ColumnExpression, Equatable {
public init(_ codingKey: CodingKey) {
self.name = codingKey.stringValue
}
// Avoid a wrong resolution when BUILD_LIBRARY_FOR_DISTRIBUTION is set
@_disfavoredOverload
public static func == (lhs: Column, rhs: Column) -> Bool {
lhs.name == rhs.name
}
}
/// Support for column enums:
@@ -1565,6 +1565,13 @@ public protocol SQLExpressible {
var sqlExpression: SQLExpression { get }
}
#if compiler(>=5.5)
extension SQLExpressible where Self == Column {
/// The hidden rowID column
public static var rowID: Self { Column.rowID }
}
#endif
/// `SQLSpecificExpressible` is a protocol for all database-specific types that
/// can be turned into an SQL expression. Types whose existence is not purely
/// dedicated to the database should adopt the `SQLExpressible`
+11 -1
View File
@@ -22,15 +22,25 @@ public func average(_ value: SQLSpecificExpressible) -> SQLExpression {
// MARK: - COUNT(...)
// TODO: deprecate, replace with count(expression)
/// Returns an expression that evaluates the `COUNT` SQL function.
///
/// // COUNT(email)
/// count(Column("email"))
///
/// :nodoc:
@available(*, deprecated)
public func count(_ counted: SQLSelectable) -> SQLExpression {
counted.sqlSelection.countExpression
}
/// Returns an expression that evaluates the `COUNT` SQL function.
///
/// // COUNT(email)
/// count(Column("email"))
public func count(_ counted: SQLSpecificExpressible) -> SQLExpression {
.count(counted.sqlExpression)
}
// MARK: - COUNT(DISTINCT ...)
@@ -965,20 +965,17 @@ protocol ColumnAddressable {
struct DummyRow: ColumnAddressable {
struct DummyIndex { }
func index(forColumn column: String) -> DummyIndex? { DummyIndex() }
@inline(__always)
func databaseValue(at index: DummyIndex) -> DatabaseValue { DatabaseValue(storage: .int64(1)) }
}
/// Row has columns
extension Row: ColumnAddressable {
@inline(__always)
func databaseValue(at index: Int) -> DatabaseValue { self[index] }
}
/// PersistenceContainer has columns
extension PersistenceContainer: ColumnAddressable {
func index(forColumn column: String) -> String? { column }
@inline(__always)
func databaseValue(at column: String) -> DatabaseValue {
self[caseInsensitive: column]?.databaseValue ?? .null
}
+1 -2
View File
@@ -74,8 +74,7 @@ extension SQLSelection {
}
}
/// Support for `count(selection)`.
/// TODO: deprecate `count(selection)`, and get rid of this property.
/// TODO: remove when `count(_ counted: SQLSelectable)` is removed.
var countExpression: SQLExpression {
switch impl {
case .allColumns:
@@ -120,12 +120,10 @@ private class RecordEncoder<Record: EncodableRecord>: Encoder {
}
/// Helper methods
@inline(__always)
fileprivate func persist(_ value: DatabaseValueConvertible?, forKey key: CodingKey) {
_persistenceContainer[key.stringValue] = value
}
@inline(__always)
fileprivate func encode<T>(_ value: T, forKey key: CodingKey) throws where T: Encodable {
if let date = value as? Date {
persist(Record.databaseDateEncodingStrategy.encode(date), forKey: key)
@@ -236,7 +234,6 @@ private var iso8601Formatter: ISO8601DateFormatter = {
}()
extension DatabaseDateEncodingStrategy {
@inline(__always)
fileprivate func encode(_ date: Date) -> DatabaseValueConvertible? {
switch self {
case .deferredToDate:
@@ -264,7 +261,6 @@ extension DatabaseDateEncodingStrategy {
}
extension DatabaseUUIDEncodingStrategy {
@inline(__always)
fileprivate func encode(_ uuid: UUID) -> DatabaseValueConvertible? {
switch self {
case .deferredToUUID:
+1 -3
View File
@@ -195,14 +195,13 @@ public struct PersistenceContainer {
// fileprivate for Row(_:PersistenceContainer)
// The ordering of the OrderedDictionary helps generating always the same
// SQL queries, and hit the statement cache.
@usableFromInline var storage: OrderedDictionary<String, DatabaseValueConvertible?>
fileprivate var storage: OrderedDictionary<String, DatabaseValueConvertible?>
/// Accesses the value associated with the given column.
///
/// It is undefined behavior to set different values for the same column.
/// Column names are case insensitive, so defining both "name" and "NAME"
/// is considered undefined behavior.
@inlinable
public subscript(_ column: String) -> DatabaseValueConvertible? {
get { storage[column] ?? nil }
set { storage.updateValue(newValue, forKey: column) }
@@ -213,7 +212,6 @@ public struct PersistenceContainer {
/// It is undefined behavior to set different values for the same column.
/// Column names are case insensitive, so defining both "name" and "NAME"
/// is considered undefined behavior.
@inlinable
public subscript<Column: ColumnExpression>(_ column: Column) -> DatabaseValueConvertible? {
get { self[column.name] }
set { self[column.name] = newValue }
@@ -238,7 +238,6 @@ private struct _RowDecoder<R: FetchableRecord>: Decoder {
// Helper methods
@inline(__always)
private func decode<T>(
_ type: T.Type,
fromRow row: Row,
@@ -255,7 +254,6 @@ private struct _RowDecoder<R: FetchableRecord>: Decoder {
}
}
@inline(__always)
private func decode<T>(
_ type: T.Type,
fromRow row: Row,
@@ -404,7 +402,6 @@ private var iso8601Formatter: ISO8601DateFormatter = {
}()
extension DatabaseDateDecodingStrategy {
@inline(__always)
fileprivate func decodeIfPresent(fromRow row: Row, atUncheckedIndex index: Int) throws -> Date? {
if let sqliteStatement = row.sqliteStatement {
return try decodeIfPresent(
@@ -418,7 +415,6 @@ extension DatabaseDateDecodingStrategy {
}
}
@inline(__always)
fileprivate func decode(fromRow row: Row, atUncheckedIndex index: Int) throws -> Date {
if let sqliteStatement = row.sqliteStatement {
return try decode(
@@ -432,7 +428,6 @@ extension DatabaseDateDecodingStrategy {
}
}
@inline(__always)
fileprivate func decode(
fromStatement sqliteStatement: SQLiteStatement,
atUncheckedIndex index: Int32,
@@ -491,7 +486,6 @@ extension DatabaseDateDecodingStrategy {
}
}
@inline(__always)
fileprivate func decodeIfPresent(
fromStatement sqliteStatement: SQLiteStatement,
atUncheckedIndex index: Int32,
@@ -504,7 +498,6 @@ extension DatabaseDateDecodingStrategy {
return try decode(fromStatement: sqliteStatement, atUncheckedIndex: index, context: context())
}
@inline(__always)
fileprivate func decode(
fromDatabaseValue dbValue: DatabaseValue,
context: @autoclosure () -> RowDecodingContext)
@@ -517,7 +510,6 @@ extension DatabaseDateDecodingStrategy {
}
}
@inline(__always)
fileprivate func decodeIfPresent(
fromDatabaseValue dbValue: DatabaseValue,
context: @autoclosure () -> RowDecodingContext)
@@ -533,7 +525,6 @@ extension DatabaseDateDecodingStrategy {
}
// Returns nil if decoding fails
@inline(__always)
private func dateFromDatabaseValue(_ dbValue: DatabaseValue) -> Date? {
switch self {
case .deferredToDate:
+9 -10
View File
@@ -254,7 +254,7 @@ extension FetchableRecord {
adapter: RowAdapter? = nil)
throws -> RecordCursor<Self>
{
try fetchCursor(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchCursor(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
/// Returns an array of records fetched from an SQL query.
@@ -275,7 +275,7 @@ extension FetchableRecord {
adapter: RowAdapter? = nil)
throws -> [Self]
{
try fetchAll(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchAll(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
/// Returns a single record fetched from an SQL query.
@@ -296,7 +296,7 @@ extension FetchableRecord {
adapter: RowAdapter? = nil)
throws -> Self?
{
try fetchOne(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchOne(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
@@ -319,7 +319,7 @@ extension FetchableRecord where Self: Hashable {
adapter: RowAdapter? = nil)
throws -> Set<Self>
{
try fetchSet(db, SQLRequest<Void>(sql: sql, arguments: arguments, adapter: adapter))
try fetchSet(db, SQLRequest(sql: sql, arguments: arguments, adapter: adapter))
}
}
@@ -494,14 +494,14 @@ extension FetchRequest where RowDecoder: FetchableRecord & Hashable {
/// let players: RecordCursor<Player> = try Player.fetchCursor(db, sql: "SELECT * FROM player")
/// }
public final class RecordCursor<Record: FetchableRecord>: Cursor {
@usableFromInline enum _State {
private enum _State {
case idle, busy, done, failed
}
@usableFromInline let _statement: Statement
@usableFromInline let _row: Row // Reused for performance
@usableFromInline let _sqliteStatement: SQLiteStatement
@usableFromInline var _state = _State.idle
private let _statement: Statement
private let _row: Row // Reused for performance
private let _sqliteStatement: SQLiteStatement
private var _state = _State.idle
init(statement: Statement, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws {
_statement = statement
@@ -522,7 +522,6 @@ public final class RecordCursor<Record: FetchableRecord>: Cursor {
try? _statement.reset()
}
@inlinable
public func next() throws -> Record? {
switch _state {
case .done:
+2 -17
View File
@@ -1,5 +1,5 @@
extension Database.ConflictResolution {
@usableFromInline var invalidatesLastInsertedRowID: Bool {
var invalidatesLastInsertedRowID: Bool {
switch self {
case .abort, .fail, .rollback, .replace:
return false
@@ -350,7 +350,6 @@ extension MutablePersistableRecord {
// MARK: - CRUD Internals
/// Return a non-nil dictionary if record has a non-null primary key
@usableFromInline
func primaryKey(_ db: Database) throws -> [String: DatabaseValue]? {
let databaseTableName = type(of: self).databaseTableName
let primaryKeyInfo = try db.primaryKey(databaseTableName)
@@ -371,7 +370,6 @@ extension MutablePersistableRecord {
/// that adopt MutablePersistableRecord can invoke performInsert() in their
/// implementation of insert(). They should not provide their own
/// implementation of performInsert().
@inlinable
public mutating func performInsert(_ db: Database) throws {
let conflictResolutionForInsert = type(of: self).persistenceConflictPolicy.conflictResolutionForInsert
let dao = try DAO(db, self)
@@ -395,7 +393,6 @@ extension MutablePersistableRecord {
/// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
/// PersistenceError.recordNotFound is thrown if the primary key does not
/// match any row in the database.
@inlinable
public func performUpdate(_ db: Database, columns: Set<String>) throws {
let dao = try DAO(db, self)
guard let statement = try dao.updateStatement(
@@ -420,7 +417,6 @@ extension MutablePersistableRecord {
/// implementation of performSave().
///
/// This default implementation forwards the job to `update` or `insert`.
@inlinable
public mutating func performSave(_ db: Database) throws {
// Call self.insert and self.update so that we support classes that
// override those methods.
@@ -442,7 +438,6 @@ extension MutablePersistableRecord {
/// that adopt MutablePersistableRecord can invoke performDelete() in
/// their implementation of delete(). They should not provide their own
/// implementation of performDelete().
@inlinable
public func performDelete(_ db: Database) throws -> Bool {
guard let statement = try DAO(db, self).deleteStatement() else {
// Nil primary key
@@ -459,7 +454,6 @@ extension MutablePersistableRecord {
/// that adopt MutablePersistableRecord can invoke performExists() in
/// their implementation of exists(). They should not provide their own
/// implementation of performExists().
@inlinable
public func performExists(_ db: Database) throws -> Bool {
guard let statement = try DAO(db, self).existsStatement() else {
// Nil primary key
@@ -602,7 +596,6 @@ extension PersistableRecord {
/// that adopt PersistableRecord can invoke performInsert() in their
/// implementation of insert(). They should not provide their own
/// implementation of performInsert().
@inlinable
public func performInsert(_ db: Database) throws {
let conflictResolutionForInsert = type(of: self).persistenceConflictPolicy.conflictResolutionForInsert
let dao = try DAO(db, self)
@@ -622,7 +615,6 @@ extension PersistableRecord {
/// implementation of performSave().
///
/// This default implementation forwards the job to `update` or `insert`.
@inlinable
public func performSave(_ db: Database) throws {
// Call self.insert and self.update so that we support classes that
// override those methods.
@@ -651,7 +643,6 @@ extension PersistenceContainer {
}
/// DAO takes care of PersistableRecord CRUD
@usableFromInline
final class DAO<Record: MutablePersistableRecord> {
/// The database
let db: Database
@@ -665,9 +656,8 @@ final class DAO<Record: MutablePersistableRecord> {
let databaseTableName: String
/// The table primary key info
@usableFromInline let primaryKey: PrimaryKeyInfo
let primaryKey: PrimaryKeyInfo
@usableFromInline
init(_ db: Database, _ record: Record) throws {
self.db = db
databaseTableName = type(of: record).databaseTableName
@@ -676,7 +666,6 @@ final class DAO<Record: MutablePersistableRecord> {
GRDBPrecondition(!persistenceContainer.isEmpty, "\(type(of: record)): invalid empty persistence container")
}
@usableFromInline
func insertStatement(onConflict: Database.ConflictResolution) throws -> Statement {
let query = InsertQuery(
onConflict: onConflict,
@@ -688,7 +677,6 @@ final class DAO<Record: MutablePersistableRecord> {
}
/// Returns nil if and only if primary key is nil
@usableFromInline
func updateStatement(columns: Set<String>, onConflict: Database.ConflictResolution) throws -> Statement? {
// Fail early if primary key does not resolve to a database row.
let primaryKeyColumns = primaryKey.columns
@@ -738,7 +726,6 @@ final class DAO<Record: MutablePersistableRecord> {
}
/// Returns nil if and only if primary key is nil
@usableFromInline
func deleteStatement() throws -> Statement? {
// Fail early if primary key does not resolve to a database row.
let primaryKeyColumns = primaryKey.columns
@@ -758,7 +745,6 @@ final class DAO<Record: MutablePersistableRecord> {
}
/// Returns nil if and only if primary key is nil
@usableFromInline
func existsStatement() throws -> Statement? {
// Fail early if primary key does not resolve to a database row.
let primaryKeyColumns = primaryKey.columns
@@ -778,7 +764,6 @@ final class DAO<Record: MutablePersistableRecord> {
}
/// Throws a PersistenceError.recordNotFound error
@usableFromInline
func makeRecordNotFoundError() -> Error {
let key = Dictionary(uniqueKeysWithValues: primaryKey.columns.map {
($0, persistenceContainer[caseInsensitive: $0]?.databaseValue ?? .null)
+4 -14
View File
@@ -8,10 +8,9 @@
/// dict["bar"] // 2
/// dict["qux"] // nil
/// dict.map { $0.key } // ["foo", "bar"], in this order.
@usableFromInline
struct OrderedDictionary<Key: Hashable, Value> {
@usableFromInline /* private(set) */ var keys: [Key]
@usableFromInline /* private(set) */ var dictionary: [Key: Value]
private(set) var keys: [Key]
private(set) var dictionary: [Key: Value]
var values: [Value] { keys.map { dictionary[$0]! } }
@@ -35,7 +34,6 @@ struct OrderedDictionary<Key: Hashable, Value> {
}
/// Returns the value associated with key, or nil.
@usableFromInline
subscript(_ key: Key) -> Value? {
get { dictionary[key] }
set {
@@ -48,7 +46,6 @@ struct OrderedDictionary<Key: Hashable, Value> {
}
/// Returns the value associated with key, or the default value.
@inlinable
subscript(_ key: Key, default defaultValue: Value) -> Value {
get { dictionary[key] ?? defaultValue }
set { self[key] = newValue }
@@ -72,7 +69,6 @@ struct OrderedDictionary<Key: Hashable, Value> {
/// original value. If the given key is not present in the dictionary, this
/// method appends the key-value pair and returns nil.
@discardableResult
@usableFromInline
mutating func updateValue(_ value: Value, forKey key: Key) -> Value? {
if let oldValue = dictionary.updateValue(value, forKey: key) {
return oldValue
@@ -83,7 +79,6 @@ struct OrderedDictionary<Key: Hashable, Value> {
/// Removes the value associated with key.
@discardableResult
@inlinable
mutating func removeValue(forKey key: Key) -> Value? {
guard let value = dictionary.removeValue(forKey: key) else {
return nil
@@ -173,16 +168,13 @@ struct OrderedDictionary<Key: Hashable, Value> {
}
extension OrderedDictionary: Collection {
@usableFromInline
typealias Index = Int
@usableFromInline var startIndex: Int { 0 }
@usableFromInline var endIndex: Int { keys.count }
var startIndex: Int { 0 }
var endIndex: Int { keys.count }
@usableFromInline
func index(after i: Int) -> Int { i + 1 }
@usableFromInline
subscript(position: Int) -> (key: Key, value: Value) {
let key = keys[position]
return (key: key, value: dictionary[key]!)
@@ -190,7 +182,6 @@ extension OrderedDictionary: Collection {
}
extension OrderedDictionary: ExpressibleByDictionaryLiteral {
@usableFromInline
init(dictionaryLiteral elements: (Key, Value)...) {
self.keys = elements.map { $0.0 }
self.dictionary = Dictionary(uniqueKeysWithValues: elements)
@@ -198,7 +189,6 @@ extension OrderedDictionary: ExpressibleByDictionaryLiteral {
}
extension OrderedDictionary: Equatable where Value: Equatable {
@usableFromInline
static func == (lhs: OrderedDictionary, rhs: OrderedDictionary) -> Bool {
(lhs.keys == rhs.keys) && (lhs.dictionary == rhs.dictionary)
}
-1
View File
@@ -28,7 +28,6 @@ extension Refinable {
/// }
/// newPlayer.name // "Arthur"
/// newPlayer.score // 100
@inline(__always)
func with(_ update: (inout Self) throws -> Void) rethrows -> Self {
var result = self
try update(&result)
+1 -10
View File
@@ -7,7 +7,7 @@ extension String {
/// SQL query.
///
/// db.execute(sql: "SELECT * FROM \(tableName.quotedDatabaseIdentifier)")
@inlinable public var quotedDatabaseIdentifier: String {
public var quotedDatabaseIdentifier: String {
// See <https://www.sqlite.org/lang_keywords.html>
return "\"\(self)\""
}
@@ -16,7 +16,6 @@ extension String {
/// Return as many question marks separated with commas as the *count* argument.
///
/// databaseQuestionMarks(count: 3) // "?,?,?"
@inlinable
public func databaseQuestionMarks(count: Int) -> String {
repeatElement("?", count: count).joined(separator: ",")
}
@@ -37,7 +36,6 @@ extension Optional: _OptionalProtocol { }
// MARK: - Internal
/// Reserved for GRDB: do not use.
@inlinable
func GRDBPrecondition(
_ condition: @autoclosure() -> Bool,
_ message: @autoclosure() -> String = "",
@@ -52,7 +50,6 @@ func GRDBPrecondition(
}
}
@inlinable
func fatalError<E: Error>(_ error: E) -> Never {
try! { throw error }()
}
@@ -93,7 +90,6 @@ extension DispatchQueue {
}
extension Sequence {
@inlinable
func countElements(where predicate: (Element) throws -> Bool) rethrows -> Int {
var count = 0
for e in self where try predicate(e) {
@@ -112,7 +108,6 @@ extension Sequence {
/// try throwingFirstError(
/// execute: work,
/// finally: cleanup)
@inline(__always)
func throwingFirstError<T>(execute: () throws -> T, finally: () throws -> Void) throws -> T {
var result: T?
var firstError: Error?
@@ -171,8 +166,6 @@ func concat<T>(_ rhs: ((T) -> Void)?, _ lhs: ((T) -> Void)?) -> ((T) -> Void)? {
}
extension NSRecursiveLock {
@inlinable
@inline(__always)
func synchronized<T>(
_ message: @autoclosure () -> String = #function,
_ block: () throws -> T)
@@ -199,8 +192,6 @@ extension NSRecursiveLock {
/// Performs the side effect outside of the synchronized block. This allows
/// avoiding deadlocks, when the side effect feedbacks.
@inlinable
@inline(__always)
func synchronized(
_ message: @autoclosure () -> String = #function,
_ block: (inout (() -> Void)?) -> Void)
+3 -3
View File
@@ -438,10 +438,10 @@ ifdef JAZZY
--author 'Gwendal Roué' \
--author_url https://github.com/groue \
--github_url https://github.com/groue/GRDB.swift \
--github-file-prefix https://github.com/groue/GRDB.swift/tree/v5.9.0 \
--module-version 5.9.0 \
--github-file-prefix https://github.com/groue/GRDB.swift/tree/v5.10.0 \
--module-version 5.10.0 \
--module GRDB \
--root-url http://groue.github.io/GRDB.swift/docs/5.9/ \
--root-url http://groue.github.io/GRDB.swift/docs/5.10/ \
--output Documentation/Reference \
--xcodebuild-arguments -project,GRDB.xcodeproj,-scheme,GRDBiOS
else
+31 -24
View File
@@ -11,13 +11,13 @@
---
**Latest release**: August 15, 2021 • version 5.9.0 • [CHANGELOG](CHANGELOG.md) • [Migrating From GRDB 4 to GRDB 5](Documentation/GRDB5MigrationGuide.md)
**Latest release**: August 22, 2021 • version 5.10.0 • [CHANGELOG](CHANGELOG.md) • [Migrating From GRDB 4 to GRDB 5](Documentation/GRDB5MigrationGuide.md)
**Requirements**: iOS 10.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+ &bull; SQLite 3.8.5+ &bull; Swift 5.2+ / Xcode 11.4+
| Swift version | GRDB version |
| -------------- | ----------------------------------------------------------- |
| **Swift 5.2+** | **v5.9.0** |
| **Swift 5.2+** | **v5.10.0** |
| Swift 5.1 | [v4.14.0](https://github.com/groue/GRDB.swift/tree/v4.14.0) |
| Swift 5 | [v4.14.0](https://github.com/groue/GRDB.swift/tree/v4.14.0) |
| Swift 4.2 | [v4.14.0](https://github.com/groue/GRDB.swift/tree/v4.14.0) |
@@ -316,7 +316,7 @@ Documentation
#### Reference
- [GRDB Reference](http://groue.github.io/GRDB.swift/docs/5.9/index.html) (generated by [Jazzy](https://github.com/realm/jazzy))
- [GRDB Reference](http://groue.github.io/GRDB.swift/docs/5.10/index.html) (generated by [Jazzy](https://github.com/realm/jazzy))
#### Getting Started
@@ -510,7 +510,7 @@ let dbQueue = try DatabaseQueue(
configuration: config)
```
See [Configuration](http://groue.github.io/GRDB.swift/docs/5.9/Structs/Configuration.html) for more details.
See [Configuration](http://groue.github.io/GRDB.swift/docs/5.10/Structs/Configuration.html) for more details.
## Database Pools
@@ -590,7 +590,7 @@ let dbPool = try DatabasePool(
configuration: config)
```
See [Configuration](http://groue.github.io/GRDB.swift/docs/5.9/Structs/Configuration.html) for more details.
See [Configuration](http://groue.github.io/GRDB.swift/docs/5.10/Structs/Configuration.html) for more details.
Database pools are more memory-hungry than database queues. See [Memory Management](#memory-management) for more information.
@@ -650,7 +650,7 @@ try dbQueue.write { db in
}
```
The `?` and colon-prefixed keys like `:score` in the SQL query are the **statements arguments**. You pass arguments with arrays or dictionaries, as in the example above. See [Values](#values) for more information on supported arguments types (Bool, Int, String, Date, Swift enums, etc.), and [StatementArguments](http://groue.github.io/GRDB.swift/docs/5.9/Structs/StatementArguments.html) for a detailed documentation of SQLite arguments.
The `?` and colon-prefixed keys like `:score` in the SQL query are the **statements arguments**. You pass arguments with arrays or dictionaries, as in the example above. See [Values](#values) for more information on supported arguments types (Bool, Int, String, Date, Swift enums, etc.), and [StatementArguments](http://groue.github.io/GRDB.swift/docs/5.10/Structs/StatementArguments.html) for a detailed documentation of SQLite arguments.
You can also embed query arguments right into your SQL queries, with the `literal` argument label, as in the example below. See [SQL Interpolation] for more details.
@@ -908,7 +908,7 @@ try dbQueue.read { db in
let dictionary = try Dictionary(uniqueKeysWithValues: cursor)
```
- **Cursors adopt the [Cursor](http://groue.github.io/GRDB.swift/docs/5.9/Protocols/Cursor.html) protocol, which looks a lot like standard [lazy sequences](https://developer.apple.com/reference/swift/lazysequenceprotocol) of Swift.** As such, cursors come with many convenience methods: `compactMap`, `contains`, `dropFirst`, `dropLast`, `drop(while:)`, `enumerated`, `filter`, `first`, `flatMap`, `forEach`, `joined`, `joined(separator:)`, `max`, `max(by:)`, `min`, `min(by:)`, `map`, `prefix`, `prefix(while:)`, `reduce`, `reduce(into:)`, `suffix`:
- **Cursors adopt the [Cursor](http://groue.github.io/GRDB.swift/docs/5.10/Protocols/Cursor.html) protocol, which looks a lot like standard [lazy sequences](https://developer.apple.com/reference/swift/lazysequenceprotocol) of Swift.** As such, cursors come with many convenience methods: `compactMap`, `contains`, `dropFirst`, `dropLast`, `drop(while:)`, `enumerated`, `filter`, `first`, `flatMap`, `forEach`, `joined`, `joined(separator:)`, `max`, `max(by:)`, `min`, `min(by:)`, `map`, `prefix`, `prefix(while:)`, `reduce`, `reduce(into:)`, `suffix`:
```swift
// Prints all Github links
@@ -987,7 +987,7 @@ let rows = try Row.fetchAll(db,
arguments: ["name": "Arthur"])
```
See [Values](#values) for more information on supported arguments types (Bool, Int, String, Date, Swift enums, etc.), and [StatementArguments](http://groue.github.io/GRDB.swift/docs/5.9/Structs/StatementArguments.html) for a detailed documentation of SQLite arguments.
See [Values](#values) for more information on supported arguments types (Bool, Int, String, Date, Swift enums, etc.), and [StatementArguments](http://groue.github.io/GRDB.swift/docs/5.10/Structs/StatementArguments.html) for a detailed documentation of SQLite arguments.
Unlike row arrays that contain copies of the database rows, row cursors are close to the SQLite metal, and require a little care:
@@ -1272,7 +1272,7 @@ GRDB ships with built-in support for the following value types:
- Generally speaking, all types that adopt the [DatabaseValueConvertible](#custom-value-types) protocol.
Values can be used as [statement arguments](http://groue.github.io/GRDB.swift/docs/5.9/Structs/StatementArguments.html):
Values can be used as [statement arguments](http://groue.github.io/GRDB.swift/docs/5.10/Structs/StatementArguments.html):
```swift
let url: URL = ...
@@ -1719,7 +1719,7 @@ try dbQueue.inDatabase { db in // or dbPool.writeWithoutTransaction
}
```
Transactions can't be left opened unless you set the [allowsUnsafeTransactions](http://groue.github.io/GRDB.swift/docs/5.9/Structs/Configuration.html) configuration flag:
Transactions can't be left opened unless you set the [allowsUnsafeTransactions](http://groue.github.io/GRDB.swift/docs/5.10/Structs/Configuration.html) configuration flag:
```swift
// fatal error: A transaction has been left opened at the end of a database access
@@ -1831,7 +1831,7 @@ try dbQueue.write { db in
}
```
The `?` and colon-prefixed keys like `:name` in the SQL query are the statement arguments. You set them with arrays or dictionaries (arguments are actually of type [StatementArguments](http://groue.github.io/GRDB.swift/docs/5.9/Structs/StatementArguments.html), which happens to adopt the ExpressibleByArrayLiteral and ExpressibleByDictionaryLiteral protocols).
The `?` and colon-prefixed keys like `:name` in the SQL query are the statement arguments. You set them with arrays or dictionaries (arguments are actually of type [StatementArguments](http://groue.github.io/GRDB.swift/docs/5.10/Structs/StatementArguments.html), which happens to adopt the ExpressibleByArrayLiteral and ExpressibleByDictionaryLiteral protocols).
```swift
insertStatement.arguments = ["name": "Arthur", "score": 1000]
@@ -1914,7 +1914,7 @@ See also `Database.execute(sql:)` in the [Executing Updates](#executing-updates)
> :point_up: **Note**: it is a programmer error to reuse a prepared statement that has failed: GRDB may crash if you do so.
For more information about prepared statements, see the [Statement reference](http://groue.github.io/GRDB.swift/docs/5.9/Classes/Statement.html).
For more information about prepared statements, see the [Statement reference](http://groue.github.io/GRDB.swift/docs/5.10/Classes/Statement.html).
### Prepared Statements Cache
@@ -2657,7 +2657,7 @@ try Place.fetchSet(db, sql: "SELECT ...", arguments:...) // Set<Place>
try Place.fetchOne(db, sql: "SELECT ...", arguments:...) // Place?
```
See [fetching methods](#fetching-methods) for information about the `fetchCursor`, `fetchAll`, `fetchSet` and `fetchOne` methods. See [StatementArguments](http://groue.github.io/GRDB.swift/docs/5.9/Structs/StatementArguments.html) for more information about the query arguments.
See [fetching methods](#fetching-methods) for information about the `fetchCursor`, `fetchAll`, `fetchSet` and `fetchOne` methods. See [StatementArguments](http://groue.github.io/GRDB.swift/docs/5.10/Structs/StatementArguments.html) for more information about the query arguments.
> :point_up: **Note**: for performance reasons, the same row argument to `init(row:)` is reused during the iteration of a fetch query. If you want to keep the row for later use, make sure to store a copy: `self.row = row.copy()`.
@@ -3093,7 +3093,7 @@ protocol EncodableRecord {
}
```
See [DatabaseDateDecodingStrategy](https://groue.github.io/GRDB.swift/docs/5.9/Enums/DatabaseDateDecodingStrategy.html), [DatabaseDateEncodingStrategy](https://groue.github.io/GRDB.swift/docs/5.9/Enums/DatabaseDateEncodingStrategy.html), and [DatabaseUUIDEncodingStrategy](https://groue.github.io/GRDB.swift/docs/5.9/Enums/DatabaseUUIDEncodingStrategy.html) to learn about all available strategies.
See [DatabaseDateDecodingStrategy](https://groue.github.io/GRDB.swift/docs/5.10/Enums/DatabaseDateDecodingStrategy.html), [DatabaseDateEncodingStrategy](https://groue.github.io/GRDB.swift/docs/5.10/Enums/DatabaseDateEncodingStrategy.html), and [DatabaseUUIDEncodingStrategy](https://groue.github.io/GRDB.swift/docs/5.10/Enums/DatabaseUUIDEncodingStrategy.html) to learn about all available strategies.
> :point_up: **Note**: there is no customization of uuid decoding, because UUID can already decode all its encoded variants (16-bytes blobs, and uuid strings).
@@ -3581,7 +3581,7 @@ When SQLite won't let you provide an explicit primary key (as in [full-text](Doc
var id: Int64?
init(row: Row) {
id = row[Column.rowID]
id = row[Column.rowID] // or `row[.rowID]` with Swift 5.5+
}
}
```
@@ -3600,7 +3600,7 @@ When SQLite won't let you provide an explicit primary key (as in [full-text](Doc
var id: Int64?
func encode(to container: inout PersistenceContainer) {
container[Column.rowID] = id
container[Column.rowID] = id // or `container[.rowID]` with Swift 5.5+
container["message"] = message
container["date"] = date
}
@@ -4623,7 +4623,7 @@ Player // SELECT * FROM player
```
Raw SQL snippets are also accepted, with eventual [arguments](http://groue.github.io/GRDB.swift/docs/5.9/Structs/StatementArguments.html):
Raw SQL snippets are also accepted, with eventual [arguments](http://groue.github.io/GRDB.swift/docs/5.10/Structs/StatementArguments.html):
```swift
// SELECT DATE(creationDate), COUNT(*) FROM player WHERE name = 'Arthur' GROUP BY date(creationDate)
@@ -4834,7 +4834,7 @@ GRDB comes with a Swift version of many SQLite [built-in operators](https://sqli
```swift
// WITH selectedName AS (...)
// SELECT * FROM player WHERE name IN selectedName
let cte = CommonTableExpression<Void>(named: "selectedName", ...)
let cte = CommonTableExpression(named: "selectedName", ...)
Player
.with(cte)
.filter(cte.contains(nameColumn))
@@ -5342,7 +5342,7 @@ try Player.customRequest().fetchAll(db) // [Player]
- The `adapted(_:)` method eases the consumption of complex rows with [row adapters](#row-adapters). See [Joined Queries Support](#joined-queries-support) for some sample code that uses this method.
- [AnyFetchRequest](http://groue.github.io/GRDB.swift/docs/5.9/Structs/AnyFetchRequest.html): a type-erased request.
- [AnyFetchRequest](http://groue.github.io/GRDB.swift/docs/5.10/Structs/AnyFetchRequest.html): a type-erased request.
## Joined Queries Support
@@ -6520,7 +6520,7 @@ After `stopObservingDatabaseChangesUntilNextTransaction()`, the `databaseDidChan
### DatabaseRegion
**[DatabaseRegion](https://groue.github.io/GRDB.swift/docs/5.9/Structs/DatabaseRegion.html) is a type that helps observing changes in the results of a database [request](#requests)**.
**[DatabaseRegion](https://groue.github.io/GRDB.swift/docs/5.10/Structs/DatabaseRegion.html) is a type that helps observing changes in the results of a database [request](#requests)**.
A request knows which database modifications can impact its results. It can communicate this information to [transaction observers](#transactionobserver-protocol) by the way of a DatabaseRegion.
@@ -6530,7 +6530,7 @@ DatabaseRegion fuels, for example, [ValueObservation and DatabaseRegionObservati
For example, if you observe the region of `Player.select(max(Column("score")))`, then you'll get be notified of all changes performed on the `score` column of the `player` table (updates, insertions and deletions), even if they do not modify the value of the maximum score. However, you will not get any notification for changes performed on other database tables, or updates to other columns of the player table.
For more details, see the [reference](http://groue.github.io/GRDB.swift/docs/5.9/Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV10isModified2bySbAA0B5EventV_tF).
For more details, see the [reference](http://groue.github.io/GRDB.swift/docs/5.10/Structs/DatabaseRegion.html#/s:4GRDB14DatabaseRegionV10isModified2bySbAA0B5EventV_tF).
#### The DatabaseRegionConvertible Protocol
@@ -7650,7 +7650,7 @@ try snapshot2.read { db in
### DatabaseWriter and DatabaseReader Protocols
Both DatabaseQueue and DatabasePool adopt the [DatabaseReader](http://groue.github.io/GRDB.swift/docs/5.9/Protocols/DatabaseReader.html) and [DatabaseWriter](http://groue.github.io/GRDB.swift/docs/5.9/Protocols/DatabaseWriter.html) protocols. DatabaseSnapshot adopts DatabaseReader only.
Both DatabaseQueue and DatabasePool adopt the [DatabaseReader](http://groue.github.io/GRDB.swift/docs/5.10/Protocols/DatabaseReader.html) and [DatabaseWriter](http://groue.github.io/GRDB.swift/docs/5.10/Protocols/DatabaseWriter.html) protocols. DatabaseSnapshot adopts DatabaseReader only.
These protocols provide a unified API that let you write generic code that targets all concurrency modes. They fuel, for example:
@@ -7900,6 +7900,7 @@ FAQ
- [How do I monitor the duration of database statements execution?](#how-do-i-monitor-the-duration-of-database-statements-execution)
- [What Are Experimental Features?](#what-are-experimental-features)
- [Does GRDB support library evolution and ABI stability?](does-grdb-support-library-evolution-and-abi-stability)
**[FAQ: Associations](#faq-associations)**
@@ -8028,6 +8029,7 @@ db.trace { event in
- :arrow_up: [FAQ]
- [How do I monitor the duration of database statements execution?](#how-do-i-monitor-the-duration-of-database-statements-execution)
- [What Are Experimental Features?](#what-are-experimental-features)
- [Does GRDB support library evolution and ABI stability?](does-grdb-support-library-evolution-and-abi-stability)
### How do I monitor the duration of database statements execution?
@@ -8054,6 +8056,11 @@ try dbQueue.read { db in
}
```
### Does GRDB support library evolution and ABI stability?
No, GRDB does not support library evolution and ABI stability. The only promise is API stability according to [semantic versioning](http://semver.org), with an exception for [experimental features](#what-are-experimental-features).
Yet, GRDB can be built with the "Build Libraries for Distribution" Xcode option (`BUILD_LIBRARY_FOR_DISTRIBUTION`), so that you can build binary frameworks at your convenience.
## FAQ: Associations
@@ -8324,7 +8331,7 @@ When this is the case, there are two possible explanations:
try db.execute(sql: "UPDATE player SET name = ?", arguments: [name])
```
For more information, see [Double-quoted String Literals Are Accepted](https://sqlite.org/quirks.html#dblquote), and [Configuration.acceptsDoubleQuotedStringLiterals](http://groue.github.io/GRDB.swift/docs/5.9/Structs/Configuration.html#/s:4GRDB13ConfigurationV33acceptsDoubleQuotedStringLiteralsSbvp).
For more information, see [Double-quoted String Literals Are Accepted](https://sqlite.org/quirks.html#dblquote), and [Configuration.acceptsDoubleQuotedStringLiterals](http://groue.github.io/GRDB.swift/docs/5.10/Structs/Configuration.html#/s:4GRDB13ConfigurationV33acceptsDoubleQuotedStringLiteralsSbvp).
@@ -8491,7 +8498,7 @@ This chapter has been superseded by [ValueObservation] and [DatabaseRegionObserv
[Sharing a Database]: Documentation/SharingADatabase.md
[FAQ]: #faq
[Database Observation]: #database-changes-observation
[SQLRequest]: http://groue.github.io/GRDB.swift/docs/5.9/Structs/SQLRequest.html
[SQLRequest]: http://groue.github.io/GRDB.swift/docs/5.10/Structs/SQLRequest.html
[SQL literal]: Documentation/SQLInterpolation.md#sql-literal
[Identifiable]: https://developer.apple.com/documentation/swift/identifiable
[Query Interface Organization]: Documentation/QueryInterfaceOrganization.md
+1 -2
View File
@@ -4,5 +4,4 @@ TVOS_DEPLOYMENT_TARGET = 9.0
WATCHOS_DEPLOYMENT_TARGET = 2.0
//// Compile with all opt-in APIs
//GCC_PREPROCESSOR_DEFINITIONS = $(inherited) GRDB_SQLITE_ENABLE_PREUPDATE_HOOK=1
//OTHER_SWIFT_FLAGS = $(inherited) -D SQLITE_ENABLE_FTS5 -D SQLITE_ENABLE_PREUPDATE_HOOK
OTHER_SWIFT_FLAGS = $(inherited) -D SQLITE_ENABLE_FTS5
+1 -1
View File
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.9.0</string>
<string>5.10.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
+1 -4
View File
@@ -18,7 +18,6 @@
- [ ] Breaking: have DatabaseRegionObservation produce DatabaseCancellable just as ValueObservation.
- [ ] Can Swift 5.5 help us with `select(.all)` (request of RowDecoder), `select(.id)` (request of RowDecoder.ID), `select(.rowid)` (request of Int64)?
- [ ] Direct access to statement for bindings
- [ ] Breaking: make `fetchOne(key:)` type-safe (have a single dedicated primary key type)
- [ ] Property wrapper that decodes dictionaries (but how to tell the key column?)
- [X] See if SQLITE_FCNTL_DATA_VERSION could help working around the lack of snapshots in order to avoid double initial fetch of ValueObservation. Result: no, it does not look it returns values that are comparable between two distinct SQLite connections (from the initial reader, and from the writer thhat starts the observation)
- [ ] Grab all FTS tokens in a string
@@ -37,7 +36,7 @@
- [ ] Turn a hasMany to hasOne without first/last : hasMany(Book.self).filter(Column("isBest") /* assume a single book is flagged best */).asOne()
- [ ] Support for more kinds of joins: https://github.com/groue/GRDB.swift/issues/740
- [ ] HasAndBelongsToMany: https://github.com/groue/GRDB.swift/issues/711
- [ ] Support UNION https://github.com/groue/GRDB.swift/issues/671
- [ ] Support UNION https://github.com/groue/GRDB.swift/issues/671 (https://www.sqlite.org/lang_select.html#compound)
- [ ] request.exists(db) as an alternative to fetchOne(db) != nil. Can generate optimized SQL.
- [ ] Measure the duration of transactions
- [ ] Improve SQL generation for `Player.....fetchCount(db)`, especially with distinct. Try to avoid `SELECT COUNT(*) FROM (SELECT DISTINCT player.* ...)`
@@ -64,7 +63,6 @@
- [ ] Have SQLPrimaryKeyExpression embed the record type
- [ ] Remove support for suspended databases - https://inessential.com/2020/02/13/how_we_fixed_the_dreaded_0xdead10cc_cras
- [ ] https://sqlite.org/pragma.html#pragma_index_xinfo
- [ ] Deprecate DatabaseQueue/Pool.addFunction, collation, tokenizer: those should be done in Configuration.prepareDatabase
- [ ] filter(rowid:), filter(rowids:)
- [ ] https://github.com/apple/swift-evolution/blob/master/proposals/0075-import-test.md
- [ ] https://forums.swift.org/t/how-to-encode-objects-of-unknown-type/12253/6
@@ -73,7 +71,6 @@
- [ ] Not sure: type safety for SQL expressions
- [ ] Introduce some record protocol with an associated primary key type. Restrict filter(key:) methods to this type. Allow distinguishing FooId from BarId types.
- [ ] Replace Column with TypedColumn. How to avoid code duplication (repeated types)? Keypaths?
- [ ] Cursor.underestimatedCount, which could speed up Array(cursor) and fetchAll()
- [ ] Remove prefix from association keys when association name is namespaced: https://github.com/groue/GRDB.swift/issues/584#issuecomment-517658122
- [ ] Alternative support for custom SQLite builds, wih CocoaPods: https://github.com/CocoaPods/CocoaPods/issues/9103
@@ -34,7 +34,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let statement = try db.makeStatement(sql: sql)
try test(Fetched.fetchCursor(db, sql: sql))
try test(Fetched.fetchCursor(statement))
try test(Fetched.fetchCursor(db, SQLRequest<Void>(sql: sql)))
try test(Fetched.fetchCursor(db, SQLRequest(sql: sql)))
try test(SQLRequest<Fetched>(sql: sql).fetchCursor(db))
}
do {
@@ -43,7 +43,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchCursor(db, sql: sql, adapter: adapter))
try test(Fetched.fetchCursor(statement, adapter: adapter))
try test(Fetched.fetchCursor(db, SQLRequest<Void>(sql: sql, adapter: adapter)))
try test(Fetched.fetchCursor(db, SQLRequest(sql: sql, adapter: adapter)))
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchCursor(db))
}
}
@@ -86,7 +86,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let sql = "SELECT throw()"
try test(Fetched.fetchCursor(db, sql: sql), sql: sql)
try test(Fetched.fetchCursor(db.makeStatement(sql: sql)), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql).fetchCursor(db), sql: sql)
}
do {
@@ -94,7 +94,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchCursor(db, sql: sql, adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchCursor(db), sql: sql)
}
}
@@ -118,7 +118,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let sql = "SELECT * FROM nonExistingTable"
try test(Fetched.fetchCursor(db, sql: sql), sql: sql)
try test(Fetched.fetchCursor(db.makeStatement(sql: sql)), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql).fetchCursor(db), sql: sql)
}
do {
@@ -126,7 +126,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchCursor(db, sql: sql, adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchCursor(db), sql: sql)
}
}
@@ -143,7 +143,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let statement = try db.makeStatement(sql: sql)
try test(Fetched.fetchAll(db, sql: sql))
try test(Fetched.fetchAll(statement))
try test(Fetched.fetchAll(db, SQLRequest<Void>(sql: sql)))
try test(Fetched.fetchAll(db, SQLRequest(sql: sql)))
try test(SQLRequest<Fetched>(sql: sql).fetchAll(db))
}
do {
@@ -152,7 +152,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchAll(db, sql: sql, adapter: adapter))
try test(Fetched.fetchAll(statement, adapter: adapter))
try test(Fetched.fetchAll(db, SQLRequest<Void>(sql: sql, adapter: adapter)))
try test(Fetched.fetchAll(db, SQLRequest(sql: sql, adapter: adapter)))
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchAll(db))
}
}
@@ -187,7 +187,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let sql = "SELECT throw()"
try test(Fetched.fetchAll(db, sql: sql), sql: sql)
try test(Fetched.fetchAll(db.makeStatement(sql: sql)), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql).fetchAll(db), sql: sql)
}
do {
@@ -195,7 +195,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchAll(db, sql: sql, adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchAll(db), sql: sql)
}
}
@@ -219,7 +219,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let sql = "SELECT * FROM nonExistingTable"
try test(Fetched.fetchAll(db, sql: sql), sql: sql)
try test(Fetched.fetchAll(db.makeStatement(sql: sql)), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql).fetchAll(db), sql: sql)
}
do {
@@ -227,7 +227,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchAll(db, sql: sql, adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchAll(db), sql: sql)
}
}
@@ -244,7 +244,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let statement = try db.makeStatement(sql: sql)
try test(Fetched.fetchSet(db, sql: sql))
try test(Fetched.fetchSet(statement))
try test(Fetched.fetchSet(db, SQLRequest<Void>(sql: sql)))
try test(Fetched.fetchSet(db, SQLRequest(sql: sql)))
try test(SQLRequest<Fetched>(sql: sql).fetchSet(db))
}
do {
@@ -253,7 +253,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchSet(db, sql: sql, adapter: adapter))
try test(Fetched.fetchSet(statement, adapter: adapter))
try test(Fetched.fetchSet(db, SQLRequest<Void>(sql: sql, adapter: adapter)))
try test(Fetched.fetchSet(db, SQLRequest(sql: sql, adapter: adapter)))
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchSet(db))
}
}
@@ -288,7 +288,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let sql = "SELECT throw()"
try test(Fetched.fetchSet(db, sql: sql), sql: sql)
try test(Fetched.fetchSet(db.makeStatement(sql: sql)), sql: sql)
try test(Fetched.fetchSet(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Fetched.fetchSet(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql).fetchSet(db), sql: sql)
}
do {
@@ -296,7 +296,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchSet(db, sql: sql, adapter: adapter), sql: sql)
try test(Fetched.fetchSet(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Fetched.fetchSet(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Fetched.fetchSet(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchSet(db), sql: sql)
}
}
@@ -320,7 +320,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let sql = "SELECT * FROM nonExistingTable"
try test(Fetched.fetchSet(db, sql: sql), sql: sql)
try test(Fetched.fetchSet(db.makeStatement(sql: sql)), sql: sql)
try test(Fetched.fetchSet(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Fetched.fetchSet(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql).fetchSet(db), sql: sql)
}
do {
@@ -328,7 +328,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchSet(db, sql: sql, adapter: adapter), sql: sql)
try test(Fetched.fetchSet(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Fetched.fetchSet(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Fetched.fetchSet(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchSet(db), sql: sql)
}
}
@@ -346,7 +346,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let statement = try db.makeStatement(sql: sql)
try test(Fetched.fetchOne(db, sql: sql))
try test(Fetched.fetchOne(statement))
try test(Fetched.fetchOne(db, SQLRequest<Void>(sql: sql)))
try test(Fetched.fetchOne(db, SQLRequest(sql: sql)))
try test(SQLRequest<Fetched>(sql: sql).fetchOne(db))
}
do {
@@ -355,7 +355,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchOne(db, sql: sql, adapter: adapter))
try test(Fetched.fetchOne(statement, adapter: adapter))
try test(Fetched.fetchOne(db, SQLRequest<Void>(sql: sql, adapter: adapter)))
try test(Fetched.fetchOne(db, SQLRequest(sql: sql, adapter: adapter)))
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchOne(db))
}
}
@@ -368,7 +368,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let statement = try db.makeStatement(sql: sql)
try test(Fetched.fetchOne(db, sql: sql))
try test(Fetched.fetchOne(statement))
try test(Fetched.fetchOne(db, SQLRequest<Void>(sql: sql)))
try test(Fetched.fetchOne(db, SQLRequest(sql: sql)))
try test(SQLRequest<Fetched>(sql: sql).fetchOne(db))
}
do {
@@ -377,7 +377,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchOne(db, sql: sql, adapter: adapter))
try test(Fetched.fetchOne(statement, adapter: adapter))
try test(Fetched.fetchOne(db, SQLRequest<Void>(sql: sql, adapter: adapter)))
try test(Fetched.fetchOne(db, SQLRequest(sql: sql, adapter: adapter)))
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchOne(db))
}
}
@@ -390,7 +390,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let statement = try db.makeStatement(sql: sql)
try test(Fetched.fetchOne(db, sql: sql))
try test(Fetched.fetchOne(statement))
try test(Fetched.fetchOne(db, SQLRequest<Void>(sql: sql)))
try test(Fetched.fetchOne(db, SQLRequest(sql: sql)))
try test(SQLRequest<Fetched>(sql: sql).fetchOne(db))
}
do {
@@ -399,7 +399,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchOne(db, sql: sql, adapter: adapter))
try test(Fetched.fetchOne(statement, adapter: adapter))
try test(Fetched.fetchOne(db, SQLRequest<Void>(sql: sql, adapter: adapter)))
try test(Fetched.fetchOne(db, SQLRequest(sql: sql, adapter: adapter)))
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchOne(db))
}
}
@@ -435,7 +435,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let sql = "SELECT throw()"
try test(Fetched.fetchOne(db, sql: sql), sql: sql)
try test(Fetched.fetchOne(db.makeStatement(sql: sql)), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql).fetchOne(db), sql: sql)
}
do {
@@ -443,7 +443,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchOne(db, sql: sql, adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchOne(db), sql: sql)
}
}
@@ -467,7 +467,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let sql = "SELECT * FROM nonExistingTable"
try test(Fetched.fetchOne(db, sql: sql), sql: sql)
try test(Fetched.fetchOne(db.makeStatement(sql: sql)), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql).fetchOne(db), sql: sql)
}
do {
@@ -475,7 +475,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchOne(db, sql: sql, adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchOne(db), sql: sql)
}
}
@@ -497,7 +497,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let statement = try db.makeStatement(sql: sql)
try test(Optional<Fetched>.fetchCursor(db, sql: sql))
try test(Optional<Fetched>.fetchCursor(statement))
try test(Optional<Fetched>.fetchCursor(db, SQLRequest<Void>(sql: sql)))
try test(Optional<Fetched>.fetchCursor(db, SQLRequest(sql: sql)))
try test(SQLRequest<Fetched?>(sql: sql).fetchCursor(db))
}
do {
@@ -506,7 +506,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Optional<Fetched>.fetchCursor(db, sql: sql, adapter: adapter))
try test(Optional<Fetched>.fetchCursor(statement, adapter: adapter))
try test(Optional<Fetched>.fetchCursor(db, SQLRequest<Void>(sql: sql, adapter: adapter)))
try test(Optional<Fetched>.fetchCursor(db, SQLRequest(sql: sql, adapter: adapter)))
try test(SQLRequest<Fetched?>(sql: sql, adapter: adapter).fetchCursor(db))
}
}
@@ -549,7 +549,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let sql = "SELECT throw()"
try test(Optional<Fetched>.fetchCursor(db, sql: sql), sql: sql)
try test(Optional<Fetched>.fetchCursor(db.makeStatement(sql: sql)), sql: sql)
try test(Optional<Fetched>.fetchCursor(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Optional<Fetched>.fetchCursor(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched?>(sql: sql).fetchCursor(db), sql: sql)
}
do {
@@ -557,7 +557,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Optional<Fetched>.fetchCursor(db, sql: sql, adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchCursor(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchCursor(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Optional<Fetched>.fetchCursor(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched?>(sql: sql, adapter: adapter).fetchCursor(db), sql: sql)
}
}
@@ -581,7 +581,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let sql = "SELECT * FROM nonExistingTable"
try test(Optional<Fetched>.fetchCursor(db, sql: sql), sql: sql)
try test(Optional<Fetched>.fetchCursor(db.makeStatement(sql: sql)), sql: sql)
try test(Optional<Fetched>.fetchCursor(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Optional<Fetched>.fetchCursor(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched?>(sql: sql).fetchCursor(db), sql: sql)
}
do {
@@ -589,7 +589,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Optional<Fetched>.fetchCursor(db, sql: sql, adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchCursor(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchCursor(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Optional<Fetched>.fetchCursor(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched?>(sql: sql, adapter: adapter).fetchCursor(db), sql: sql)
}
}
@@ -608,7 +608,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let statement = try db.makeStatement(sql: sql)
try test(Optional<Fetched>.fetchAll(db, sql: sql))
try test(Optional<Fetched>.fetchAll(statement))
try test(Optional<Fetched>.fetchAll(db, SQLRequest<Void>(sql: sql)))
try test(Optional<Fetched>.fetchAll(db, SQLRequest(sql: sql)))
try test(SQLRequest<Fetched?>(sql: sql).fetchAll(db))
}
do {
@@ -617,7 +617,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Optional<Fetched>.fetchAll(db, sql: sql, adapter: adapter))
try test(Optional<Fetched>.fetchAll(statement, adapter: adapter))
try test(Optional<Fetched>.fetchAll(db, SQLRequest<Void>(sql: sql, adapter: adapter)))
try test(Optional<Fetched>.fetchAll(db, SQLRequest(sql: sql, adapter: adapter)))
try test(SQLRequest<Fetched?>(sql: sql, adapter: adapter).fetchAll(db))
}
}
@@ -652,7 +652,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let sql = "SELECT throw()"
try test(Optional<Fetched>.fetchAll(db, sql: sql), sql: sql)
try test(Optional<Fetched>.fetchAll(db.makeStatement(sql: sql)), sql: sql)
try test(Optional<Fetched>.fetchAll(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Optional<Fetched>.fetchAll(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched?>(sql: sql).fetchAll(db), sql: sql)
}
do {
@@ -660,7 +660,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Optional<Fetched>.fetchAll(db, sql: sql, adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchAll(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchAll(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Optional<Fetched>.fetchAll(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched?>(sql: sql, adapter: adapter).fetchAll(db), sql: sql)
}
}
@@ -684,7 +684,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let sql = "SELECT * FROM nonExistingTable"
try test(Optional<Fetched>.fetchAll(db, sql: sql), sql: sql)
try test(Optional<Fetched>.fetchAll(db.makeStatement(sql: sql)), sql: sql)
try test(Optional<Fetched>.fetchAll(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Optional<Fetched>.fetchAll(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched?>(sql: sql).fetchAll(db), sql: sql)
}
do {
@@ -692,7 +692,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Optional<Fetched>.fetchAll(db, sql: sql, adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchAll(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchAll(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Optional<Fetched>.fetchAll(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched?>(sql: sql, adapter: adapter).fetchAll(db), sql: sql)
}
}
@@ -709,7 +709,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let statement = try db.makeStatement(sql: sql)
try test(Optional<Fetched>.fetchSet(db, sql: sql))
try test(Optional<Fetched>.fetchSet(statement))
try test(Optional<Fetched>.fetchSet(db, SQLRequest<Void>(sql: sql)))
try test(Optional<Fetched>.fetchSet(db, SQLRequest(sql: sql)))
try test(SQLRequest<Fetched?>(sql: sql).fetchSet(db))
}
do {
@@ -718,7 +718,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Optional<Fetched>.fetchSet(db, sql: sql, adapter: adapter))
try test(Optional<Fetched>.fetchSet(statement, adapter: adapter))
try test(Optional<Fetched>.fetchSet(db, SQLRequest<Void>(sql: sql, adapter: adapter)))
try test(Optional<Fetched>.fetchSet(db, SQLRequest(sql: sql, adapter: adapter)))
try test(SQLRequest<Fetched?>(sql: sql, adapter: adapter).fetchSet(db))
}
}
@@ -753,7 +753,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let sql = "SELECT throw()"
try test(Optional<Fetched>.fetchSet(db, sql: sql), sql: sql)
try test(Optional<Fetched>.fetchSet(db.makeStatement(sql: sql)), sql: sql)
try test(Optional<Fetched>.fetchSet(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Optional<Fetched>.fetchSet(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched?>(sql: sql).fetchSet(db), sql: sql)
}
do {
@@ -761,7 +761,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Optional<Fetched>.fetchSet(db, sql: sql, adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchSet(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchSet(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Optional<Fetched>.fetchSet(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched?>(sql: sql, adapter: adapter).fetchSet(db), sql: sql)
}
}
@@ -785,7 +785,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let sql = "SELECT * FROM nonExistingTable"
try test(Optional<Fetched>.fetchSet(db, sql: sql), sql: sql)
try test(Optional<Fetched>.fetchSet(db.makeStatement(sql: sql)), sql: sql)
try test(Optional<Fetched>.fetchSet(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Optional<Fetched>.fetchSet(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched?>(sql: sql).fetchSet(db), sql: sql)
}
do {
@@ -793,7 +793,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Optional<Fetched>.fetchSet(db, sql: sql, adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchSet(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchSet(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Optional<Fetched>.fetchSet(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched?>(sql: sql, adapter: adapter).fetchSet(db), sql: sql)
}
}
@@ -25,10 +25,18 @@ private struct Book: FetchableRecord, PersistableRecord, Codable {
static let databaseTableName = "book"
static let author = belongsTo(Author.self)
#if compiler(>=5.5)
static let bookFts4 = hasOne(BookFts4.self, using: ForeignKey([.rowID]))
#else
static let bookFts4 = hasOne(BookFts4.self, using: ForeignKey([Column.rowID]))
#endif
#if SQLITE_ENABLE_FTS5
#if compiler(>=5.5)
static let bookFts5 = hasOne(BookFts5.self, using: ForeignKey([.rowID]))
#else
static let bookFts5 = hasOne(BookFts5.self, using: ForeignKey([Column.rowID]))
#endif
#endif
var author: QueryInterfaceRequest<Author> { request(for: Book.author) }
}
+8
View File
@@ -10,7 +10,11 @@ private struct Book {
extension Book : FetchableRecord {
init(row: Row) {
#if compiler(>=5.5)
id = row[.rowID]
#else
id = row[Column.rowID]
#endif
title = row["title"]
author = row["author"]
body = row["body"]
@@ -22,7 +26,11 @@ extension Book : MutablePersistableRecord {
static let databaseSelection: [SQLSelectable] = [AllColumns(), Column.rowID]
func encode(to container: inout PersistenceContainer) {
#if compiler(>=5.5)
container[.rowID] = id
#else
container[Column.rowID] = id
#endif
container["title"] = title
container["author"] = author
container["body"] = body
+8
View File
@@ -10,7 +10,11 @@ private struct Book {
extension Book : FetchableRecord {
init(row: Row) {
#if compiler(>=5.5)
id = row[.rowID]
#else
id = row[Column.rowID]
#endif
title = row["title"]
author = row["author"]
body = row["body"]
@@ -22,7 +26,11 @@ extension Book : MutablePersistableRecord {
static let databaseSelection: [SQLSelectable] = [AllColumns(), Column.rowID]
func encode(to container: inout PersistenceContainer) {
#if compiler(>=5.5)
container[.rowID] = id
#else
container[Column.rowID] = id
#endif
container["title"] = title
container["author"] = author
container["body"] = body
+12 -1
View File
@@ -11,7 +11,11 @@ private struct Book {
extension Book : FetchableRecord {
init(row: Row) {
#if compiler(>=5.5)
id = row[.rowID]
#else
id = row[Column.rowID]
#endif
title = row["title"]
author = row["author"]
body = row["body"]
@@ -21,9 +25,13 @@ extension Book : FetchableRecord {
extension Book : MutablePersistableRecord {
static let databaseTableName = "books"
static let databaseSelection: [SQLSelectable] = [AllColumns(), Column.rowID]
func encode(to container: inout PersistenceContainer) {
#if compiler(>=5.5)
container[.rowID] = id
#else
container[Column.rowID] = id
#endif
container["title"] = title
container["author"] = author
container["body"] = body
@@ -72,6 +80,9 @@ class FTS5RecordTests: GRDBTestCase {
let pattern = FTS5Pattern(matchingAllTokensIn: "Herman Melville")!
XCTAssertEqual(try Book.matching(pattern).fetchCount(db), 1)
XCTAssertEqual(try Book.filter(Column("books").match(pattern)).fetchCount(db), 1)
XCTAssertEqual(try Book.filter(Column("author").match(pattern)).fetchCount(db), 1)
XCTAssertEqual(try Book.filter(Column("title").match(pattern)).fetchCount(db), 0)
}
}
@@ -933,7 +933,7 @@ extension FetchableRecordDecodableTests {
}
let adapter = SuffixRowAdapter(fromIndex: 1).addingScopes(["nestedKeyed": RangeRowAdapter(0..<1)])
let request = SQLRequest<Void>(
let request = SQLRequest(
sql: "SELECT ? AS name, ? AS nestedSingle, ? AS nestedUnkeyed",
arguments: ["foo", "bar", "[\"baz\"]"],
adapter: adapter)
@@ -969,7 +969,7 @@ extension FetchableRecordDecodableTests {
XCTAssertNil(record.nestedUnkeyed.context)
}
let request = SQLRequest<Void>(
let request = SQLRequest(
sql: "SELECT ? AS nestedKeyed, ? AS nestedSingle, ? AS nestedUnkeyed",
arguments: ["{\"name\":\"foo\"}", "bar", "[\"baz\"]"])
@@ -1005,7 +1005,7 @@ extension FetchableRecordDecodableTests {
}
let adapter = SuffixRowAdapter(fromIndex: 1).addingScopes(["nestedKeyed": RangeRowAdapter(0..<1)])
let request = SQLRequest<Void>(
let request = SQLRequest(
sql: "SELECT ? AS name, ? AS nestedSingle, ? AS nestedUnkeyed",
arguments: ["foo", "bar", "[\"baz\"]"],
adapter: adapter)
@@ -1041,7 +1041,7 @@ extension FetchableRecordDecodableTests {
XCTAssertEqual(record.nestedUnkeyed.context, "JSON column: nestedUnkeyed")
}
let request = SQLRequest<Void>(
let request = SQLRequest(
sql: "SELECT ? AS nestedKeyed, ? AS nestedSingle, ? AS nestedUnkeyed",
arguments: ["{\"name\":\"foo\"}", "bar", "[\"baz\"]"])
+26 -26
View File
@@ -39,7 +39,7 @@ class FetchableRecordTests: GRDBTestCase {
let statement = try db.makeStatement(sql: sql)
try test(Fetched.fetchCursor(db, sql: sql))
try test(Fetched.fetchCursor(statement))
try test(Fetched.fetchCursor(db, SQLRequest<Void>(sql: sql)))
try test(Fetched.fetchCursor(db, SQLRequest(sql: sql)))
try test(SQLRequest<Fetched>(sql: sql).fetchCursor(db))
}
do {
@@ -48,7 +48,7 @@ class FetchableRecordTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchCursor(db, sql: sql, adapter: adapter))
try test(Fetched.fetchCursor(statement, adapter: adapter))
try test(Fetched.fetchCursor(db, SQLRequest<Void>(sql: sql, adapter: adapter)))
try test(Fetched.fetchCursor(db, SQLRequest(sql: sql, adapter: adapter)))
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchCursor(db))
}
}
@@ -95,7 +95,7 @@ class FetchableRecordTests: GRDBTestCase {
let sql = "SELECT throw(), NULL"
try test(Fetched.fetchCursor(db, sql: sql), sql: sql)
try test(Fetched.fetchCursor(db.makeStatement(sql: sql)), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql).fetchCursor(db), sql: sql)
}
do {
@@ -103,7 +103,7 @@ class FetchableRecordTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchCursor(db, sql: sql, adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchCursor(db), sql: sql)
}
}
@@ -127,7 +127,7 @@ class FetchableRecordTests: GRDBTestCase {
let sql = "SELECT * FROM nonExistingTable"
try test(Fetched.fetchCursor(db, sql: sql), sql: sql)
try test(Fetched.fetchCursor(db.makeStatement(sql: sql)), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql).fetchCursor(db), sql: sql)
}
do {
@@ -135,7 +135,7 @@ class FetchableRecordTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchCursor(db, sql: sql, adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchCursor(db), sql: sql)
}
}
@@ -153,7 +153,7 @@ class FetchableRecordTests: GRDBTestCase {
let statement = try db.makeStatement(sql: sql)
try test(Fetched.fetchAll(db, sql: sql))
try test(Fetched.fetchAll(statement))
try test(Fetched.fetchAll(db, SQLRequest<Void>(sql: sql)))
try test(Fetched.fetchAll(db, SQLRequest(sql: sql)))
try test(SQLRequest<Fetched>(sql: sql).fetchAll(db))
}
do {
@@ -162,7 +162,7 @@ class FetchableRecordTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchAll(db, sql: sql, adapter: adapter))
try test(Fetched.fetchAll(statement, adapter: adapter))
try test(Fetched.fetchAll(db, SQLRequest<Void>(sql: sql, adapter: adapter)))
try test(Fetched.fetchAll(db, SQLRequest(sql: sql, adapter: adapter)))
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchAll(db))
}
}
@@ -200,7 +200,7 @@ class FetchableRecordTests: GRDBTestCase {
let sql = "SELECT throw()"
try test(Fetched.fetchAll(db, sql: sql), sql: sql)
try test(Fetched.fetchAll(db.makeStatement(sql: sql)), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql).fetchAll(db), sql: sql)
}
do {
@@ -208,7 +208,7 @@ class FetchableRecordTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchAll(db, sql: sql, adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchAll(db), sql: sql)
}
}
@@ -232,7 +232,7 @@ class FetchableRecordTests: GRDBTestCase {
let sql = "SELECT * FROM nonExistingTable"
try test(Fetched.fetchAll(db, sql: sql), sql: sql)
try test(Fetched.fetchAll(db.makeStatement(sql: sql)), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql).fetchAll(db), sql: sql)
}
do {
@@ -240,7 +240,7 @@ class FetchableRecordTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchAll(db, sql: sql, adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchAll(db), sql: sql)
}
}
@@ -258,7 +258,7 @@ class FetchableRecordTests: GRDBTestCase {
let statement = try db.makeStatement(sql: sql)
try test(Fetched.fetchSet(db, sql: sql))
try test(Fetched.fetchSet(statement))
try test(Fetched.fetchSet(db, SQLRequest<Void>(sql: sql)))
try test(Fetched.fetchSet(db, SQLRequest(sql: sql)))
try test(SQLRequest<Fetched>(sql: sql).fetchSet(db))
}
do {
@@ -267,7 +267,7 @@ class FetchableRecordTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchSet(db, sql: sql, adapter: adapter))
try test(Fetched.fetchSet(statement, adapter: adapter))
try test(Fetched.fetchSet(db, SQLRequest<Void>(sql: sql, adapter: adapter)))
try test(Fetched.fetchSet(db, SQLRequest(sql: sql, adapter: adapter)))
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchSet(db))
}
}
@@ -305,7 +305,7 @@ class FetchableRecordTests: GRDBTestCase {
let sql = "SELECT throw()"
try test(Fetched.fetchSet(db, sql: sql), sql: sql)
try test(Fetched.fetchSet(db.makeStatement(sql: sql)), sql: sql)
try test(Fetched.fetchSet(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Fetched.fetchSet(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql).fetchSet(db), sql: sql)
}
do {
@@ -313,7 +313,7 @@ class FetchableRecordTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchSet(db, sql: sql, adapter: adapter), sql: sql)
try test(Fetched.fetchSet(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Fetched.fetchSet(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Fetched.fetchSet(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchSet(db), sql: sql)
}
}
@@ -337,7 +337,7 @@ class FetchableRecordTests: GRDBTestCase {
let sql = "SELECT * FROM nonExistingTable"
try test(Fetched.fetchSet(db, sql: sql), sql: sql)
try test(Fetched.fetchSet(db.makeStatement(sql: sql)), sql: sql)
try test(Fetched.fetchSet(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Fetched.fetchSet(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql).fetchSet(db), sql: sql)
}
do {
@@ -345,7 +345,7 @@ class FetchableRecordTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchSet(db, sql: sql, adapter: adapter), sql: sql)
try test(Fetched.fetchSet(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Fetched.fetchSet(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Fetched.fetchSet(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchSet(db), sql: sql)
}
}
@@ -363,7 +363,7 @@ class FetchableRecordTests: GRDBTestCase {
let statement = try db.makeStatement(sql: sql)
try test(Fetched.fetchOne(db, sql: sql))
try test(Fetched.fetchOne(statement))
try test(Fetched.fetchOne(db, SQLRequest<Void>(sql: sql)))
try test(Fetched.fetchOne(db, SQLRequest(sql: sql)))
try test(SQLRequest<Fetched>(sql: sql).fetchOne(db))
}
do {
@@ -372,7 +372,7 @@ class FetchableRecordTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchOne(db, sql: sql, adapter: adapter))
try test(Fetched.fetchOne(statement, adapter: adapter))
try test(Fetched.fetchOne(db, SQLRequest<Void>(sql: sql, adapter: adapter)))
try test(Fetched.fetchOne(db, SQLRequest(sql: sql, adapter: adapter)))
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchOne(db))
}
}
@@ -386,7 +386,7 @@ class FetchableRecordTests: GRDBTestCase {
let statement = try db.makeStatement(sql: sql)
try test(Fetched.fetchOne(db, sql: sql))
try test(Fetched.fetchOne(statement))
try test(Fetched.fetchOne(db, SQLRequest<Void>(sql: sql)))
try test(Fetched.fetchOne(db, SQLRequest(sql: sql)))
try test(SQLRequest<Fetched>(sql: sql).fetchOne(db))
}
do {
@@ -395,7 +395,7 @@ class FetchableRecordTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchOne(db, sql: sql, adapter: adapter))
try test(Fetched.fetchOne(statement, adapter: adapter))
try test(Fetched.fetchOne(db, SQLRequest<Void>(sql: sql, adapter: adapter)))
try test(Fetched.fetchOne(db, SQLRequest(sql: sql, adapter: adapter)))
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchOne(db))
}
}
@@ -434,7 +434,7 @@ class FetchableRecordTests: GRDBTestCase {
let sql = "SELECT throw()"
try test(Fetched.fetchOne(db, sql: sql), sql: sql)
try test(Fetched.fetchOne(db.makeStatement(sql: sql)), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql).fetchOne(db), sql: sql)
}
do {
@@ -442,7 +442,7 @@ class FetchableRecordTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchOne(db, sql: sql, adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchOne(db), sql: sql)
}
}
@@ -466,7 +466,7 @@ class FetchableRecordTests: GRDBTestCase {
let sql = "SELECT * FROM nonExistingTable"
try test(Fetched.fetchOne(db, sql: sql), sql: sql)
try test(Fetched.fetchOne(db.makeStatement(sql: sql)), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest<Void>(sql: sql)), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql: sql)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql).fetchOne(db), sql: sql)
}
do {
@@ -474,7 +474,7 @@ class FetchableRecordTests: GRDBTestCase {
let adapter = SuffixRowAdapter(fromIndex: 1)
try test(Fetched.fetchOne(db, sql: sql, adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db.makeStatement(sql: sql), adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest<Void>(sql: sql, adapter: adapter)), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql: sql, adapter: adapter)), sql: sql)
try test(SQLRequest<Fetched>(sql: sql, adapter: adapter).fetchOne(db), sql: sql)
}
}
@@ -36,7 +36,11 @@ private class Person : Record, Hashable {
}
required init(row: Row) {
#if compiler(>=5.5)
id = row[.rowID]
#else
id = row[Column.rowID]
#endif
age = row["age"]
name = row["name"]
creationDate = row["creationDate"]
@@ -44,7 +48,11 @@ private class Person : Record, Hashable {
}
override func encode(to container: inout PersistenceContainer) {
#if compiler(>=5.5)
container[.rowID] = id
#else
container[Column.rowID] = id
#endif
container["name"] = name
container["age"] = age
container["creationDate"] = creationDate
@@ -15,8 +15,8 @@
"repositoryURL": "https://github.com/realm/realm-cocoa.git",
"state": {
"branch": null,
"revision": "ae8e646590396dfc13c1abbf8aa2e48c43766dce",
"version": "10.7.2"
"revision": "83a07f6a508c3427058d9e2c466208d0b6a960fa",
"version": "10.12.0"
}
},
{
@@ -24,8 +24,8 @@
"repositoryURL": "https://github.com/realm/realm-core",
"state": {
"branch": null,
"revision": "bab46acdca91c417a0d4849b8f4992a3c17e29a5",
"version": "10.5.5"
"revision": "e72b3078bfc5c3f69a0b18f7a220be27e28c463f",
"version": "11.2.0"
}
},
{
@@ -33,8 +33,8 @@
"repositoryURL": "https://github.com/stephencelis/SQLite.swift.git",
"state": {
"branch": null,
"revision": "0a9893ec030501a3956bee572d6b4fdd3ae158a1",
"version": "0.12.2"
"revision": "8096e9b9c5cc694f373d2176f96889d3e4afe053",
"version": "0.13.0"
}
}
]