Module default_functions
Expand description
Which functions a @default(...) may call (cratestack#1209).
A function-shaped default reaches a migration’s DEFAULT clause, so it
has to name something the database can run. cratestack check accepts
three groups and refuses everything else:
- the markers,
dbgenerated()and the refusedautoincrement(); seesuper::default_markers; - cratestack’s own generators,
BuiltinDefault:now(),uuid()andcuid(). The runtime fills them in Rust on create, on every backend, and the migration emitter writes the matching database default where the database has one; - functions the schema registers as provided by its database, with
datasource db { functions = ["my_fn"] }. Registering is an assertion, likedbgenerated(): cratestack writes the call verbatim, and the database refuses the migration if the function does not exist.
@default(auth().field) is none of these: it is filled from the auth
context and never reaches DDL.
Structs§
- Function
Call - A call at the start of a default’s inner text:
name(args)trailing.closedis false when the opening(has no matching).
Enums§
- Builtin
Default - A
@default(...)function cratestack itself defines. - Default
Value - What a
@default(...)inner text is.
Functions§
- classify_
default - Classify a
@default(...)inner text. The parser and the migration emitter both go through this, so they cannot disagree on what a default means. - function_
call - Parse the call at the start of
inner, orNoneif it does not start withname(. A name is[A-Za-z_][A-Za-z0-9_.]*, so a schema-qualifiedpublic.my_fn()parses too; whitespace may sit between it and(. The closing)is the one that balances the opening(. - registered_
functions - The functions
datasource { functions = [...] }registers, in order.Ok(empty)when there is no datasource or nofunctionsentry;Errwith a message when the entry is not a list of quoted function names.