Preskoči na vsebino

SQL (Squeal) notes

Changing queries and using prepared statements

Always prefer compile-time query to runtime query, so that errors are caught at compile time.

  • If a compile time (ie. query_*!) is changed (even if just spacing is changed (because of underlying hash of query)) it needs to be re-prepared with scripts/prepare.sh. This generates .sqlx/* files. Use --merged to genertae sqlx-data.json in workspace root.

  • If after compiling, compile time query is valid and works correctly you might consider moving it into stored procedure/function. Using sqlx = { ..., git = ..., rev = ... } in Cargo.toml didn't solve the issue though.