Expand description
syn-based parsing of #[derive(Table)] structs and #[derive(DbEnum)]
enums into the schema model. This is the only place #[orm(...)]
attribute semantics are defined — the derive macro and the CLI both call
into here, so they can never drift apart.
Functions§
- enum_
from_ item - Parse one
#[derive(DbEnum)]enum. Variants must be unit variants; the stored value is the snake_case variant name. - has_
derive - Does
#[derive(...)]on this item mentionname(by last path segment, sofse_orm::Tablematches too)? - native_
sql_ type - Map a Rust type to its native SQLite storage type. Anything not listed
here needs
#[orm(json)]or aDbEnum. - parse_
sources - Parse a whole tables folder:
sourcesis(file name, file content), where the file name is only used in error messages. Two passes — enums first so struct fields can resolve them — then foreign keys are resolved from struct names to table names. - pluralize
- Naive English pluralization for default table names — struct
Categorybecomes tablecategories. Wrong for irregular nouns; override with#[orm(table = "...")]. - table_
from_ struct - Parse one
#[derive(Table)]struct. - to_
snake_ case