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 renamed SQL.

    • ๐Ÿ†• 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 and NOT 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.