GRDB.swift v6.0.0-beta Release Notes
-
๐ Released August 21, 2022 • diff
๐ New
๐ Upgrading your app can bring improvements: check [Migrating From GRDB 5 to GRDB 6](Documentation/GRDB6MigrationGuide.md) for some suggestions.
๐ :star: Support for
UPSERT
:player.upsert(db)
, etc. See [Persistence Methods](README.md#persistence-methods).๐ :star: Support for the
RETURNING
clause:player.insertAndFetch(db)
,Player.deleteAndFetchAll(db)
, etc. See [Persistence Methods and theRETURNING
clause](README.md#persistence-methods-and-the-returning-clause).:star: [Persistence Callbacks](README.md#persistence-callbacks) allow record types to customize persistence methods:
didInsert
,willSave
, etc.๐ :star: Better support for unexpected database values. Where GRDB 5 would crash during encoding and decoding database values, GRDB 6 has learned to throw errors instead. Record protocols throw decoding and encoding errors, and value requests throw errors on invalid inputs.
Request protocols and cursors now define primary associated types, enabled by SE-0346.
All persistence methods now accept an explicit conflict policy:
player.insert(db, onConflict: .replace)
, etc.You can append the contents of a cursor to a collection with
RangeReplaceableCollection.append(contentsOf:)
.ValueObservation.map
now accepts a throwing closure argument.
๐ Documentation Updates
- ๐ :star: [Migrating From GRDB 5 to GRDB 6](Documentation/GRDB6MigrationGuide.md): suggestions for improving your applications, and guidance for handling the breaking changes.
- The [Persistence Methods](README.md#persistence-methods) chapter introduces the
upsert
method. - โก๏ธ The [Persistence Methods and the
RETURNING
clause](README.md#persistence-methods-and-the-returning-clause) chapter introduces persistence methods that fetch inserted, updated and deleted values. - The [Persistence Callbacks](README.md#persistence-callbacks) chapter introduces the callback invoked from persistence methods, such as
didInsert
,willSave
, etc. - โก๏ธ The [DatabaseRegionObservation](README.md#databaseregionobservation) chapter was updated for the new
DatabaseRegionObservation.start
method. - โช The [Transaction Hook](README.md#transaction-hook) chapter describes the new
Database.afterNextTransaction(onCommit:onRollback:)
method. - The [Value Queries](README.md#value-queries) chapter explains how to distinguish a request that returns no value from a request that fetches a NULL value.
๐ฅ Breaking Changes
- โ Removed deprecated methods
- :star: Bumped requirements:
- Swift 5.7+ and Xcode 14+ are required.
- iOS 11.0+ / macOS 10.13+ / tvOS 11.0+ / watchOS 4.0+ / SQLite 3.19.3+ are required.
- ๐จ :star: Record protocols were refactored:
- The
FetchableRecord.init(row:)
initializer can now throw errors. - The
EncodableRecord.encode(to:)
method can now throw errors. - Record types can no longer override persistence methods. You use [Persistence Callbacks](README.md#persistence-callbacks) instead.
- The
- Various breaking changes:
- The in-memory
DatabaseQueue()
initializer can now throw errors. - The
selectID()
method is replaced withselectPrimaryKey(as:)
. Cursor.isEmpty
is now a throwing property, instead of a method.- The
Record.copy()
method was removed, without replacement. - The
DerivableRequest.limit(_:offset_:)
method was removed, without replacement. DatabaseRegionObservation.start(in:onError:onChange:)
now returns a cancellable.- The
DatabaseRegionObservation.extent
property was removed. - The
statement
property of database cursors was replaced with read-only properties such assql
orcolumnNames
. - The
Database.afterNextTransactionCommit(_:)
method was renamedDatabase.afterNextTransaction(onCommit:onRollback:)
, and is now able to report rollbacks as well as commits.
- The in-memory