-
Notifications
You must be signed in to change notification settings - Fork 211
Switch to sqlx for compile-time checked queries #874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
During CI it should not connect to the database, or do a build with and without the database: we want to make sure the cached data is correct and a build can work without a connection. |
By my understanding there will be a separate CLI utility that prepares the queries. So we can run a build job that calls |
I think this’d be a great change, I’ll take a look at it once we’re async-capable |
I have a WIP for this in https://github.com/jyn514/docs.rs/tree/sqlx, using |
(compare link: master...jyn514:sqlx) |
Currently blocked on launchbadge/sqlx#700. |
One footgun I found with this: If a migration fails and leaves the database in an inconsistent state, you can no longer compile the code to fix it, because |
The sqlx cli tool can also run migrations, so that can be used to fix anything broken |
short update here:
apart from that the user experience especially with the |
A common source of outages is an incorrect query with no tests (#862, #829, #648, etc). While it's good to have tests for all queries, it's not always feasible (especially until #822 is fixed). SQLx offers that advantage that it can check all queries at build time without having to write a test for that specific query. It is also fully async (cc @Kixiron), although that might mean we have to wait until we switch to tokio 0.2.
To avoid needless database connections, this should only connect to the database when a query is changed or added, or a schema change is made: launchbadge/sqlx#249. During CI it should always connect to the database.
The text was updated successfully, but these errors were encountered: