Expand description
Minimal SQL builder helpers that leverage metadata from #[derive(Fetchable)].
Feature flags select placeholder style:
tokio_postgres: $1, $2, …mysql_async: ?rusqlite: ?libsql: ?
Default (no feature): ?
Enums§
- Placeholder
- Placeholder representation.
Functions§
- build_
where_ and - Build WHERE clause for simple conjunction (AND) of equality comparisons.
Returns (“WHERE
= AND = …”, params_in_order) - build_
where_ or - Build WHERE clause for disjunction (OR) of groups of ANDed equality comparisons. Each inner vector represents one group combined by AND; groups are then OR-ed together. Returns (“WHERE (a = ? AND b = ?) OR (c = ?)”, params)
- delete_
by_ id - Build DELETE … WHERE id =
- insert
- Build INSERT INTO
(
) VALUES ( ) When feature tokio_postgresorlibsql_returningis enabled, this appendsRETURNING <id_column>.- insert_
many - Build INSERT INTO
(
) VALUES rows*( ) This generates multi-row VALUES with correct placeholder numbering for Postgres and ‘?’ placeholders for other backends. - keyset_
by_ id - Keyset pagination helper over the id column. Returns (SQL, params). When
afteris Some(v): usesWHERE id > v(or< vwhen ascending=false) and orders accordingly. Whenafteris None: omits the comparison and just orders/limits.- select_
all - Build SELECT
FROM - select_
by_ field - Build SELECT … WHERE
= - select_
by_ id - Build a simple SELECT … WHERE id =
statement using metadata from E.- select_
by_ in - Build SELECT … WHERE
IN ( , , …) - select_
by_ is_ not_ null - Build SELECT … WHERE
IS NOT NULL - select_
by_ is_ null - Build SELECT … WHERE
IS NULL - select_
by_ not_ in - Build SELECT … WHERE
NOT IN ( , , …) - select_
count_ all - Build SELECT COUNT(*) FROM
- select_
count_ by_ field - Build SELECT COUNT(*) FROM
WHERE
= - select_
where - Build SELECT
FROM WHERE
- select_
with_ pagination - Build SELECT with optional ORDER BY, LIMIT, OFFSET
- update_
by_ id - Build UPDATE
SET
= , … WHERE = - insert_