GRDB.swift v5.7.0 Release Notes
-
๐ Released March 28, 2021 • diff
๐ New: #947 by @chrisballinger: Allow access to Encoder from KeyedEncodingContainer
๐ New: Record types that adopt the standard Identifiable protocol have gained type-safe methods that deal with the primary key. For example:
let player = try Player.fetchOne(db, id: 42) try Player.deleteAll(db, ids: [1, 2, 3])
See the new [Identifiable Records](README.md#identifiable-records) documentation chapter for more information.
๐ New:
SQLLiteral
has more use cases than initialy expected, and is renamedSQL
.๐ New: [
SQL
literal](Documentation/SQLInterpolation.md#sql-literal) can now be directly used as an expression, an ordering term, or a selection item.:let name = "O'Brien" let request = Player .select(SQL("id, score"), ...) .filter(SQL("name = \(name)") && ...) .order(SQL("score DESC"), ...)
๐ New: Table creation DSL now supports columns and constraints defined with raw SQL String or [SQL literal](Documentation/SQLInterpolation.md#sql-literal):
try db.create(table: "player") do { t in t.column(sql: "id INTEGER PRIMARY KEY AUTOINCREMENT") t.column(literal: "name TEXT DEFAULT \("Anonymous")") t.constraint(sql: "CHECK (LENGTH(name) > 0)") t.constraint(literal: "CHECK (LENGTH(name) <= \(100))") }
๐ New: Prepared statements can profit from [SQL Interpolation](Documentation/SQLInterpolation.md):
let updateStatement = try db.makeUpdateStatement(literal: "INSERT ...") let selectStatement = try db.makeSelectStatement(literal: "SELECT ...") // ~~~~~~~
๐ New: [DatabaseMigrator](Documentation/Migrations.md#asynchronous-migrations) can now asynchronously migrate a database. A Combine publisher is also available.
๐ New: Added support for the
EXISTS
andNOT EXISTS
subquery operators. See the updated [SQL Operators](README.md#sql-operators) documentation.๐ New:
Foundation.Decimal
can now be stored in the database, and all Foundation number types can be decoded from decimal numbers stored as strings. See the [NSNumber, NSDecimalNumber, and Decimal](README.md#nsnumber-nsdecimalnumber-and-decimal) chapter for details.