Skip to main content

Module embed_struct

Module embed_struct 

Source

Functions§

basic_embedded_struct
Tests that embedded structs are registered in the app schema but don’t create their own database tables (they’re inlined into parent models).
create_and_query_embedded
Tests basic CRUD operations with embedded fields across all ID types. Validates create, read, update (both instance and query-based), and delete.
crud_nested_embedded
Tests CRUD operations with 2-level nested embedded structs. Validates that creating, reading, updating (instance and query-based), and deleting records with nested embedded structs works end-to-end.
deeply_nested_embedded_schema
Tests deeply nested embedded types (3+ levels) to verify schema building handles arbitrary nesting depth correctly. Validates:
embedded_struct_fields_codegen
Tests code generation for embedded struct field accessors:
embedded_struct_with_jiff_fields
Tests that jiff temporal types inside embedded structs round-trip correctly. Covers Timestamp (epoch nanos), civil::Date, civil::Time, and civil::DateTime.
embedded_struct_with_uuid_field
Tests that UUID fields inside embedded structs round-trip correctly. UUID requires a type cast on databases that don’t support it natively (e.g., SQLite stores it as text). This exercises the table_to_model lifting path for embedded struct fields with non-trivial type mappings.
partial_update_embedded_fields
Tests partial updates of embedded struct fields via stmt::patch / stmt::apply. This validates that individual fields within an embedded struct can be updated without replacing the entire struct.
partial_update_nested_embedded
Tests partial updates of deeply nested embedded fields via nested stmt::patch calls. Validates that patching a leaf field inside an outer embedded struct updates only that leaf, leaving all other fields unchanged in the database.
query_based_partial_update_embedded
Tests partial updates of embedded fields using the query/filter-based path. User::filter_by_id(id).update().address(stmt::patch(...)) follows a different code path than the instance-based user.update().address(stmt::patch(...)), so both need coverage.
query_embedded_fields_comparison_ops
Tests comparison operators (gt, lt, ge, le, ne) on embedded struct fields. SQL-only: DynamoDB doesn’t support range queries on non-key attributes. Validates that all comparison operators work correctly with embedded fields.
query_embedded_multiple_fields
Tests querying by multiple embedded fields in a single query (AND conditions). SQL-only: DynamoDB requires partition key in queries. Validates that complex filters with multiple embedded fields work correctly.
query_embedded_struct_fields
Tests querying by embedded struct fields with composite keys (DynamoDB compatible). Validates:
root_model_with_embedded_field
Tests the complete schema generation and mapping for embedded fields:
unit_enum_in_embedded_struct
Tests a unit enum embedded as a field inside an embedded struct (enum-in-struct nesting). The struct flattens to columns including the enum’s discriminant column.
update_with_embedded_field_filter
Tests UPDATE operations filtered by embedded struct fields. SQL-only: DynamoDB requires partition key in queries/updates. Validates that updates can target rows based on embedded field values.
whole_embedded_struct_eq_ne
Tests eq and ne on a whole multi-field embedded value: both decompose into per-column comparisons — equality into AND, inequality into OR — so ne matches rows differing in any column.