You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(spec): declare {0000} as the contract default for format-less autonumber (#6555) (#7265)
`FieldSchema.autonumberFormat` is optional, and the two sides that mint record
numbers each answered "no format declared" on their own — differently.
driver-sql substituted `'{0000}'` and issued `0001`; the ObjectQL engine's
in-memory fallback path parsed the empty string and fell through
`renderAutonumber`'s no-slot branch to a bare `1`. One metadata document, two
number shapes. The counter VALUE always agreed (#6468 pinned it) — the fork was
rendering width alone.
Per the maintainer's 2026-08-08 ruling (route 3, default fixed at `{0000}`),
this lands the CONTRACT half only:
- `DEFAULT_AUTONUMBER_FORMAT` — new export beside `renderAutonumber`; the one
place the value is written down.
- `resolveAutonumberFormat(field)` — new export; canonical `autonumberFormat`,
then the `format` shorthand (#1603), then the declared default. A key holding
anything but a non-empty string counts as undeclared — driver-sql's
truthiness rule, chosen so already-stored SQL numbers keep their shape.
- `FieldSchema.autonumberFormat` declares the default as a JSON-Schema
annotation, registered in `DEFAULT_CHANGES_BY_MAJOR` (#4666 ratchet).
Deliberately an annotation, not a Zod `.default()`: the key is flat on
FieldSchema and shared by every field type, so a parse-time default was
measured to materialize `autonumberFormat: '{0000}'` on `text`/`number`/
`lookup` fields and turned 28 cases in `build-schemas-check-mode.test.ts` red.
Parse output is unchanged for every type.
Both generators keep their hand-written fallbacks for now; removing them
follows in two separate cards, so nothing about today's rendering moves.
Part of #6555.
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: content/docs/references/data/field.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,7 +128,7 @@ const result = AddressSchema.parse(data);
128
128
|**system**|`boolean`| optional | Auto-injected system/audit field (e.g. created_at, updated_by, organization_id). Tools that surface system fields separately from author-declared business fields should branch on this flag. |
129
129
|**sortable**|`boolean`| optional | Whether field is sortable in list views |
130
130
|**inlineHelpText**|`string`| optional | Help text displayed below the field in forms |
131
-
|**autonumberFormat**|`string`| optional | Auto-number format: literal text + `{0000}` counter, `{YYYY}`/`{MM}`/`{DD}`/`{YYYYMMDD}` date tokens (business tz), and `{field_name}` interpolation. Counter resets per rendered prefix (e.g. AD`{YYYYMMDD}``{0000}` resets daily). |
131
+
|**autonumberFormat**|`string`| optional | Auto-number format: literal text + `{0000}` counter, `{YYYY}`/`{MM}`/`{DD}`/`{YYYYMMDD}` date tokens (business tz), and `{field_name}` interpolation. Counter resets per rendered prefix (e.g. AD`{YYYYMMDD}``{0000}` resets daily). Omitted on an `autonumber` field ⇒ the contract default `{0000}` (#6555). |
132
132
|**externalId**|`boolean`| optional | Is external ID for upsert operations |
0 commit comments