Expand description
Portable parameterised queries over sqlx::Any.
sea-query builds the SQL and an ordered list of values for the running
backend; bind_values binds those values to a sqlx::Any query. Only
portable value kinds are supported (bool, integers, floats, text, bytes), so
backend-specific types (timestamps, JSON) are represented as text or integers
at the query boundary and converted in Rust.
Traits§
- AnyRow
Ext - Row helpers for portably stored types.
Functions§
- bind_
values - Binds
sea-queryvalues onto asqlx::Anyquery, in order. Only portable value kinds occur here (the framework converts time/JSON to text before building), so an unsupported kind is a framework bug and panics. - bind_
values_ as - Same as
bind_values, for aquery_asmapping rows intoO. - build
- Renders a
sea-querystatement to(sql, values)forbackend. - insert_
returning_ id - Runs an insert and returns the generated auto-increment id, portably.
- on_
conflict_ ignore - A portable “insert, ignore duplicates” conflict clause for
keys(the unique or primary-key columns of the conflict). Use in place ofOnConflict::columns(keys).do_nothing(): sea-query renders MySQL’sDO NOTHINGas invalid SQL (ON DUPLICATE KEY IGNORE), so this expresses the same intent as a no-op update of the first key column, which is valid on Postgres, MySQL, and SQLite alike. - text_
cast - The SQL type to cast a column to when you need its value back as a string on
any backend. Descriptor-driven screens cast every selected column to a string
so a value of any type reads back uniformly through
sqlx::Any. MySQL rejectsCAST(x AS text)(it casts tochar), while Postgres and SQLite usetext. Use asExpr::col(c).cast_as(sea_query::Alias::new(text_cast(backend))).