Module default_markers
Expand description
The @default(...) marker functions — spellings that are not real
database functions and must never reach a DEFAULT clause verbatim.
There are two:
dbgenerated()— the sanctioned marker meaning “the column’s value is generated at the database level” (a sequence,GENERATED ... AS IDENTITY, a trigger, hand-authored SQL). The emitter emits noDEFAULTclause for it and warns that the real default must exist.autoincrement()— a Prisma-style spelling thatcratestack checkrefuses outright (cratestack#1128), because neither Postgres nor SQLite has such a function and the emittedDEFAULT autoincrement()fails at apply time. The emitter must never write it either.
These are matched whitespace-insensitively. attribute_text::split_attributes
trims only the outer edges of each attribute (it does piece.trim() per
piece), so @default(autoincrement ()) keeps the space between the name
and its opening parenthesis. A plain exact-string match would let that
spelling slip past both the parser validator and the migration emitter
and re-emit broken DDL. Because the two live in different crates, sharing
one matcher here is what stops them disagreeing again — each previously
hand-rolled the same exact-string check and shared the same blind spot.
Classification only: the returned marker decides what the spelling
means, never the emitted text. A quoted literal ('pending'), a bare
word, or any other function (now(), cs_cuid()) is None and is left
to the caller’s own literal/function handling, which is deliberate and
unchanged.
Structs§
- Marker
Call - A marker call split into its parts.
argsis the text between the call’s parentheses;trailingis whatever follows the matching).closedis false when the opening(has no matching).
Enums§
- Default
Marker - A
@default(...)marker function.
Functions§
- default_
inner - The trimmed inner text of a field’s first
@default(...)attribute. - default_
marker - The marker a
@default(...)inner text starts with, if any. Seemarker_callfor the parts. - marker_
call - Parse the inner text of a
@default(...)attribute — the text between the outer parentheses — as a marker call, orNoneif it does not start with one.