Skip to content

Fixing the incorrect JSON type column definition for the MariaDB dialect #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

locene
Copy link

@locene locene commented Jun 4, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant