sequelize-typescript-generator
sequelize-typescript-generator copied to clipboard
Fixing the incorrect JSON type column definition for the MariaDB dialect
When generating MariaDB models with this project, JSON type columns are incorrectly defined as string instead of object, which prevents the models from taking full advantage of the correct data type and its associated benefits.
Given that the JSON type in MariaDB is essentially an alias for LONGTEXT, the key differentiator is the inclusion of the JSON_VALID CHECK constraint (reference: https://mariadb.com/kb/en/json/). To address this, I modified the DialectMariaDB.ts file to inspect LONGTEXT columns for the presence of a valid JSON_VALID constraint. If a constraint is found, the column is output as an object; otherwise, it defaults to a string.