GRDB.swift v2.9.0 Release Notes
-
๐ Released February 25, 2018 • diff
๐ New
- ๐ Changes tracking overhaul: changes tracking, a feature previously restricted to the
Record
class and its subclasses, is now available for all records. And it has a better looking API (documentation). - Database snapshots: Database pools can now take database snapshots. A snapshot sees an unchanging database content, as it existed at the moment the snapshot was created (documentation).
- ๐ Improved support for joined queries: more than a set on new APIs, we provide a set of guidelines that will help you deal with your wildest joined queries. Check the new Joined Queries Support documentation chapter.
Database.columns(in:)
returns information about the columns of a table.Request.adapted(_:)
is no longer experimental.- ๐
Configuration.allowsUnsafeTransactions
lets you leave transactions opened between two database accesses (see below). - ๐ Support for explicit transaction management, via the new
Database.beginTransaction
,commit
, androllback
methods.
๐ Fixed
It is now a programmer error to leave a transaction opened at the end of a database access block:
// Fatal error: A transaction has been left opened at the end of a database access try dbQueue.inDatabase { db in try db.beginTransaction() }
One can still opt-in for the unsafe behavior by setting the new
allowsUnsafeTransactions
configuration flag:var config = Configuration() config.allowsUnsafeTransactions = true let dbQueue = DatabaseQueue(configuration: config) // OK try dbQueue.inDatabase { db in try db.beginTransaction() }
๐ Deprecated
- ๐
Database.columnCount(in:)
is deprecated. Usedb.columns(in:).count
instead. - ๐
RecordBox
, introduced in 2.7.0, was ill-advised. It has been deprecated. Use changes tracking methods on the Persistable protocol instead. - ๐
Record.hasPersistentChangedValues
has been deprecated, renamedhasDatabaseChanges
. - ๐
Record.persistentChangedValues
has been deprecated, renameddatabaseChanges
.
๐ Documentation Diff
- โก๏ธ The Changes Tracking chapter has been updated for the new universal support for record changes.
- A new Database Snapshots chapter has been added.
- โก๏ธ The Concurrency chapter has been updated for database snapshots.
- A new Differences between Database Queues and Pools chapter has been added, that attempts at visually show how much database pools are different from database queues.
- ๐ A new Joined Queries Support chapter has been added.
- The Row Adapters chapter has been made consistent with the new chapter on joined queries.
- The Codable Records chapter has been made consistent with the new chapter on joined queries.
- โก๏ธ The Database Schema Introspection has been updated for
Database.columns(in:)
API diff
+struct ColumnInfo { + let name: String + let type: String + let isNotNull: Bool + let defaultValueSQL: String? + let primaryKeyIndex: Int +} struct Configuration { + var allowsUnsafeTransactions: Bool } class Database { + @available(*, deprecated, message: "Use db.columns(in: tableName).count instead") func columnCount(in tableName: String) throws -> Int + func columns(in tableName: String) throws -> [ColumnInfo] + func beginTransaction(_ kind: TransactionKind? = nil) throws + func rollback() throws + func commit() throws } class DatabasePool { + func makeSnapshot() throws -> DatabaseSnapshot } +class DatabaseSnapshot: DatabaseReader { } extension MutablePersistable { + @discardableResult + func updateChanges(_ db: Database, from record: MutablePersistable) throws -> Bool + func databaseEqual(_ record: Self) -> Bool + func databaseChanges(from record: MutablePersistable) -> [String: DatabaseValue] } class Record { - final func updateChanges(_ db: Database) throws + @discardableResult + final func updateChanges(_ db: Database) throws -> Bool } +@available(*, deprecated, message: "Prefer changes methods defined on the MutablePersistable protocol: databaseEqual(_:), databaseChanges(from:), updateChanges(from:)") class RecordBox: Record { } class Row { + var unscoped: Row + var containsNonNullValue: Bool + func hasNull(atIndex index: Int) -> Bool + subscript<Record: RowConvertible>(_ scope: String) -> Record + subscript<Record: RowConvertible>(_ scope: String) -> Record? } extension TableMapping { + static func selectionSQL(alias: String? = nil) -> String + static func numberOfSelectedColumns(_ db: Database) throws -> Int } +struct EmptyRowAdapter: RowAdapter { } struct ScopeAdapter { + init(base: RowAdapter, scopes: [String: RowAdapter]) } +func splittingRowAdapters(columnCounts: [Int]) -> [RowAdapter]
- ๐ Changes tracking overhaul: changes tracking, a feature previously restricted to the