Repository navigation
Conversation
| }); | ||
| }); | ||
|
|
||
| // TODO: check what this test is supposed to do and update the possible defaultValue accordingly |
There was a problem hiding this comment.
This test is broken and should be split into multiple tests:
- One that uses
DataTypes.ARRAY(on dialects that support this type) with an empty array: should work - One that uses
DataTypes.BLOB: should never work,[]is not a valid value on a blob - One that uses
DataTypes.JSON(on dialects that support this type) : should always work - One that uses any string type (like
'JSON'insteadDataTypes.JSON): should never work because can't guess the type of an empty array and string types don't give any information
Note that the data type is an actual data type and not a string in the above two tests
| }); | ||
|
|
||
| // TODO: this test is broken for at least DB2. It adds the default value because the data type is a string, which can't have special behaviors. | ||
| // change type to an actual Sequelize DataType & re-enable |
There was a problem hiding this comment.
In this instance it's honestly default that's broken. String types don't give any information so the default value should always be added.
If DataTypes.BLOB were used, then the dialect could enforce specific behaviors
| }); | ||
| }); | ||
|
|
||
| // TODO: check what this test is supposed to do and update the possible defaultValue accordingly |
There was a problem hiding this comment.
Same remarks as the above three review notes:
Because the type is a string instead of an instanceof DataType, no special behavior can occur. We use string data types as-is, it's the equivalent of using a literal()
This test should use DataTypes.TEXT instead
An array is also not a good type to use to test that the default value is not added: A string would be a better value
| }); | ||
| }); | ||
|
|
||
| // TODO: check what this test is supposed to do and update the possible defaultValue accordingly |
| }); | ||
|
|
||
| // TODO: check what this test is supposed to do and update the possible defaultValue accordingly | ||
| it(`No Default value for JSON allowed for some dialects`, () => { |
|
Superseded by and linked in #17121 |
Moves both methods out of every dialect's `query-generator.js` and into its `query-generator-typescript.internal.ts`, and renames them from `attributeToSQL` / `attributesToSQL` to `attributeToSql` / `attributesToSql`. Closes the last item of sequelize#15533. The core declaration is now a typed contract every dialect implements, rather than a `ColumnsDescription` signature that described none of them. The new `AttributeToSqlColumn` interface documents what the dialects actually read, and is deliberately wider than `NormalizedAttributeOptions` because these methods are also called with `describeTable` output, where the type is a raw SQL string. `isBinaryStringType` joins `attributeTypeToDataTypeId` in the core data type utilities, replacing the `attribute.type.options?.binary` reach-through. No SQL changes. The pinned suites produce byte-identical output for all nine dialects. Typing the tests did surface two things they were getting wrong: a `deferrable` passed as a raw string rather than the `Deferrable` enum, and a leftover pre-rename option name. Three no-op arguments went away because the compiler proved they could not do anything: `AttributeToSqlOptions` and `EscapeOptions` share no properties, so mssql and snowflake were handing `escape` an object it could never read, and several `toSql({ dialect })` calls passed an argument no implementation accepts. Co-Authored-By: Claude Opus 5 <[email protected]>
Moves both methods out of every dialect's `query-generator.js` and into its `query-generator-typescript.internal.ts`, and renames them from `attributeToSQL` / `attributesToSQL` to `attributeToSql` / `attributesToSql`. Closes the last item of sequelize#15533. The core declaration is now a typed contract every dialect implements, rather than a `ColumnsDescription` signature that described none of them. The new `AttributeToSqlColumn` interface documents what the dialects actually read, and is deliberately wider than `NormalizedAttributeOptions` because these methods are also called with `describeTable` output, where the type is a raw SQL string. `isBinaryStringType` joins `attributeTypeToDataTypeId` in the core data type utilities, replacing the `attribute.type.options?.binary` reach-through. No SQL changes. The pinned suites produce byte-identical output for all nine dialects. Typing the tests did surface two things they were getting wrong: a `deferrable` passed as a raw string rather than the `Deferrable` enum, and a leftover pre-rename option name. Three no-op arguments went away because the compiler proved they could not do anything: `AttributeToSqlOptions` and `EscapeOptions` share no properties, so mssql and snowflake were handing `escape` an object it could never read, and several `toSql({ dialect })` calls passed an argument no implementation accepts. Co-Authored-By: Claude Opus 5 <[email protected]>
Moves both methods out of every dialect's `query-generator.js` and into its `query-generator-typescript.internal.ts`, and renames them from `attributeToSQL` / `attributesToSQL` to `attributeToSql` / `attributesToSql`. Closes the last item of sequelize#15533. The core declaration is now a typed contract every dialect implements, rather than a `ColumnsDescription` signature that described none of them. The new `AttributeToSqlColumn` interface documents what the dialects actually read, and is deliberately wider than `NormalizedAttributeOptions` because these methods are also called with `describeTable` output, where the type is a raw SQL string. `isBinaryStringType` joins `attributeTypeToDataTypeId` in the core data type utilities, replacing the `attribute.type.options?.binary` reach-through. No SQL changes. The pinned suites produce byte-identical output for all nine dialects. Typing the tests did surface two things they were getting wrong: a `deferrable` passed as a raw string rather than the `Deferrable` enum, and a leftover pre-rename option name. Three no-op arguments went away because the compiler proved they could not do anything: `AttributeToSqlOptions` and `EscapeOptions` share no properties, so mssql and snowflake were handing `escape` an object it could never read, and several `toSql({ dialect })` calls passed an argument no implementation accepts. Co-Authored-By: Claude Opus 5 <[email protected]>
Replaces the per-dialect `attributesToSQL` suites with two dialect-agnostic suites that cover all nine dialects, including ibmi and mssql which had no coverage at all. The expectations pin current behaviour exactly, so this commit changes no SQL. Behaviour that is wrong today is pinned as-is and marked with a TODO. `sqlite3` gains an `attributeToSQL` method, extracted from `attributesToSQL` without changing its output, so the shared suite can cover it like every other dialect. `inlineErrorCause` now inspects non-error values instead of stringifying them: mssql and ibmi return null-prototype maps from `attributesToSQL`, which threw when the assertion message was built. Closes #15533 Co-Authored-By: Claude Opus 5 <[email protected]>
…ToSql Moves both methods out of every dialect's `query-generator.js` and into its `query-generator-typescript.internal.ts`, and renames them from `attributeToSQL` / `attributesToSQL` to `attributeToSql` / `attributesToSql`. Closes the last item of #15533. The core declaration is now a typed contract every dialect implements, rather than a `ColumnsDescription` signature that described none of them. The new `AttributeToSqlColumn` interface documents what the dialects actually read, and is deliberately wider than `NormalizedAttributeOptions` because these methods are also called with `describeTable` output, where the type is a raw SQL string. `isBinaryStringType` joins `attributeTypeToDataTypeId` in the core data type utilities, replacing the `attribute.type.options?.binary` reach-through. No SQL changes. The pinned suites produce byte-identical output for all nine dialects. Typing the tests did surface two things they were getting wrong: a `deferrable` passed as a raw string rather than the `Deferrable` enum, and a leftover pre-rename option name. Three no-op arguments went away because the compiler proved they could not do anything: `AttributeToSqlOptions` and `EscapeOptions` share no properties, so mssql and snowflake were handing `escape` an object it could never read, and several `toSql({ dialect })` calls passed an argument no implementation accepts. Co-Authored-By: Claude Opus 5 <[email protected]>
…ToSql Moves both methods out of every dialect's `query-generator.js` and into its `query-generator-typescript.internal.ts`, and renames them from `attributeToSQL` / `attributesToSQL` to `attributeToSql` / `attributesToSql`. Closes the last item of #15533. The core declaration is now a typed contract every dialect implements, rather than a `ColumnsDescription` signature that described none of them. The new `AttributeToSqlColumn` interface documents what the dialects actually read, and is deliberately wider than `NormalizedAttributeOptions` because these methods are also called with `describeTable` output, where the type is a raw SQL string. It declares `Model`, which mssql and oracle read to detect a column that references its own table, and it deliberately has no index signature: one would turn off excess property checking, which is what let the old option name mismatches compile, and would also make `NormalizedAttributeOptions` unassignable to it. `isBinaryStringType` joins `attributeTypeToDataTypeId` in the core data type utilities, replacing the `attribute.type.options?.binary` reach-through. No SQL changes. The pinned suites produce byte-identical output for all nine dialects. Typing the tests did surface two things they were getting wrong: a `deferrable` passed as a raw string rather than the `Deferrable` enum, and a leftover pre-rename option name. Four no-op arguments went away because the compiler proved they could not do anything: `AttributeToSqlOptions` and `EscapeOptions` share no properties, so mssql and snowflake were handing `escape` an object it could never read, several `toSql({ dialect })` calls passed an argument no implementation accepts, and db2 read a `replacements` option that no caller has ever passed. Co-Authored-By: Claude Opus 5 <[email protected]>
Replaces the per-dialect `attributesToSQL` suites with two dialect-agnostic suites that cover all nine dialects, including ibmi and mssql which had no coverage at all. The expectations pin current behaviour exactly, so this commit changes no SQL. Behaviour that is wrong today is pinned as-is and marked with a TODO. `sqlite3` gains an `attributeToSQL` method, extracted from `attributesToSQL` without changing its output, so the shared suite can cover it like every other dialect. `inlineErrorCause` now inspects non-error values instead of stringifying them: mssql and ibmi return null-prototype maps from `attributesToSQL`, which threw when the assertion message was built. Closes #15533 Co-Authored-By: Claude Opus 5 <[email protected]>
…ToSql Moves both methods out of every dialect's `query-generator.js` and into its `query-generator-typescript.internal.ts`, and renames them from `attributeToSQL` / `attributesToSQL` to `attributeToSql` / `attributesToSql`. Closes the last item of #15533. The core declaration is now a typed contract every dialect implements, rather than a `ColumnsDescription` signature that described none of them. The new `AttributeToSqlColumn` interface documents what the dialects actually read, and is deliberately wider than `NormalizedAttributeOptions` because these methods are also called with `describeTable` output, where the type is a raw SQL string. It declares `Model`, which mssql and oracle read to detect a column that references its own table, and it deliberately has no index signature: one would turn off excess property checking, which is what let the old option name mismatches compile, and would also make `NormalizedAttributeOptions` unassignable to it. `isBinaryStringType` joins `attributeTypeToDataTypeId` in the core data type utilities, replacing the `attribute.type.options?.binary` reach-through. No SQL changes. The pinned suites produce byte-identical output for all nine dialects. Typing the tests did surface two things they were getting wrong: a `deferrable` passed as a raw string rather than the `Deferrable` enum, and a leftover pre-rename option name. Four no-op arguments went away because the compiler proved they could not do anything: `AttributeToSqlOptions` and `EscapeOptions` share no properties, so mssql and snowflake were handing `escape` an object it could never read, several `toSql({ dialect })` calls passed an argument no implementation accepts, and db2 read a `replacements` option that no caller has ever passed. Co-Authored-By: Claude Opus 5 <[email protected]>
Pull Request Checklist
Description Of Change
Just like #15526 this PR is smaller than the others. I just want to get rid of the dialect specific QueryGenerator unit tests and doing it properly just gets me in a too big of a rabbit hole. Future PRs should migrate
attributesToSQLandattributeToSQLand overhaul the test suite.