sequelize-typescript-generator icon indicating copy to clipboard operation
sequelize-typescript-generator copied to clipboard

MySQL JSON strings

Open samdaw13 opened this issue 2 years ago • 0 comments

Hello,

I am running into an issue where MySQL needs to store JSON objects as strings. See https://dev.mysql.com/doc/refman/8.0/en/json.html#:~:text=In%20MySQL%2C%20JSON,following%20examples%20demonstrate for more details.

However the sequelize-typescript-generator is typing the database JSON columns as object, which is throwing typing errors when trying to insert, as the insert must be a string, but TypeScript expects an object.

Our implementation is using a programatic script to generate the types. I can literally fix the issue by changing the build/dialects/DialectMySQL.ts jsDataTypesMap.json to 'string'. But that isn't a valid solution.

Is there a way to change the outputted json type from object to string?

samdaw13 avatar Aug 09 '23 23:08 samdaw13