Repository navigation
fix(driver-sql): a MySQL TEXT column carries its declared literal default - #37331
Conversation
…ault
knex's MySQL column compiler drops every DEFAULT on a text builder, so a
storage.notNull text field with a literal defaultValue was added to a
populated MySQL table as TEXT NOT NULL with no DEFAULT: existing rows read
'' and every insert omitting the field was refused. The column is now
declared through specificType with the expression form DEFAULT ('d'),
which MySQL 8.0.13+ accepts on TEXT, and the differ reads MySQL's
charset-introduced spelling of that default as an expression.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011y7As6JrAPNfuwC2RLXXGu
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011y7As6JrAPNfuwC2RLXXGu
📓 Docs Drift Check6 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 15 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 5929cfd4274b8106fb2d5c20b10d4a37f795dac4 && git checkout 5929cfd4274b8106fb2d5c20b10d4a37f795dac4
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin dbc1765a24e953ae52c2a4aa2c600b4b1461ed0d c4ce8ab14d228d562d85fd28b16b38aa08898c28 && git checkout -B drift-repro dbc1765a24e953ae52c2a4aa2c600b4b1461ed0d && git merge --no-ff c4ce8ab14d228d562d85fd28b16b38aa08898c28
node scripts/docs-audit/affected-docs.mjs --json dbc1765a24e953ae52c2a4aa2c600b4b1461ed0d |
…spelling Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011y7As6JrAPNfuwC2RLXXGu
|
repo:objectstack#7 · os-alice · session_011y7As6JrAPNfuwC2RLXXGu
席位意见:ACCEPT,排队落地;合入队列那次构建就是实测 MySQL 的读数。 席位核对 — ACCEPT · head c4ce8ab (2026-11-25T18:44Z)
|
…surface (objectstack-ai#38267) <!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DDypKu7B9nwbu5WuV7AEio8)_ Part of objectstack-ai#38087 (items 1–2; item 3 is the maintainer's) Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:用户无感。开发 agent 动 SQL 驱动时,派发工具现在会提前告诉它“真库测试会在合并队列里跑”。以前工具对这一项一字不提。 - 为什么做:配合“改 SQL 驱动的 PR 在合并队列里跑真库测试”这项裁决(先观察,再定是否必过)。观察读数已贴在卡上:三天多里有 23 个改驱动的 PR 跑了这一项,只红过一次。那次是 PR 自己新加的测试在 MySQL 上失败,因为这一项不是必过,PR 照样合进主干,主干红了约 6 小时。没有偶发失败,也没有拖慢队列。 - 出错会怎样:只影响开发 agent 读到的提示文字和一段代码注释,不影响 CI 本身,可直接撤回。 - 要你做什么:无。是否把这一项设为必过,由席位另行带读数问你。 ## What changes - **`scripts/pm/dispatch-gates.mjs`** fixes item 2's first bullet, which did not match main. - The `temporal-conformance` job's `if:` (ruling record 7146156389) ends in a clause that `jobIfReading` refused whole: `github.event_name != 'pull_request' && (github.event_name != 'merge_group' || needs.filter.outputs.temporal_live != 'false')`. So a driver-sql card derived no row for the live PG + MySQL leg at all. - The reader now recognises that exact spelling as a third WHEN and returns `queueGate`. `jobFilterPopulation` resolves the output's globs. - `jobFilteredSteps` then decides per card, on a glob that matches the path itself (`triggerListMatches`, which has no directory reach), and names that glob on the row: - a matching path gets "first run is the merge-queue build"; - a path that matches none and reaches into none gets the full-battery sentence; - a directory surface that only reaches into the globs (for example `packages/runtime`, through the one-file cascade-delete glob) gets a hedged third sentence: "the merge-queue build runs it only if a changed file is in `filter.temporal_live` … otherwise its first run is `main`'s push battery". The same hedge applies when the queue list is uncertain: a dropped positive extglob, or a plain negation, which paths-filter and GitHub's `paths:` read differently. A negated extglob still refuses the job. - An unparenthesised `A || B` ahead of any stripped event clause is now refused. GitHub binds `&&` tighter than `||`, so the clause binds to `B` alone. `(A || B)` reads as before, and no live `if:` is spelled the bare way. - The population is still the filter outputs ahead of the clause. The queue output's globs never join it. - **`scripts/check-required-contexts.mjs`**: the tombstone prose said the leg runs "in the FULL BATTERY only". It now says the leg also runs on a queue entry that hits `temporal_live`, that it is still not a required context, and that the call is the maintainer's. Prose only: `REQUIRED_CONTEXTS` and every pinned name are untouched. - **Re-read and already right on main, so left untouched:** - The THE TWO SPEEDS comment in `ci.yml`: already names the exception and says it is advisory. No `ci.yml` edit, so this PR does not overlap objectstack-ai#36646 or objectstack-ai#38132. - The required-set paragraph in `AGENTS.md`: the eleven contexts are exact, and "a check outside those eleven is advisory" covers the leg. Net 0 bytes. - `docs/agents/multi-agent-discipline.md` › Two speeds: already carries the exception sentence. - `scripts/pm/check-expected-skips.mjs:1318`: this is the self-test's FIXTURE_TREE, frozen on purpose to judge the measured historical heads, not the live tree. The live roster is derived and already handles the new `if:` (`--roster`: "gate: job-gate filter core + pr-event pull_request; derived"). ## Observation reading (item 1) Posted on the card: objectstack-ai#38087 comment 7237905765. - Window: 863 `merge_group` runs since PR objectstack-ai#37155. The leg ran in 38 of them, which are 23 distinct entries. - Reds: 1, an own regression. PR objectstack-ai#37279's new live-MySQL test failed. It landed anyway, because the leg is advisory, and objectstack-ai#37331 fixed it about 6 h later. Flakes 0, inherited 0. Entries that hit a live glob and skipped the leg: 0. - Leg minutes: median 11.1, p90 13.6. - Queue wall time where the leg ran: median 28.4. Where it skipped: median 24.6. The leg is never on the critical path: it finishes 7 to 26 minutes before the run does. ## Tests <details><summary>self-test, ablation, derived output (head 0e1b472)</summary> - `os-verify-lock.sh -c 'pnpm check:pm-dispatch-gates'`: `✓ dispatch-gates self-test (fast tier): 2385 cases pass`, `VERDICT command-exit 0`. New cases: - the queue-path reading, three near-miss refusals and `queueGate` null elsewhere; - LIVE: a route-ledger path gets the full-battery sentence; - LIVE: a driver-sql path gets the queue-build sentence; - an in-place ablation of `queueOutput` on the row; - added in the rework: - `triggerListMatches` against `triggerListCovers` on a directory; - LIVE: the directory surface `packages/runtime` gets the hedged sentence, never the queue-build-first one; - its ablation: with `queueHedged` stripped, the queue-build-first sentence comes back; - the driver-sql row names its matching glob; - `queueUncertain` for a dropped extglob and for a plain negation; - the bare `A || B` refusals beside the parenthesised read. - On-disk mutation: with the clause match replaced by `null`, `jobIfReading(<live temporal if>)` returns `null`. Restored with `git checkout HEAD --`, it returns `{refs:[filter.core], notOnPullRequest:true, queueGate:filter.temporal_live}`. - `node scripts/pm/dispatch-gates.mjs packages/drivers/driver-sql/src/sql-driver.ts` now prints `[ci.yml · Temporal Conformance (live PG + MySQL)] … ⛔ does NOT run on this PR: … your paths hit filter.temporal_live, so its first run on this change is the merge-queue build`. Before, it printed no row. - `node scripts/check-required-contexts.mjs --self-test`: 190 assertions pass. </details> ## Acceptance notes - `check-expected-skips`'s derived reason for this job still reads "answered by the merge-queue build" and adds "(plus 2 further condition(s) the recogniser does not read)". That is true only when the entry hits `temporal_live`. The hedge is honest, and the recogniser deliberately evaluates no paths, so this is noted here and not filed. ## Verification - Read first: `scripts/pm/dispatch-gates.mjs` `jobIfReading` (the recursion on the text before the clause, which refuses a doubled event clause), then `jobFilteredSteps` (the per-card `queueHit`). - Two-minute check: `node scripts/pm/dispatch-gates.mjs packages/drivers/driver-sql/src/sql-driver.ts 2>&1 | grep Temporal` should print one row ending "first run on this change is the merge-queue build". <details><summary>local gates (head 0e1b472)</summary> - `dispatch-gates --ran`: 70 of 70 derived families accounted for. - `pnpm check:i18n-coverage`: NOT MEASURED, exit 3 `PREREQUISITE NOT MET — the workspace CLI is not built`. The gate needs the CLI and every example config built, and this diff touches neither. CI's `Lint & Repo Gates` runs it. The first round's report wrongly counted this gate as exit 0. - Every other derived command exited 0, `node scripts/check-self-test-workflow-commands.mjs` included. It timed out in the first round and is green now. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_016WV4cxRDKprCtjpEdtiPFW)_ <!-- signed: repo:objectstack#1 · os-elon-musk · session_016WV4cxRDKprCtjpEdtiPFW --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Alice · project thread
Fixes #37320
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
textbuilder (itsdefaultToreturns an empty string for a text/blob type, a raw expression included), and MySQL refuses a literal DEFAULT on a TEXT column anyway (ER_BLOB_CANT_HAVE_DEFAULT). So since the ADD COLUMN change for driver-sql: schema sync adds a new storage.notNull field to an existing table as NOT NULL with no default — on SQLite the whole object's sync fails and the object becomes unwritable #37258,added_dflt(type: 'text',storage.notNull,defaultValue: 'd') was added to the populated MySQL table astext not nullwith no DEFAULT. MySQL then gives existing rows the implicit'', and an insert that omits the column is refused (Field 'added_dflt' doesn't have a default value). Those are the two red cases. Postgres keeps the DEFAULT, which is why its half passed.mysql:8.0image the CI job uses):ALTER TABLE … ADD COLUMN a text not null default ('d')on a populated table gives the existing rowd, and an insert that omitsastoresd. The expression form needs MySQL 8.0.13+ / MariaDB 10.2+, the floornowColumnDefaultalready states for itstime/datedefaults.createColumn(sql-driver-column-creation.ts): the two unbounded-text sites (an unboundedstring-family field, and an unkeyed text-family field) build the column throughspecificType(name, 'text')on MySQL when the field declares a literal default, so knex keeps the clause, and askapplyDeclaredColumnDefaultfor the expression form. Same physical type (text).NOW()on a text column keeps the old behaviour (no DEFAULT):nowColumnDefaulthas no text-column expression on MySQL.applyDeclaredColumnDefault(sql-driver-schema-sync.ts) takes anexpressionFormflag and emitsknex.raw('(?)', [dv]), so the literal is escaped by the client as before.SqlDriver#applyDeclaredColumnDefaultpasses it through and gives the bodyknex.sql-driver.tsstays at its line ceiling (10071).physicalDefaultLiteral(schema-drift.ts): MySQL reports that DEFAULT as the charset-introduced, backslash-escaped_utf8mb4\'d\'(EXTRA = DEFAULT_GENERATED). Read as a bare literal, it compared unequal to the declaration. The live run of the new drift case showedset_column_default:added_dfltproposed against the column that had just been created. The statement that applies that op is refused on a TEXT column (ALTER COLUMN … SET DEFAULT, the parenthesised form too, measuredER_BLOB_CANT_HAVE_DEFAULT). The spelling is now read as an expression, like every other physical expression, and neither literal arm acts on it.Tests
sql-driver-37258-add-column-not-null.test.ts: the two MySQL cases pass unchanged. New case on every cell: "reports no drift for the column that took its declared literal default". It is red on MySQL without theschema-drift.tsreading.sql-driver-36245-stale-literal-default.test.ts: two rows in the physical-DEFAULT table pin the MySQL spelling asexpression, on every run, including CI runs with no live server.Repro at base 829a45e, live MySQL 8.0.46 (local container)
Fix, all three dialects (sqlite, live PG 16, live MySQL 8.0.46)
Full driver-sql suite in the CI step's environment, head ddccf38
TZ=America/New_York, PG at Asia/Shanghai, MySQL at +08:00, OS_EXPECT_LIVE_DIALECT_MATRIX=1, both live URLs set. These are the "Run driver-sql suite against both live servers" step's settings.
An earlier run against UTC servers failed 7 tests and 4 suites, all on the testkit's "server runs at UTC" fixture assertion. That is the environment, not the change.
pnpm --filter @objectstack/driver-sql typecheck: exit 0.Ablation: the specificType choice reverted to table.text (scripts/ablation-replace.mjs)
The suite imports the driver from
src/, so the mutation needs no rebuild.Acceptance notes
Temporal Conformance (live PG + MySQL)never runs onpull_request. Itsif:readsgithub.event_name != 'pull_request', so it runs on push/schedule and in the merge queue when the entry's diff hits thetemporal_livepaths. This PR's own check-runs therefore do not carry it. The live evidence above is local, from the same images and settings. The queue build of this PR is the first CI measurement. No workflow file is touched.defaultValue: 'NOW()'on MySQL still gets no column DEFAULT (knex dropsCURRENT_TIMESTAMPon TEXT, and a bare one is refused). Also, the MySQLrelax_not_null/tighten_not_nullarms restate a column throughMODIFYwithout its DEFAULT. Neither is reached by this card's cases.Verification
Read first:
sql-driver-column-creation.ts(textColumnand themysqlTextDefaultflag at the head of the type switch), thenschema-drift.ts(MYSQL_INTRODUCED_STRINGinphysicalDefaultLiteral).Two-minute check: start
mysql:8.0and runOS_TEST_MYSQL_URL=mysql://root:root@127.0.0.1:3306/conformance pnpm --filter @objectstack/driver-sql exec vitest run src/sql-driver-37258-add-column-not-null.test.ts. Expect 12 passed: 6 on sqlite and 6 on live mysql.Local gates, head ddccf38 (trial deviations, 试行偏离: the derived families run locally, the rest cited to CI)
dispatch-gates --repo objectstack-ai/objectstack --commands: 73 families. All 73 ran: 70 exit 0, 3 exit 3 (NOT MEASURED, prerequisite):check-plugin-teardown-shape.mjs --self-test: shallow clone, the pinned positive-control commit is unreachable.check:dual-build-cjs-loadsandcheck:lean-entry-closure: they read every package'sdist/, and only the driver-sql closure is built here.--ranwith exit codes:73 derived, 70 run, 3 NOT-MEASURED (3 DERIVED from a recorded exit 3), 0 UNRUN.check:facade-delegation-only:sql-driver.ts: 10071 lines, ceiling 10071.check:nul-bytes: OK.🤖 Generated with Claude Code
https://claude.ai/code/session_011y7As6JrAPNfuwC2RLXXGu