Repository navigation
fix: correct the remaining per-dialect attributeToSql bugs - #18402
Merged
wikirik-agent merged 0 commit intoSep 18, 2026
Conversation
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
wikirik-agent
force-pushed
the
wikirik-agent/attributes-to-sql-latent-bugs
branch
2 times, most recently
from
September 18, 2026 20:36
fd9e289 to
1cab5f2
Compare
wikirik-agent
deleted the
wikirik-agent/attributes-to-sql-latent-bugs
branch
September 18, 2026 21:23
wikirik-agent
force-pushed
the
wikirik-agent/attributes-to-sql-latent-bugs
branch
from
September 18, 2026 21:23
1cab5f2 to
4095bd8
Compare
wikirik-agent
restored the
wikirik-agent/attributes-to-sql-latent-bugs
branch
September 18, 2026 21:28
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.
Description of Changes
Fourth and last of the stack re-implementing #17121, stacked on #18401.
These are the per-dialect bugs found while converting the nine
attributeToSqlimplementations to TypeScript. Unlike the earlier PRs in the stack, every claim here was verified against a real server (SQL Server 2025, Db2 LUW 12.1.4, Oracle 23.26 Free, MySQL 8.4, MariaDB 11.6) rather than from reading the source.mysql —
DEFAULTwas silently dropped for BLOB, TEXT, GEOMETRY and JSONMySQL accepts a default on those types as long as it is written as an expression, i.e. wrapped in parentheses, since 8.0.13. The minimum supported version is 8.0.20, so every supported server can take one.
The drop is now a parenthesisation, so the value reaches the server:
Verified end to end: the column is created and the value round-trips.
Worth noting the guard sat before the existing
BaseSqlExpressionparenthesisation, so the MySQL 8.0.13 expression-default support already in the codebase was unreachable for exactly the types that needed it.mariadb — same drop, but MariaDB has no such restriction at all
MariaDB has accepted defaults on BLOB/TEXT since 10.2.1 (MDEV-10134) and the minimum supported version is 10.4.30, so the list is removed outright rather than converted. Verified: bare
TEXT DEFAULT 'abc',BLOB,JSONandGEOMETRYdefaults are all accepted.mariadb also emitted expression defaults unparenthesised, which MariaDB rejects for anything that is not a bare function call —
DEFAULT 1+1fails,DEFAULT (1+1)works. Those are now parenthesised as they already were on mysql, which is why threecreate-tableexpectations change.oracle — two branches that could never have worked
else if (attribute.type && attribute.type === 'DOUBLE')only matches the raw string'DOUBLE', and then calls.toSql()on it, which a string does not have. Reaching it threw aTypeError.DataTypes.DOUBLErenders asBINARY_DOUBLEorDOUBLE PRECISIONand never takes this path. A raw string type now falls through to the general branch like every other one.Model.tableNameagainstreferences.tableName, but v7 references usereferences.table, so the comparison was always againstundefinedand the check never fired. It now goes throughisSameTable, as mssql's equivalent already does.mssql and oracle —
attributeToSqlmodified its inputBoth cleared
onDelete/onUpdateon the caller's attribute object for self-referencing columns (oracle's check only started firing with the fix above). oracle also setunsignedtofalseon the shared data type, so a second call with the same type silently lost itsCHECK (... >= 0). Both now work on a copy; oracle's integer types never renderUNSIGNED, so the flag only needs to be read.ibmi — dead local
attributeStringwas computed and then overwritten by both following branches.Not changed, and why
attribute.comment— I had this on my list, but SQLite has noCOMMENTsyntax at all, so there is nothing to emit. Not a bug.typeWithoutDefault— left alone. I have no Snowflake account and no Db2 for i server, and after finding that five of the seven lists were wrong I did not want to change two more on documentation alone. Both are now the only remaining lists.Verification
eslint, cleantscon both configs.TZ=UTC; four timestamp tests otherwise fail on a host in CEST, unrelated to this change. One db2 run hit anSQL0911Ndeadlock in anafter eachhook and passed on rerun.List of Breaking Changes
mysql and mariadb now emit a
DEFAULTclause for column types where they previously emitted none. A model that declared adefaultValueon aTEXT/BLOB/JSON/GEOMETRYcolumn silently got no default before and will now get the one it asked for.Replaces #18369, which was opened from a fork before stacked PRs were possible.
🤖 Generated with Claude Code