Repository navigation
feat: rewrite Data Types - #14505
feat: rewrite Data Types#14505
Conversation
converts data-types to TS
* meta: update unit tests from #14505 * meta: update typing tests * meta: update integration tests from #14505 * meta: fix ibmi/db2 unit test * meta: fix failing integration tests * meta: undo integration/utils changes * meta: undo index order * meta: remove incorrect mention of bigint * meta: fix index order test
WikiRik
left a comment
There was a problem hiding this comment.
Okay, I've gone through all tests and most of the implementation as well and I think that once I resolve all my comments we should be good to merge. Like you mentioned before there are indeed still a lot of TODOs but let's not make this PR even larger.
Also; I hope that we won't have any PRs of this size again soon
I can't agree more. This was one hell of a PR. Thankfully even files like |
|
All 3 are done. All that remains is sorting out the failing integration tests (dialects trying to use the "timezone" option but it's unsupported) |
WikiRik
left a comment
There was a problem hiding this comment.
If the tests agree I think we should be good to go! 🚀

PR Description
This PR migrates DataTypes to TypeScript.
It continues the work that was started in the previous DataType PRs by @allawesome497
Closes #14240 - @allawesome497's refactor
Closes #14239 - @allawesome497's refactor
Closes #14238 - @allawesome497's refactor
Closes #14220 - @allawesome497's refactor
Closes #14081 - @allawesome497's refactor
Closes #13981 - @allawesome497's refactor
Closes #13970 - @allawesome497's refactor
Closes #13799 - @allawesome497's refactor
Closes #12941 - initial refactor
Closes #14438
Closes #9786
Closes #8356
Closes #8963
Closes #13065
Closes #11828
Closes #11550
Closes #11266
Closes #11177
Closes #10946
Closes #10493
Closes #10383
Closes #8702
Closes #7930
Closes #10982
I'm doing the whole migration in one PR.
Notable Changes
.validateon all of its DataTypes instead of just a single hardcoded one for strings.DataTypes.postgres.JSONdirectly.DataTypesare now fully responsible for properly escaping values that are injected in queries. This has been done because:SQLString.escapedelegates to DataTypes now. DataTypes are the one true source of truth for serialization.AcceptedType. This was done because the previous 3 types added a lot of complexity with little to no benefit over just usingunknown. Especially because we can't guarantee what we will be receiving from connectors. It's better to useunknownand be defensive when treating the input.escapekey altogether. All DataTypes must properly escape their values themselves. No magic.JSONTYPE. It was just an alias forJSON, and should not be used.NUMERIC, it was an alias forDECIMALDOUBLE PRECISION, it was an alias forDOUBLEDataTypes.ENUMis able to generate its SQL type name.DataTypes.TIMEDataTypes.REAL.DataTypes.FLOATis always single-precision floating point.DataTypes.DOUBLEis always double-precision floating point. FLOAT & REAL are redundant, but we did not normalize so users needed all 3:JSONsupport to all dialects. Basic means that the JSON value will be serialized/deserialized into a text column. No query support.DataTypes.DATEin mssql & postgresMerge Squash Commit Message Body (for breaking changes)
Don't forget the empty line at the start of the body
Some explanations for above breaking change
valuesoutside ofENUM. i.e. the following is no longer possible:Dateobject if no JS DataType is specified.DataTypes.DATE,DataTypes.DATETIME.ZONEDwould both map to the Postgres DataTypetimestamptz. We do a minimal amount of parsing based on the DB type, and if a JS DataType is specified, do extra parsing (such as converting to a Date object forDataTypes.DATE, and a temporal object forDataTypes.DATETIME.ZONED)DataTypes.DECIMALhas very different meaning from one dialect to the other. In MySQL, it's defaulted toDataTypes.DECIMAL(10, 0)(meaning a 10 digit number, with no decimal part). In postgres, it means "unconstrained". There are no way to have an unconstrained decimal any other way, soDataTypes.DECIMALis now interpreted as "unconstrained", and dialects that do not support unconstrained decimals now throw when no parameter is specified. This will require updating https://sequelize.org/docs/v7/other-topics/other-data-types/#exact-decimal-numbersTODO
ibmiimpossible to know, no DB availablesnowflakeimpossible to know, no DB availableThings to extract to other PRs
To reduce the weight of this one
_dialect->dialectinQueryGeneratorconstructors meta: refactor _dialect to dialect in queryGenerator #15069classToInvokableto its own filelogQuerystringifies its parametersUtils.now()&Utils.toDefaultValue()accept a dialect instead of a dialect name meta: makeUtils.now()andUtils.toDefaultValue()accept a dialect #15072An error occured while normalizing attribute ${this.name}#${name}).Blocking PRs
Follow Up Tasks