Module index_attribute
Expand description
Parsing for the model-level @@index([...], using: ..., opclass: "...", where: "...") attribute (cratestack#156, cratestack#742) — a general
secondary index, optionally naming a non-default Postgres access
method (e.g. ivfflat/hnsw for pgvector approximate-nearest-neighbor
search), operator class, and a partial-index predicate.
Shares its bracketed-field-list syntax with @@id([...])/
@@unique([...]) (see [super::field_list]), but unlike those,
@@index(...) also accepts trailing using:/opclass:/where:
keyword arguments after the field list — the same shape
@relation(fields:[...], references:[...]) already uses
(cratestack-parser::relation_helpers::parse_relation_attribute),
reimplemented here (via [super::attribute_syntax], shared with
@@unique([...], where: "...")) rather than shared with the parser
crate’s own copy because that helper is private to the parser crate
and this one also needs to be callable from cratestack-migrate (via
crate::schema::project_model, one layer below the parser).
Structs§
- Parsed
Index Attribute - The parsed shape of an
@@index([...], using: ..., opclass: "...", where: "...")attribute.
Functions§
- parse_
index_ attribute - Parses
@@index([field1, field2, ...]), optionally followed byusing: <method>,opclass: "<name>", and/orwhere: "<predicate>". Callers are responsible for checking that each field name resolves to a real scalar field on the model.