mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-26 04:07:50 +00:00
30 files changed
+51
-51
No files matched your search
+2
-2
@@ -447,7 +447,7 @@ Released September 27, 2020 • [diff](https://github.com/groue/GRDB.swift/co
|
||||
|
||||
Released September 20, 2020 • [diff](https://github.com/groue/GRDB.swift/compare/v5.0.0-beta.11...v5.0.0)
|
||||
|
||||
- **Fixed**: [#838](https://github.com/groue/GRDB.swift/issues/838): Have indexed colums inherit the `ifNotExists` flag from table creation.
|
||||
- **Fixed**: [#838](https://github.com/groue/GRDB.swift/issues/838): Have indexed columns inherit the `ifNotExists` flag from table creation.
|
||||
|
||||
|
||||
## 5.0.0-beta.11
|
||||
@@ -5909,7 +5909,7 @@ Record ([documentation](https://github.com/groue/GRDB.swift#record-class)):
|
||||
- `Record.reload()` has been removed. You have to provide your own implementation, should you need reloading.
|
||||
- `Record.init(row: Row)` has been renamed `Record.init(_ row: Row)` (unlabelled row argument).
|
||||
- `Record.updateFromRow()` has been removed. Override `init(_ row: Row)` instead.
|
||||
- `Record.didInsertWithRowID(_:forColumn:)` should be overriden by Record subclasses that are interested in their row ids.
|
||||
- `Record.didInsertWithRowID(_:forColumn:)` should be overridden by Record subclasses that are interested in their row ids.
|
||||
- `Record.databaseEdited` has been renamed `hasPersistentChangedValues`.
|
||||
- `Record.databaseChanges` has been renamed `persistentChangedValues` and now returns `[String: DatabaseValue?]`, the dictionary of old values for changed columns.
|
||||
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ How you can Contribute
|
||||
|
||||
GRDB is "documentation-driven", which means that nothing ships until it is supported by documentation that makes sense. Documentation makes sense when someone who is not you is able to figure out what is the purpose of your contribution, how to use it, and what are its eventual caveats and corner cases. When the documentation is hard to write, or reveals too many caveats, it is the sign that the api needs to be fixed.
|
||||
|
||||
8. **Open a pull request with your changes (targetting the `development` branch)!**
|
||||
8. **Open a pull request with your changes (targeting the `development` branch)!**
|
||||
|
||||
9. **If you are granted a push access to the repository**, check [ReleaseProcess.md](Documentation/ReleaseProcess.md) in order to publish a new GRDB version.
|
||||
|
||||
|
||||
@@ -317,7 +317,7 @@ In other words, whenever you need to perform some database access or observation
|
||||
|
||||
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:
|
||||
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 only one publisher:
|
||||
|
||||
```swift
|
||||
struct HallOfFame {
|
||||
|
||||
@@ -422,7 +422,7 @@ let publisher = observation
|
||||
}
|
||||
```
|
||||
|
||||
6. The `TableRecord.selectionSQL()` method is no longer avaible. When you need to embed the columns selected by a record type in an SQL request, you now have to use [SQL Interpolation]:
|
||||
6. The `TableRecord.selectionSQL()` method is no longer available. When you need to embed the columns selected by a record type in an SQL request, you now have to use [SQL Interpolation]:
|
||||
|
||||
```swift
|
||||
// BEFORE: GRDB 4
|
||||
|
||||
@@ -543,7 +543,7 @@ Those properties provide an alternative way to feed our application:
|
||||
|
||||
## How to Design Database Managers
|
||||
|
||||
Many developpers want to hide GRDB database queues and pools inside "database managers":
|
||||
Many developers want to hide GRDB database queues and pools inside "database managers":
|
||||
|
||||
```swift
|
||||
// LibraryManager grants access to the library database.
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ import GRDB
|
||||
//: This playground demonstrates how one can implement **customized decoding of
|
||||
//: database rows**.
|
||||
//:
|
||||
//: Customized row decoding allows you to go beyong the built-in support for
|
||||
//: Customized row decoding allows you to go beyond the built-in support for
|
||||
//: requests of raw rows, values, or types that adopt the
|
||||
//: FetchableRecord protocol.
|
||||
//:
|
||||
@@ -116,7 +116,7 @@ extension Base {
|
||||
//: example, we could fetch all Base values from the database:
|
||||
//:
|
||||
//: try dbQueue.read { db in
|
||||
//: // An array [Base] that constains Foo and Bar instances
|
||||
//: // An array [Base] that contains Foo and Bar instances
|
||||
//: let bases = try Base.fetchAll(db)
|
||||
//: }
|
||||
//:
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import GRDB
|
||||
|
||||
|
||||
// Create the databsae
|
||||
// Create the database
|
||||
|
||||
let dbQueue = DatabaseQueue() // Memory database
|
||||
var migrator = DatabaseMigrator()
|
||||
|
||||
@@ -37,7 +37,7 @@ try db.create(table: "appConfiguration") { t in
|
||||
// Make sure the id column is always 1
|
||||
.check { $0 == 1 }
|
||||
|
||||
// The configuration colums
|
||||
// The configuration columns
|
||||
t.column("flag", .boolean).notNull()
|
||||
// ... other columns
|
||||
}
|
||||
@@ -78,7 +78,7 @@ migrator.registerMigration("appConfiguration") { db in
|
||||
// Single row guarantee
|
||||
t.column("id", .integer).primaryKey(onConflict: .replace).check { $0 == 1 }
|
||||
|
||||
// The configuration colums
|
||||
// The configuration columns
|
||||
t.column("flag", .boolean).notNull()
|
||||
// ... other columns
|
||||
}
|
||||
|
||||
@@ -626,7 +626,7 @@ extension Database {
|
||||
}
|
||||
|
||||
/// If there exists a unique key on columns, return the columns
|
||||
/// ordered as the matching index (or primay key). Case of returned columns
|
||||
/// ordered as the matching index (or primary key). Case of returned columns
|
||||
/// is not guaranteed.
|
||||
func columnsForUniqueKey<T: Sequence>(
|
||||
_ columns: T,
|
||||
|
||||
@@ -177,15 +177,15 @@ extension RowDecodingError: CustomStringConvertible {
|
||||
chunks.append("column: \(String(reflecting: columnName))")
|
||||
chunks.append("column index: \(columnIndex)")
|
||||
} else {
|
||||
// column name is already mentionned in context.debugDescription
|
||||
// column name is already mentioned in context.debugDescription
|
||||
}
|
||||
|
||||
case .prefetchKey:
|
||||
// key is already mentionned in context.debugDescription
|
||||
// key is already mentioned in context.debugDescription
|
||||
break
|
||||
|
||||
case .scope:
|
||||
// scope is already mentionned in context.debugDescription
|
||||
// scope is already mentioned in context.debugDescription
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -784,7 +784,7 @@ extension SQLExpression {
|
||||
return try sql(context)
|
||||
}
|
||||
|
||||
/// If this expression is a table colum, returns the name of this column.
|
||||
/// If this expression is a table column, returns the name of this column.
|
||||
///
|
||||
/// When in doubt, returns nil.
|
||||
///
|
||||
|
||||
@@ -205,7 +205,7 @@ extension SQLRelation: Refinable {
|
||||
select { _ in expressions.map { .expression($0) } }
|
||||
}
|
||||
|
||||
/// Sets the selection, removes all selections from chidren, and clears the
|
||||
/// Sets the selection, removes all selections from children, and clears the
|
||||
/// `isDistinct` flag.
|
||||
func selectOnly(_ selection: [SQLSelection]) -> Self {
|
||||
self
|
||||
@@ -378,7 +378,7 @@ extension SQLRelation {
|
||||
// has-many-through associations, where we user the cardinality of
|
||||
// the association instead.
|
||||
//
|
||||
// By prefering the cardinality of the child kind in general, we make it
|
||||
// By preferring the cardinality of the child kind in general, we make it
|
||||
// possible to join to a plural association and decode it in a singular
|
||||
// key. In the example below, we have a singular kind `.oneRequired`,
|
||||
// a plural to-many association, and we use a singular key:
|
||||
|
||||
@@ -423,7 +423,7 @@ public class TableAlias: Hashable {
|
||||
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
///
|
||||
/// An expression that evaluates to true if the record refered by this
|
||||
/// An expression that evaluates to true if the record referred by this
|
||||
/// `TableAlias` exists.
|
||||
///
|
||||
/// For example, here is how filter books and only keep those that are not
|
||||
|
||||
@@ -600,7 +600,7 @@ public enum DatabaseDateDecodingStrategy {
|
||||
// MARK: - DatabaseColumnDecodingStrategy
|
||||
|
||||
/// `DatabaseColumnDecodingStrategy` specifies how `FetchableRecord` types that
|
||||
/// also adopt the standard `Decodable` protocol look for the database colums
|
||||
/// also adopt the standard `Decodable` protocol look for the database columns
|
||||
/// that match their coding keys.
|
||||
///
|
||||
/// For example:
|
||||
|
||||
@@ -468,7 +468,7 @@ extension MutablePersistableRecord {
|
||||
/// Don't invoke this method directly: it is an internal method for types
|
||||
/// that adopt MutablePersistableRecord.
|
||||
///
|
||||
/// performDelete() provides the default implementation for deelte(). Types
|
||||
/// performDelete() provides the default implementation for delete(). Types
|
||||
/// that adopt MutablePersistableRecord can invoke performDelete() in
|
||||
/// their implementation of delete(). They should not provide their own
|
||||
/// implementation of performDelete().
|
||||
|
||||
@@ -62,7 +62,7 @@ open class Record: FetchableRecord, TableRecord, PersistableRecord {
|
||||
|
||||
/// The default request selection.
|
||||
///
|
||||
/// Unless this method is overriden, requests select all columns:
|
||||
/// Unless this method is overridden, requests select all columns:
|
||||
///
|
||||
/// // SELECT * FROM player
|
||||
/// try Player.fetchAll(db)
|
||||
|
||||
@@ -1800,7 +1800,7 @@ The transaction kind can be changed in the database configuration, or for each t
|
||||
// 1) Default configuration:
|
||||
let dbQueue = try DatabaseQueue(path: "...")
|
||||
|
||||
// BEGIN DEFERED TRANSACTION ...
|
||||
// BEGIN DEFERRED TRANSACTION ...
|
||||
dbQueue.write { db in ... }
|
||||
|
||||
// BEGIN EXCLUSIVE TRANSACTION ...
|
||||
@@ -3436,7 +3436,7 @@ For an efficient algorithm which synchronizes the content of a database table wi
|
||||
|
||||
GRDB records come with many default behaviors, that are designed to fit most situations. Many of those defaults can be customized for your specific needs:
|
||||
|
||||
- [Customizing the Persistence Methods]: define what happens when you call a persistance method such as `player.insert(db)`
|
||||
- [Customizing the Persistence Methods]: define what happens when you call a persistence method such as `player.insert(db)`
|
||||
- [Conflict Resolution]: Run `INSERT OR REPLACE` queries, and generally define what happens when a persistence method violates a unique index.
|
||||
- [The Implicit RowID Primary Key]: all about the special `rowid` column.
|
||||
- [Columns Selected by a Request]: define which columns are selected by requests such as `Player.fetchAll(db)`.
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
- [ ] GRDB 6: UPSERT
|
||||
- [ ] GRDB 6: support for RETURNING
|
||||
- [ ] GRDB 6: allow mutating `update` (for timestamps)
|
||||
- [ ] Long run edition. Use case: user edits the database (CRUD) but the application wants to commmit and the end of the editing session.
|
||||
- [ ] Long run edition. Use case: user edits the database (CRUD) but the application wants to commit and the end of the editing session.
|
||||
* Create an edition SQLite connection with an open transaction (a new kind of DatabaseWriter with a save() method)
|
||||
* All other writes will fail with SQLITE_BUSY. Unless they are schedules in a target dispatch queue which is paused during the edition.
|
||||
- [ ] Can we use generated columns to makes it convenient to index on inserted JSON objects? https://github.com/apple/swift-package-manager/pull/3090#issuecomment-740091760
|
||||
@@ -74,7 +74,7 @@
|
||||
- [ ] 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?
|
||||
- [ ] 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
|
||||
- [ ] Alternative support for custom SQLite builds, with CocoaPods: https://github.com/CocoaPods/CocoaPods/issues/9103
|
||||
|
||||
|
||||
## Unsure how
|
||||
|
||||
@@ -396,7 +396,7 @@ class DatabaseWriterWritePublisherTests : XCTestCase {
|
||||
// MARK: - Regression tests
|
||||
|
||||
// Regression test against deadlocks created by concurrent completion
|
||||
// and cancellations trigerred by .switchToLatest().prefix(1)
|
||||
// and cancellations triggered by .switchToLatest().prefix(1)
|
||||
func testDeadlockPrevention() throws {
|
||||
guard #available(OSX 10.15, iOS 13, tvOS 13, watchOS 6, *) else {
|
||||
throw XCTSkip("Combine is not available")
|
||||
|
||||
@@ -822,7 +822,7 @@ class DatabaseMigratorTests : GRDBTestCase {
|
||||
}
|
||||
try XCTAssertEqual(dbQueue.read(migrator2.appliedMigrations), ["1"])
|
||||
|
||||
// ... unless databaase gets erased
|
||||
// ... unless database gets erased
|
||||
migrator2.eraseDatabaseOnSchemaChange = true
|
||||
try migrator2.migrate(dbQueue)
|
||||
try XCTAssertEqual(dbQueue.read(migrator2.appliedMigrations), ["1", "2"])
|
||||
@@ -871,7 +871,7 @@ class DatabaseMigratorTests : GRDBTestCase {
|
||||
}
|
||||
try XCTAssertEqual(dbQueue.read(migrator2.appliedMigrations), ["1"])
|
||||
|
||||
// ... unless databaase gets erased
|
||||
// ... unless database gets erased
|
||||
migrator2.eraseDatabaseOnSchemaChange = true
|
||||
try migrator2.migrate(dbQueue)
|
||||
try XCTAssertEqual(dbQueue.read(migrator2.appliedMigrations), ["1", "2"])
|
||||
|
||||
@@ -153,7 +153,7 @@ class DatabaseQueueSchemaCacheTests : GRDBTestCase {
|
||||
#if SQLITE_HAS_CODEC
|
||||
// Avoid error due to key not being provided:
|
||||
// file is not a database - while executing `ATTACH DATABASE...`
|
||||
throw XCTSkip("This test does not suppport encrypted databases")
|
||||
throw XCTSkip("This test does not support encrypted databases")
|
||||
#endif
|
||||
|
||||
let attached1 = try makeDatabaseQueue(filename: "attached1")
|
||||
|
||||
@@ -14,7 +14,7 @@ class DatabaseValueConvertibleDecodableTests: GRDBTestCase {
|
||||
preconditionFailure("not tested")
|
||||
}
|
||||
|
||||
// Infered, tested
|
||||
// Inferred, tested
|
||||
// static func fromDatabaseValue(_ databaseValue: DatabaseValue) -> Value? { ... }
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class DatabaseValueConvertibleDecodableTests: GRDBTestCase {
|
||||
preconditionFailure("not tested")
|
||||
}
|
||||
|
||||
// Infered, tested
|
||||
// Inferred, tested
|
||||
// static func fromDatabaseValue(_ databaseValue: DatabaseValue) -> Value? { ... }
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ class DatabaseValueConvertibleDecodableTests: GRDBTestCase {
|
||||
preconditionFailure("not tested")
|
||||
}
|
||||
|
||||
// Infered, tested
|
||||
// Inferred, tested
|
||||
// static func fromDatabaseValue(_ databaseValue: DatabaseValue) -> Value? { ... }
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class DatabaseValueConvertibleEncodableTests: GRDBTestCase {
|
||||
preconditionFailure("not tested")
|
||||
}
|
||||
|
||||
// Infered, tested
|
||||
// Inferred, tested
|
||||
// var databaseValue: DatabaseValue { ... }
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class DatabaseValueConvertibleEncodableTests: GRDBTestCase {
|
||||
preconditionFailure("not tested")
|
||||
}
|
||||
|
||||
// Infered, tested
|
||||
// Inferred, tested
|
||||
// var databaseValue: DatabaseValue { ... }
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class DatabaseValueConvertibleEncodableTests: GRDBTestCase {
|
||||
preconditionFailure("not tested")
|
||||
}
|
||||
|
||||
// Infered, tested
|
||||
// Inferred, tested
|
||||
// var databaseValue: DatabaseValue { ... }
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ extension DatabaseValueConvertibleEncodableTests {
|
||||
preconditionFailure("not tested")
|
||||
}
|
||||
|
||||
// Infered, tested
|
||||
// Inferred, tested
|
||||
// var databaseValue: DatabaseValue { ... }
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ extension DatabaseValueConvertibleEncodableTests {
|
||||
preconditionFailure("not tested")
|
||||
}
|
||||
|
||||
// Infered, tested
|
||||
// Inferred, tested
|
||||
// var databaseValue: DatabaseValue { ... }
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ extension DatabaseValueConvertibleEncodableTests {
|
||||
preconditionFailure("not tested")
|
||||
}
|
||||
|
||||
// Infered, tested
|
||||
// Inferred, tested
|
||||
// var databaseValue: DatabaseValue { ... }
|
||||
}
|
||||
|
||||
|
||||
@@ -713,7 +713,7 @@ class FoundationDateComponentsTests : GRDBTestCase {
|
||||
}
|
||||
|
||||
func testJSONEncodingOfDatabaseDateComponents() throws {
|
||||
// Encoding root string is not suppported by all system version: use an object
|
||||
// Encoding root string is not supported by all system version: use an object
|
||||
struct Record: Encodable {
|
||||
var date: DatabaseDateComponents
|
||||
}
|
||||
@@ -726,7 +726,7 @@ class FoundationDateComponentsTests : GRDBTestCase {
|
||||
}
|
||||
|
||||
func testJSONDecodingOfDatabaseDateComponents() throws {
|
||||
// Decoding root string is not suppported by all system version: use an object
|
||||
// Decoding root string is not supported by all system version: use an object
|
||||
struct Record: Decodable {
|
||||
var date: DatabaseDateComponents
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ private class Person : Record {
|
||||
}
|
||||
|
||||
override func insert(_ db: Database) throws {
|
||||
// This is implicitely tested with the NOT NULL constraint on creationDate
|
||||
// This is implicitly tested with the NOT NULL constraint on creationDate
|
||||
if creationDate == nil {
|
||||
creationDate = Date()
|
||||
}
|
||||
@@ -116,7 +116,7 @@ private class PersonWithModifiedCaseColumns: Record {
|
||||
}
|
||||
|
||||
override func insert(_ db: Database) throws {
|
||||
// This is implicitely tested with the NOT NULL constraint on creationDate
|
||||
// This is implicitly tested with the NOT NULL constraint on creationDate
|
||||
if creationDate == nil {
|
||||
creationDate = Date()
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class RecordInitializersTests : GRDBTestCase {
|
||||
|
||||
func testFetchedRecordAreInitializedFromRow() throws {
|
||||
|
||||
// Here we test that Record.init(row: Row) can be overriden independently from Record.init().
|
||||
// Here we test that Record.init(row: Row) can be overridden independently from Record.init().
|
||||
// People must be able to perform some initialization work when fetching records from the database.
|
||||
|
||||
XCTAssertFalse(RecordWithPedigree().initializedFromRow)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
// Person has a RowID primary key, and a overriden insert() method.
|
||||
// Person has a RowID primary key, and an overridden insert() method.
|
||||
private class Person : Record, Hashable {
|
||||
var id: Int64?
|
||||
var name: String!
|
||||
@@ -59,7 +59,7 @@ private class Person : Record, Hashable {
|
||||
}
|
||||
|
||||
override func insert(_ db: Database) throws {
|
||||
// This is implicitely tested with the NOT NULL constraint on creationDate
|
||||
// This is implicitly tested with the NOT NULL constraint on creationDate
|
||||
if creationDate == nil {
|
||||
creationDate = Date()
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import XCTest
|
||||
import GRDB
|
||||
|
||||
// Person has a RowID primary key, and a overriden insert() method.
|
||||
// Person has a RowID primary key, and an overridden insert() method.
|
||||
private class Person : Record, Hashable {
|
||||
var id: Int64!
|
||||
var name: String!
|
||||
@@ -48,7 +48,7 @@ private class Person : Record, Hashable {
|
||||
}
|
||||
|
||||
override func insert(_ db: Database) throws {
|
||||
// This is implicitely tested with the NOT NULL constraint on creationDate
|
||||
// This is implicitly tested with the NOT NULL constraint on creationDate
|
||||
if creationDate == nil {
|
||||
creationDate = Date()
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ private class Person : Record {
|
||||
}
|
||||
|
||||
override func insert(_ db: Database) throws {
|
||||
// This is implicitely tested with the NOT NULL constraint on creationDate
|
||||
// This is implicitly tested with the NOT NULL constraint on creationDate
|
||||
if creationDate == nil {
|
||||
creationDate = Date()
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ class TableRecordTests: GRDBTestCase {
|
||||
#if SQLITE_HAS_CODEC
|
||||
// Avoid error due to key not being provided:
|
||||
// file is not a database - while executing `ATTACH DATABASE...`
|
||||
throw XCTSkip("This test does not suppport encrypted databases")
|
||||
throw XCTSkip("This test does not support encrypted databases")
|
||||
#endif
|
||||
|
||||
struct Team: Codable, PersistableRecord, FetchableRecord, Equatable {
|
||||
@@ -188,7 +188,7 @@ class TableRecordTests: GRDBTestCase {
|
||||
#if SQLITE_HAS_CODEC
|
||||
// Avoid error due to key not being provided:
|
||||
// file is not a database - while executing `ATTACH DATABASE...`
|
||||
throw XCTSkip("This test does not suppport encrypted databases")
|
||||
throw XCTSkip("This test does not support encrypted databases")
|
||||
#endif
|
||||
|
||||
struct Team: Codable, PersistableRecord, FetchableRecord, Equatable {
|
||||
|
||||
Reference in new issue
Block a user