Fixing the incorrect JSON type column definition for the MariaDB dialect #60
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.
When generating MariaDB models with this project, JSON type columns are incorrectly defined as
string
instead ofobject
, 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 anobject
; otherwise, it defaults to astring
.