Crate storeit_sql_builder

Crate storeit_sql_builder 

Source
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_postgres or libsql_returning is enabled, this appends RETURNING <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 after is Some(v): uses WHERE id > v (or < v when ascending=false) and orders accordingly. When after is 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 =