Expand description
The queryweave runtime for the persistence layer: the traits and SQL the
code generated for entities and wrappers (Columns, AppendToQuery,
AppendToQueryWithSeparator) names, on top of the core runtime
(queryweave), which it re-exports so that code names only this crate.
This is where the domain’s database-agnostic filters, sorting and writes
(queryweave::FilterCondition, queryweave::SortKey,
queryweave::FieldValue) become SQL. They name domain fields; the
Columns of the entity storing them say which column each lives in, and
write the SQL against them.
The SQL is portable across the databases sqlx supports: Postgres,
MySQL/MariaDB and SQLite (any BindValues database). What stays
database-specific is semantics, not syntax: LIKE is case-sensitive on
Postgres but case-insensitive on SQLite (for ASCII) and under MySQL’s
default collations, and column names are written unquoted, so they must not
be reserved words of the database.
Macros§
- assert_
columns - Assert at compile time that every one of
fieldshas a column onentity.
Structs§
- Change
Set - The names of the fields that changed, e.g. between a model and its merge-patched version.
- Field
Value - A domain field to write and the value to write to it, e.g. one changed field of a merge patch.
- Filter
Condition - One set filter of a generated filter-options model:
field operator value. - Message
- A message built at compile time (see
missing_column_message). - Model
Data - Items (
T) naming fields of the modelM, e.g. the set filters of a generated filter-options model. - Query
Builder - The sqlx query builder the clauses are appended to, and the separated
builder
Columns::push_assignmentsreturns: re-exported so the generated code (and its callers) name the same sqlx as this crate, whatever the user calls their own sqlx dependency. A builder type for constructing queries at runtime. - Separated
- The sqlx query builder the clauses are appended to, and the separated
builder
Columns::push_assignmentsreturns: re-exported so the generated code (and its callers) name the same sqlx as this crate, whatever the user calls their own sqlx dependency. A wrapper aroundQueryBuilderfor creating comma(or other token)-separated lists. - SortKey
- One sort key of a generated query model: sort by
fieldindirection.
Enums§
- Filter
Operator - The comparison a generated filter field performs against its column.
- Patch
- A field of a merge patch that may also be cleared: absent from the patch,
set to
null, or given a value. - Sort
Direction Model - How the sorting direction is evaluated. How it is expressed in a query is up to the persistence layer.
- Value
- A raw value to compare against or store, in a database-agnostic form.
Traits§
- Append
ToQuery - Append the filters query to the parent query.
- Append
ToQuery With Separator - Append to query individual filters.
- Bind
Values - A database the SQL helpers can write for.
- Boolean
- A raw value the
boolfilter applies to. - Changed
Fields - Detect changes in field values.
- Columns
- A table (usually a
sqlxentity) whose columns store a domain model’s fields, and the SQL written for that model’s data against those columns. - Filter
Options Of - A type converting into model
M’s filter options model. - Filterable
- The types
#[derive(Filters)]generates for a root model or a mirror, so code mirroring it names them through it instead of by name. - Into
Root Query - The query of
M(a root’s query model, or a mirror’s query parameters), converting along its chain of mirrored models into the root model’s query. - Into
Value - A raw value that can be handed to the persistence layer as a
Value. - Merge
Patch Nullable Fields - A merge patch model: which of its fields a client may set to
null(itsPatchfields), as opposed to leaving them out. - Names
Field - An item naming a domain field.
- Nullable
Fields - Which fields of a merge patch struct may be set to
null, under its own names. - Ordered
- A raw value the
lt/gtfilters can compare. - Patch
Field - A field of a merge patch, applied to the model’s field of type
F. - Patch
Kind - What a merge patch field can say: whether its kind of field may be set to
nullat all, and whether this one is. - Persisted
Fields - A type whose data names domain fields the persistence layer maps onto columns.
- QueryOf
- A type converting into model
M’s query model. - RawValue
- A domain field type with a raw value behind it: the value filters compare with and merge patches bind.
- Sort
Details Of - A type converting into model
M’s sort details. - Sort
Field Of - A sortable-fields enum mirroring model
M’s, variant for variant. - Text
- A raw value the
sw/c/ew(LIKE) filters can match.
Functions§
- column_
for - The column
fieldis stored in, per a(domain field, column)table. - first_
field_ without_ column - The first of
fieldswithout a column in the(domain field, column)table, if any. Usable inconstcode, which is howassert_columns!checks coverage at compile time. - missing_
column_ message - The compile error
assert_columns!reports for a domain field without a column onentity. Built inconstcode, since aconstpanic cannot format its message. - push_
page - Push a
LIMIT page_size OFFSET page * page_sizeclause, binding both, when both a page and a page size are requested; nothing otherwise. - sql_
direction - The SQL keyword for a sort direction.
- sql_
operator - The SQL comparison operator for a filter operator.
Type Aliases§
- Conditions
- The set filters of the model
M, as database-agnostic conditions. - Field
Values - Fields of the model
Mto write, with their values. - Sort
Keys - The requested sorting of the model
M, in order.