docs(protocol): correct the two wrong defaultValue samples in schema.mdx - #7376
Merged
Merged
Conversation
…a.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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KJATVrh6V2ysutYUJigh3B
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
os-help
marked this pull request as ready for review
August 10, 2026 08:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7244
Docs-only.
content/docs/protocol/objectql/schema.mdxis the only file touched — no schema, no engine, no driver, no gate.What changed
The card's originals — confirmed wrong
valueSchemaFor(...).safeParse(...), the probe the card used:End-to-end insert of both current samples through the engine (memory driver) is refused, not silently stored:
And the SQL DDL,
better-sqlite3, realCREATE TABLE:Both halves of the card's trace reproduce exactly.
The replacements — measured, not assumed
This is what the card supplied but never probed.
DDL for the same two replacement declarations:
So the envelope does not leak the source text into the DDL, which was the failure to rule out.
daysFromNowis a genuinely registered stdlib function (packages/formula/src/stdlib.ts:117), not invented from a doc comment — an unregistered name is refused loudly:daysFromNow(n)returns the calendar day at UTC midnight (ADR-0053 D1), so the inline comment now says so rather than the bare "7 days from now" — the old comment was true of neither the old sample nor, precisely, the new one.now() + duration("168h")was measured as the sub-day alternative (Mon Aug 17 2026 09:30:00 GMT+0000) and deliberately not used:daysFromNowis the helper the card named and the skills teach.One thing the measurement did not confirm
The card says the bare string "stores the 14 characters into the datetime field".
applyFieldDefaultsdoes assign it, but the record validator refuses the insert immediately after, so on an ordinary field the user-visible symptom is a failed write, not silent bad data. The silent-storage reading holds only wherevalidateRecordis skipped (readonly/systemfields,isSystemwrites) and for the physical column DEFAULT above, which is emitted regardless. The sample is wrong either way; the mechanism is worth stating accurately.Population scan
The card found two defects and did not claim two was all. Every
defaultValueon the page was probed:selectdraftnullnullmeans "no default"number1currency{ value: 0, currency: 'USD' }datetime"daysFromNow(7)"booleantruetogglefalseselectmediumbooleantrueTwo is the complete population on this page. The look-alike at line 706 —
expression: "record.first_name + ' ' + record.last_name"on aformulafield — is correct and deliberately untouched:expressionis typedExpressionInputSchema, whose union accepts a bare string as shorthand for{ dialect: 'cel', source }.defaultValueisz.unknown()and has no such shorthand. That asymmetry, two sections apart on one page, is precisely why the old sample looked plausible, so the new comment names it.Also checked: the 26 YAML blocks on the page parse identically before and after (3 pre-existing non-parsing blocks are deliberate side-by-side illustrations, untouched).
Gates
check:doc-authoringcheck:docs-audit-scopecheck:nul-bytescheck:adr-linkscheck:quick-reference-countscheck:org-identifier,check:role-wordpnpm --filter @objectstack/docs buildThe docs build matters here: CI's
build-docsjob filters oncontent/**, so this change triggers it.Out of scope
Filed as #7373: a CEL
defaultValuestores a rawDateintodatetime/datefields, while the stored-value contract names an ISO-8601 string — theNOW()token normalizes viaresolveNowDefaultand the CEL branch has no counterpart. Reachable by the corrected sample this PR lands, but it is an engine defect, not a docs one, so it is filed rather than fixed here (ruling: file surface is this page and nothing else).No changeset: docs-only, nothing user-visible ships.
skip-changesetis the PM's to apply at accept time.Generated by Claude Code