Skip to content

fix(driver-sql): removing a field default stores NULL on MySQL 8, and never leaves a NOT NULL column refusing writes - #36600

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-a7tzee
Nov 23, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-a7tzee

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Warren · project thread

Fixes #36596
Clause-②: no
Metadata-protocol: none

维护者速读

  • 修复 main 变红:字段删掉默认值后,MySQL 8 上不填该字段的新记录会被数据库拒绝,现在改为存空值,和 Postgres、SQLite 一致。
  • 对「不允许为空」的列,删默认值不再单独执行:字段允许为空时和「放开非空」一起执行;字段仍要求非空时原样保留,只报出。
  • 已有记录一行不改;改动可直接回退。

The cause (premise correction)

The card says the dropped DEFAULT "leaves the column NOT NULL". Measured on MySQL 8.0.46, it does not: digest is IS_NULLABLE = YES throughout. The cause is MySQL 8's ALTER COLUMN … DROP DEFAULT, which leaves even a nullable column with no default at all, so a strict-mode insert that omits it fails with ER 1364 "Field 'digest' doesn't have a default value". SET DEFAULT NULL stores NULL. Round 1 (#36564) was measured on MariaDB 10.11, which stores NULL after DROP DEFAULT, and the live MySQL leg did not run on that PR.

mysql> CREATE TABLE p (id varchar(36) PRIMARY KEY, digest varchar(255) DEFAULT 'none');
mysql> ALTER TABLE p ALTER COLUMN digest DROP DEFAULT;
mysql> INSERT INTO p (id) VALUES ('a');
ERROR 1364 (HY000): Field 'digest' doesn't have a default value
mysql> ALTER TABLE p ALTER COLUMN digest SET DEFAULT NULL;
mysql> INSERT INTO p (id) VALUES ('a');   -- stores NULL

What changes

packages/drivers/driver-sql/** only, plus this changeset.

Tests

sql-driver-36245-stale-literal-default.test.ts: §1 and §2 unchanged (not skipped, quarantined or narrowed); §2 now passes on live MySQL 8. New §3, per dialect cell (SQLite, live PG, live MySQL), on a NOT NULL column with DEFAULT 'none':

  1. No default, no storage declaration, not required: drift is drop_column_default + relax_not_null, both needs_confirm; dev boot leaves the column (unset insert stores 'none'); applyMigrationEntries applies both; unset insert stores NULL; no drift after.
  2. storage: { notNull: false }: applyPublishedColumnChanges applies both; unset insert stores NULL.
  3. storage: { notNull: true }: one destructive entry; boot, publish and non-destructive apply leave the column NOT NULL with its default.
  4. required: true, no storage: same as 3.

Live PG + MySQL evidence (in-container, CI's own setup)

Servers: MySQL 8.0.46 (STRICT_TRANS_TABLES, innodb_strict_mode=1, SET GLOBAL time_zone='+08:00') and PostgreSQL 16 (ALTER SYSTEM SET timezone='Asia/Shanghai'). Run exactly as the "Temporal Conformance (live PG + MySQL)" step runs it: TZ=America/New_York OS_EXPECT_LIVE_DIALECT_MATRIX=1 OS_TEST_POSTGRES_URL=… OS_TEST_MYSQL_URL=… pnpm --filter @objectstack/driver-sql test.

Before (origin/main 79d9c14), the red reproduced on live MySQL 8:

 FAIL  sql-driver-36245-stale-literal-default.test.ts > … #36245 §2 … (live mysql) > the second boot drops the removed default …
Error: insert into `os36245_pref` (`id`, `title`) values ('after', 'after') - Field 'digest' doesn't have a default value
 FAIL  sql-driver-36245-stale-literal-default.test.ts > … #36245 §2 … (live mysql) > without auto-reconcile the divergence is reported `safe` …
Error: insert into `os36245_pref` (`id`, `title`) values ('repaired', 'repaired') - Field 'digest' doesn't have a default value

After (head f972c24), the file, verbose: 51 passed (51). Every §2 and §3 case passes on sqlite, live postgres and live mysql (18 two-boot cases, 6 per dialect); driver-sql live-dialect coverage: all 3 dialects were exercised (sqlite, live postgres, live mysql).

After, the whole driver-sql suite under the CI step's setup:

 Test Files  1 failed | 280 passed | 1 skipped (282)
      Tests  1 failed | 7007 passed | 10 skipped (7018)
 FAIL  sql-driver-11565-row-byte-budget.test.ts > … row byte budget on live MySQL (#11565) > reports InnoDB page-limit refusals with the page limit, not the row budget

The one failure is not this PR's: it fails identically at origin/main 79d9c14 against the same local server (same command, main's src/), and passes on main's CI mysql:8.0 image. The difference is this container's Ubuntu MySQL build, not the code: the case expects the server to refuse a new 40-column table, and this server accepts it. This PR touches no create path.

Ablations (scripts/ablation-replace.mjs, each restored to HEAD, run on all three cells):

Mutation Result
MySQL drop back to DROP DEFAULT on a nullable column 4 fail: both §2 MySQL cases (ER 1364, the main-red failure), and the two MySQL §3 cases that relax then drop
NOT NULL column drop emitted safe and unpaired, as on main 9 fail across all three dialects
Publish/install no longer select the paired drop 3 fail: the storage: { notNull: false } publish case on each dialect
Pair the drop even when the declaration holds NOT NULL 6 fail: the notNull: true and required cases on each dialect

Follow-ups (not in this PR)

  • content/docs/deployment/cli.mdx (the publish paragraph under the drift-category table) says the publish applies "every safe column change, and a relax_not_null whose field declares storage: { notNull: false }". It now also applies the paired drop_column_default. That page is outside this card's file surface, so it is not edited here.
  • On MySQL, relax_not_null runs MODIFY … NULL, which also drops a column's declared literal DEFAULT (measured: NOT NULL DEFAULT 'x' becomes DEFAULT NULL); the schema sync: removing a literal defaultValue from a field leaves the physical column DEFAULT on every SQL database an earlier release created, so unset writes keep storing the old default #36245 set_column_default arm restates it on the next sync. Pre-existing and unchanged here.
  • The "Temporal Conformance (live PG + MySQL)" job is path-filtered and skipped on PRs, which is how round 1 reached main. Making it run on a driver-sql PR is a .github/workflows/ci.yml change: governed (Tier H) and outside this card's file surface, so it is not made here. Evidence from in-container live servers is pasted instead.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JQwxbY6wSVQZ9QBM4hLeYw

…OT NULL columns pair it with the relax

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbY6wSVQZ9QBM4hLeYw
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 23, 2026
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/driver-sql, touching 9 documentable anchor(s).

1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/deployment/cli.mdx (via needs_confirm (literal, a string literal in diffManagedTable; a string literal in isDeclaredRelaxPair; a string literal in isInstallRelaxation; a string literal in isPublishedColumnChange), relax_not_null (literal, a string literal in isDeclaredRelaxPair; a string literal in isInstallRelaxation; a string literal in isPublishedColumnChange))

⛔ 1 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-0.mdx (via needs_confirm (literal, a string literal in diffManagedTable; a string literal in isDeclaredRelaxPair; a string literal in isInstallRelaxation; a string literal in isPublishedColumnChange))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • the SDK route bridge reached 68 of 251 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 15 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 79d9c1435586d9b411b51a0ac395ea0c23dc3ddc → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 19710918a359f8b3a951a380226d0384992c1ae1 — the merge of head f972c24ced205938213adc96316ec3b08d055b0f into base 79d9c1435586d9b411b51a0ac395ea0c23dc3ddc, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 19710918a359f8b3a951a380226d0384992c1ae1 && git checkout 19710918a359f8b3a951a380226d0384992c1ae1
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 79d9c1435586d9b411b51a0ac395ea0c23dc3ddc f972c24ced205938213adc96316ec3b08d055b0f && git checkout -B drift-repro 79d9c1435586d9b411b51a0ac395ea0c23dc3ddc && git merge --no-ff f972c24ced205938213adc96316ec3b08d055b0f

node scripts/docs-audit/affected-docs.mjs --json 79d9c1435586d9b411b51a0ac395ea0c23dc3ddc

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 79d9c1435586d9b411b51a0ac395ea0c23dc3ddc → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj

维护者速读

修好主干变红:MySQL 上字段撤掉默认值后,不填该字段的写入不再被拒,改为存空值;三种数据库都在真实库上跑过。
原本"必填"的列不会被偷偷放宽:只有对象声明允许为空时,才连同放宽一起改,否则保持原样并在迁移计划里提示。
CI 全绿,223 行,非受管面,席位落地;合并后主干的 MySQL 实库测试会再验一遍。
要你做的:无。

席位核对 — ACCEPT (L1) · repo:objectstack#1 · head f972c24c · 2026-11-23T02:32Z

  • Shape: Fixes #36596; packages/drivers/driver-sql/src/schema-drift.ts, sql-driver-schema-sync.ts, the schema sync: removing a literal defaultValue from a field leaves the physical column DEFAULT on every SQL database an earlier release created, so unset writes keep storing the old default #36245 test file (+4 NOT NULL cases, nothing removed or narrowed), one changeset. +215/−8. Tier S (check-governed-merges: 0 of 4 paths governed); no L2 face.
  • Premise corrected and measured by the card thread on live MySQL 8.0.46: the column was nullable; MySQL 8's DROP DEFAULT leaves no default at all, so a strict-mode insert omitting it fails with ER 1364 where PG and SQLite store NULL. fix(driver-sql): a column's literal DEFAULT follows the field's declaration on an existing table #36564's live evidence was MariaDB 10.11, which is why it passed there.
  • Read: MySQL drop_column_default on a nullable column (columnInfo().nullable, read at apply time) is now SET DEFAULT NULL; NOT NULL keeps DROP DEFAULT. The differ no longer proposes a lone drop on a NOT NULL column: it pairs with the relax at needs_confirm when the declaration doesn't hold the column NOT NULL (publish/install apply the pair only for declared storage.notNull: false, via isDeclaredRelaxPair), else it is destructive and left alone with a message. The §3 pair case asserts, per cell, that the unset insert stores NULL after both ops are applied, so apply order and the stale ci read are covered on live MySQL.
  • Gates: 57 checks on f972c24c: 39 success · 18 skipped · 0 failed; landing-k K = 7 < 15. Temporal Conformance (live PG + MySQL) is still path-filtered off PR runs; the thread ran the CI step's exact command in-container (MySQL 8.0.46, PG 16): the file 51/51 on all three cells; the full suite 7007 pass, 1 fail (the driver-sql (MySQL): nothing sees the 65535-byte row budget, so a table with many wide declared bounds fails CREATE with an error naming no field #11565 InnoDB page-limit case, which fails identically on main against that local server and is green in CI's image). Before the fix, the two §2 MySQL cases fail with ER 1364 on main 79d9c143; the four ablations all go red.
  • Noted, not folded: the CI path filter that keeps live cells off driver-sql PRs is a governed ci.yml edit and a CI-budget question; it goes to the maintainer as a separate card, not this PR. The cli.mdx publish paragraph and the MySQL MODIFY default on relax (pre-existing) are in the thread's report.
  • Landing: ready + auto-merge now; main's push run is the live re-check.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 23, 2026 02:33
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit 89ce4fb Nov 23, 2026
58 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-a7tzee branch November 23, 2026 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

main red: on live MySQL, dropping a removed literal DEFAULT (#36245) leaves a NOT NULL column with no default, so unset inserts fail

2 participants