Skip to main content

Crate cratestack_sql

Crate cratestack_sql 

Source
Expand description

Dialect-agnostic SQL primitives shared by the Postgres (cratestack-sqlx) and SQLite (cratestack-rusqlite) backends.

This crate carries the type definitions every backend agrees on:

Rendering SQL strings, executing queries, and any DB-driver coupling live in the backend crates.

Structs§

CreateDefault
FieldRef
Filter
ModelColumn
ModelDescriptor
OrderClause
PostgresDialect
Postgres dialect — $N placeholders.
RelationFilter
SqlColumnValue
SqliteDialect
SQLite dialect — ?N placeholders.

Enums§

CreateDefaultType
FilterExpr
FilterOp
FilterValue
OrderTarget
RelationQuantifier
SortDirection
SqlValue

Traits§

CreateModelInput
Dialect
Backend SQL dialect.
IntoSqlValue
ModelPrimaryKey
Accessor for a model’s primary key. Implemented by the macro on every generated model struct so the batch operations can pair returned rows back to the position of their input PK in the request, producing a BatchItemResult with the right index and a NotFound entry for any requested PK that didn’t come back.
UpdateModelInput
UpsertModelInput
Input shape for the upsert primitive — INSERT … ON CONFLICT (<pk>) DO UPDATE …. sql_values() must include the primary-key column (so the backend can target the conflict), and primary_key_value() exposes the PK separately so the runtime can issue a SELECT … FOR UPDATE before the upsert to drive Created vs. Updated event / audit semantics.

Functions§

find_duplicate_sql_value
Detect the first duplicate value in a list of SqlValues, used for batch_upsert input deduplication. Linear-scan with PartialEq rather than the hashed variant in cratestack-core because SqlValue::Float and SqlValue::Decimal don’t admit a sound Hash impl.