Skip to content

fix(mariadb): emit NOCYCLE/NOCACHE on ALTER SEQUENCE#64

Merged
huyplb merged 1 commit into
mainfrom
fix/mariadb-alter-sequence-nocycle
Jul 12, 2026
Merged

fix(mariadb): emit NOCYCLE/NOCACHE on ALTER SEQUENCE#64
huyplb merged 1 commit into
mainfrom
fix/mariadb-alter-sequence-nocycle

Conversation

@huyplb

@huyplb huyplb commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

The web E2E suite surfaced a MariaDB migration failure. When a sequence differs between source and target, the generator's ALTER SEQUENCE path built its statement directly and — unlike the CREATE SEQUENCE path — never routed through MariaDB's wrapCreateSequence normalizer. So it emitted:

ALTER SEQUENCE order_seq RESTART WITH 1000 INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775806 NO CYCLE CACHE 1000;

MariaDB requires the single tokens NOCYCLE/NOCACHE and rejects the spaced form:

You have an error in your SQL syntax ... near 'CYCLE CACHE 1000'

That aborted and rolled back the entire migration (2 MariaDB E2E assertions failed).

Fix

  • New wrapAlterSequence(qualifiedName, alterSql) dialect hook, mirroring the existing wrapCreateSequence. Default is a no-op — Postgres/DB2/SQL Server/Oracle are unaffected (they accept NO CYCLE/NO CACHE).
  • The MariaDB dialect implements it, and the NO CYCLE→NOCYCLE / NO CACHE→NOCACHE normalization is factored into a shared normalizeSequenceTokens helper used by both the CREATE and ALTER paths, so they can't drift again.

Test plan

  • New unit test asserts the MariaDB ALTER emits NOCYCLE/NOCACHE and never NO CYCLE/NO CACHE
  • npx vitest run — 242 passed, 2 skipped
  • cd apps/web && npx tsc --noEmit — clean
  • Verified against the real MariaDB container: the old SQL errors, the new SQL succeeds (exit 0)
  • Web E2E: MariaDB went from FAIL to 10/10; full clean re-run of all 6 configured dialects (PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, DB2) is 6 passed / 0 failed

🤖 Generated with Claude Code

… CYCLE")

The ALTER SEQUENCE path built its statement directly and never routed through
MariaDB's wrapCreateSequence normalizer, so a MODIFIED sequence emitted
`... NO CYCLE CACHE 1000`. MariaDB requires the single tokens NOCYCLE/NOCACHE and
rejects the spaced form ("syntax error near 'CYCLE CACHE 1000'"), which aborted
and rolled back the whole migration.

Add a `wrapAlterSequence` dialect hook (mirroring wrapCreateSequence) and have
the MariaDB dialect apply the same NO CYCLE→NOCYCLE / NO CACHE→NOCACHE
normalization, factored into a shared helper so the CREATE and ALTER paths stay
in sync. Default is a no-op, so Postgres/DB2/SQL Server/Oracle are unaffected.

Found by the web E2E suite (mariadb went from FAIL to 10/10; full suite 6/6 green).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@huyplb huyplb merged commit ffc8cb7 into main Jul 12, 2026
4 of 6 checks passed
@huyplb huyplb deleted the fix/mariadb-alter-sequence-nocycle branch July 12, 2026 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant