Skip to content

Commit f0ac3e4

Browse files
os-helpclaude
andauthored
docs(protocol): correct the two wrong defaultValue samples in schema.mdx (#7244) (#7376)
Both samples on `content/docs/protocol/objectql/schema.mdx` taught a shape that today produces a rejected write or a bogus physical column DEFAULT. Measured on `origin/main` before and after: * `due_datetime` carried a BARE CEL source string. `applyFieldDefaults` recognises an expression only by `{ dialect, source }`, so the bare string fell to the literal branch; an insert was refused ("bad_dt must be a valid datetime (ISO-8601)"), and the SQL DDL emitted `` `cur_due_datetime` datetime default 'daysFromNow(7)' `` -- the source text as a physical column DEFAULT. Replaced with the explicit envelope, which evaluates (2026-08-17T00:00:00.000Z from a 2026-08-10 now) and emits no column DEFAULT. * `revenue` carried `{ value: 0, currency: 'USD' }`. `currency` is in `NUMERIC_VALUE_TYPES`, so the stored contract is `z.number().finite()`; the object was refused by the record validator and dropped entirely by the SQL DDL (no default at all). Replaced with `0`, which stores and emits `float default '0'`. The inline comments now state what the corrected samples actually mean, including that `defaultValue` -- unlike a formula field's `expression` -- has no bare-string CEL shorthand, which is the trap the old sample set. Docs-only: no behaviour change, no changeset. Claude-Session: https://claude.ai/code/session_01KJATVrh6V2ysutYUJigh3B Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4d94308 commit f0ac3e4

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

content/docs/protocol/objectql/schema.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ revenue:
382382
label: Annual Revenue
383383
scale: 2
384384
precision: 18
385-
defaultValue: { value: 0, currency: 'USD' }
385+
defaultValue: 0 # currency stores a bare number — never { value, currency }
386386
```
387387

388388
#### Date/Time Fields
@@ -396,7 +396,10 @@ start_date:
396396
due_datetime:
397397
type: datetime
398398
label: Due Date & Time
399-
defaultValue: "daysFromNow(7)" # 7 days from now (CEL)
399+
# A CEL default needs the explicit `{ dialect, source }` envelope. Unlike a
400+
# formula field's `expression`, `defaultValue` has NO bare-string shorthand —
401+
# a bare string is stored as that literal text.
402+
defaultValue: { dialect: 'cel', source: 'daysFromNow(7)' } # 7 days from now, at UTC midnight
400403
```
401404
402405
#### Boolean Fields

0 commit comments

Comments
 (0)