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)? - has_
model_ attr - Does the item carry the framework’s
#[model(...)]attribute macro? Such a struct expands to#[derive(Table)]plus app metadata, so the schema layer treats it exactly like a hand-derived table. (The framework crates are not a dependency here — this is a purely syntactic check, in the same spirit ashas_derive.) - 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. - parse_
sources_ with_ external - Like
parse_sources, but with additional already-known tables (module snapshots) available for foreign-key/relation resolution — so an app table canreferences(SomeModuleStruct)a table it doesn’t define. The external tables are not part of the returned schema. - 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