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
Is your feature request related to a problem? Please describe.
My attitude toward sqlx was that if it compiles, than db will not throw error at me at runtime.
Of course sqlx cannot check any possible constraint at compile time, but it can at least catch the most common stuff: adding a new non-null column to db.
Example:
use sqlx::PgPool;fnmain(){println!("Hello, world!");}structUser{id:i32,name:String,#[expect(dead_code)]// obviously that field would be used somewhere else in database and we cannot rely on that warningsurname:String,}#[expect(dead_code)]asyncfninsert(pool:PgPool,user:User){// developer forgot to update insert query and compiler did not warn about it
sqlx::query!("INSERT INTO user (id, name) VALUES ($1, $2)",
user.id,
user.name
).execute(&pool).await.unwrap();}
Migrations:
initial:
createtableuser (id serialprimary key, name textnot null);
second:
altertable user add column surname varchar(255) not null;
Describe the solution you'd like
I expect sqlx to catch basic cases when non-null constraints are violated.
Describe alternatives you've considered
Doing nothing
Workarounds with macros with asserts that every field is used in some way
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
My attitude toward sqlx was that if it compiles, than db will not throw error at me at runtime.
Of course sqlx cannot check any possible constraint at compile time, but it can at least catch the most common stuff: adding a new non-null column to db.
Example:
Migrations:
Describe the solution you'd like
I expect sqlx to catch basic cases when non-null constraints are violated.
Describe alternatives you've considered
The text was updated successfully, but these errors were encountered: