You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to verify the queries at compile time.
However I found this to have too many papercuts for my taste.
Here are my reasons for not verifying the queries at compile-time with SQLx:
Can't indent the SQL queries nicely using the indoc! macro
The database needs to already exist while compiling, requiring extra steps
SQLx doesn't know that INTEGER PRIMARY KEY always implies NOT NULL so the inferred datatype is <Option<i64> instead of i64. This could be worked around by explicitly adding NOT NULL but I don't want to add meaningless code
The following code does not compile because two parameters are expected while I think only one should be required:
let _ = sqlx::query!("INSERT OR IGNORE INTO zones (name) VALUES (?1);SELECT id FROM zones WHERE name = ?1;", zone).fetch_one(conn).await?;
If at least two of these issues can be resolved, I'd be willing to implement this.
The text was updated successfully, but these errors were encountered:
It would be nice to verify the queries at compile time.
However I found this to have too many papercuts for my taste.
Here are my reasons for not verifying the queries at compile-time with SQLx:
INTEGER PRIMARY KEY
always impliesNOT NULL
so the inferred datatype is<Option<i64>
instead ofi64
. This could be worked around by explicitly addingNOT NULL
but I don't want to add meaningless codeIf at least two of these issues can be resolved, I'd be willing to implement this.
The text was updated successfully, but these errors were encountered: