Skip to main content

Module query

Module query 

Source
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§

AnyRowExt
Row helpers for portably stored types.

Functions§

bind_values
Binds sea-query values onto a sqlx::Any query, 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 a query_as mapping rows into O.
build
Renders a sea-query statement to (sql, values) for backend.
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 of OnConflict::columns(keys).do_nothing(): sea-query renders MySQL’s DO NOTHING as 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 rejects CAST(x AS text) (it casts to char), while Postgres and SQLite use text. Use as Expr::col(c).cast_as(sea_query::Alias::new(text_cast(backend))).