Skip to main content

Crate jerrycan_db

Crate jerrycan_db 

Source
Expand description

Database extension: one URL-driven Db over SQLite and Postgres (sqlx Any), module-owned dual-dialect migrations, and a deterministic ?$n translator (sqlx’s Any driver does NOT translate placeholders; ours is quote-blind and safe because generated SQL never embeds string literals).

Re-exports§

pub use sea_query;
pub use sea_query_binder;
pub use sqlx;

Structs§

Db
The database dependency: a cloneable pool handle. Register app-wide with App::new().extend(db) (or .provide(db)extend is the §6 seam).
Migration
One migration, both dialects. Generated apps embed these via the tool-owned app/src/migrations.rs; modules own the .sql files (spec §5 anatomy).
OwnedMigration
Runtime-loaded migration (CLI jerrycan db migrate reads module files from disk). The owned twin of Migration; both delegate to the same runner.

Enums§

Backend
Which engine the pool speaks. Generated code branches on this for the few statements that genuinely differ (insert-id strategies, DDL).

Functions§

db_error
Map any sqlx error to a stable JC code without leaking internals; the underlying detail goes to stderr for the operator. Unique-key violations are the client’s fault (a re-POSTed id), not a server fault — they map to 409 JC0409 so duplicate writes can’t pollute 5xx alerting.
translate_placeholders
?$1, $2, … for Postgres; identity for SQLite. Quote-blind by design: generated SQL never embeds string literals (binds carry all values).