Skip to main content

Module default_markers

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 no DEFAULT clause for it and warns that the real default must exist.
  • autoincrement() — a Prisma-style spelling that cratestack check refuses outright (cratestack#1128), because neither Postgres nor SQLite has such a function and the emitted DEFAULT 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§

MarkerCall
A marker call split into its parts. args is the text between the call’s parentheses; trailing is whatever follows the matching ). closed is false when the opening ( has no matching ).

Enums§

DefaultMarker
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. See marker_call for the parts.
marker_call
Parse the inner text of a @default(...) attribute — the text between the outer parentheses — as a marker call, or None if it does not start with one.