From ce9cea5fb02b8bfa96fee3dc132cb459ad29d69b Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 10 Aug 2026 08:09:36 +0000 Subject: [PATCH] docs(protocol): correct the two wrong `defaultValue` samples in schema.mdx (#7244) 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. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01KJATVrh6V2ysutYUJigh3B --- content/docs/protocol/objectql/schema.mdx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/content/docs/protocol/objectql/schema.mdx b/content/docs/protocol/objectql/schema.mdx index 6ba6fbe562..241391d541 100644 --- a/content/docs/protocol/objectql/schema.mdx +++ b/content/docs/protocol/objectql/schema.mdx @@ -382,7 +382,7 @@ revenue: label: Annual Revenue scale: 2 precision: 18 - defaultValue: { value: 0, currency: 'USD' } + defaultValue: 0 # currency stores a bare number — never { value, currency } ``` #### Date/Time Fields @@ -396,7 +396,10 @@ start_date: due_datetime: type: datetime label: Due Date & Time - defaultValue: "daysFromNow(7)" # 7 days from now (CEL) + # A CEL default needs the explicit `{ dialect, source }` envelope. Unlike a + # formula field's `expression`, `defaultValue` has NO bare-string shorthand — + # a bare string is stored as that literal text. + defaultValue: { dialect: 'cel', source: 'daysFromNow(7)' } # 7 days from now, at UTC midnight ``` #### Boolean Fields