Hello Swift Community,
GRDB, the "toolkit for SQLite databases, with a focus on application development" has been upgraded to version 5.0.0-beta.
It comes with the version 1.0.0-beta of its companion libraries GRDBCombine and RxGRDB.
The new features are:
-
Support for subqueries
A "subquery" is a request embedded in another. For example, we can fetch all players that have the maximum score with a single database access:
// SELECT * FROM player WHERE score = (SELECT max(score) FROM player)
let maximumScore = Player.select(max(Column("score")))
let bestPlayers = try Player.filter(Column("score") == maximumScore).fetchAll(db)
Raw SQL is more welcome than ever, so you can mix and match the Swift query interface requests with SQL requests when you prefer to:
// OK
let maximumScore: SQLRequest<Int> = "SELECT max(score) FROM player"
let request = Player.filter(Column("score") == maximumScore)
// OK as well
let maximumScore = Player.select(max(Column("score")))
let request: SQLRequest<Player> = "SELECT * FROM player WHERE score = (\(maximumScore))"
-
Simplified handling of SQLite error codes
Lessons have been learned from CocoaError
:
do {
try ...
} catch DatabaseError.SQLITE_CONSTRAINT_FOREIGNKEY {
// foreign key constraint error
} catch DatabaseError.SQLITE_CONSTRAINT {
// any other constraint error
} catch {
// any other database error
}
-
Simplified switch between system SQLite, SQLCipher, and custom SQLite builds
GRDB 5 exposes everything you need with a single import GRDB
, even the raw C SQLite API:
// Compiles with all GRDB flavors
import GRDB
let sqliteVersion = String(cString: sqlite3_libversion())
GRDB 5.0 beta comes with breaking changes as well. The Migrating From GRDB 4 to GRDB 5 guide is there to describe them, and help you upgrade.
The active help of beta testers is much welcomed! Do you experience any difficulty or bug during the upgrade? Please chime in this forum, in a GitHub issue, or on Twitter.
Happy GRDB!
8 Likes
Hello,
GRDB 5.0.0-beta.2 has shipped today, with:
- More robust support for subqueries, in particular subqueries can now refer to other tables.
- The ability to check if the database schema is too recent (as suggested by @remcopoelstra here).
- Another breaking change: the (hopefully rare) applications that define custom requests on top of the
FetchRequest
protocol are warmly encouraged to use regular query interface requests or SQL requests instead.
More details in the Release notes.
As always, write a message here or in a GitHub issue if you have any question.
Happy beta testing!
1 Like
Hello,
GRDB 5.0.0-beta.3 is out! It contains bug fixes, as well as (new!) an API to measure the duration of executed database queries.
More details in the Release notes.
Thanks for upgrading your apps!
Hello,
We have three releases today:
GRDBCombine and RxGRDB apis are simplified, GRDB has learned a few SQLite date functions, and it is easier to identify the various SQLite connections when one wants to, for debugging purposes.
Hello,
GRDB 5.0.0-beta.5 is out: Release notes
In this release:
- (Breaking) Enhancements for WAL checkpointing.
-
Database.maximumStatementArgumentCount
helps you chunking big lists in order to avoid SQLite errors.
- An optimization when you observe a database value: GRDB can now avoid some useless fetches.
- New query interface apis that provide access to the primary key.
- A well-deserved update of the Demo Application, which more closely follows the Good Practices for Designing Record Types.
- New FAQ: Associations.
Happy download!
Hello,
GRDB 5.0.0-beta 6 is out: Release notes.
In this release:
- (Breaking) Embedded Combine support: remove your dependency on the companion library GRDBCombine. Documentation available in the new GRDB Combine guide.
-
Debugging operators for ValueObservation.
- A new demo app for GRDB + Combine + SwiftUI
- Faster decoding of Date and DateComponents.
And of course, GRDB works perfectly on Xcode 12 beta
Happy upgrade!
3 Likes
Hello Swift community,
Today is Bastille Day, a perfect opportunity for releasing GRDB 5.0.0-beta 7
Release notes
Hello,
A big thank you to beta testers who report their issues and questions regarding the migration to GRDB 5! Beta 9 has just shipped.
Release notes