Skip to content

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

Closed
locene wants to merge 1 commit into
spinlud:masterfrom
locene:master
Closed

locene wants to merge 1 commit into
spinlud:masterfrom
locene:master

Conversation

@locene

@locene locene commented Jun 4, 2025

Copy link
Copy Markdown

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.

@spinlud

spinlud commented Sep 11, 2026

Copy link
Copy Markdown
Owner

Superseded by #90, which includes MariaDB json_valid(...) CHECK-constraint detection (via information_schema.CHECK_CONSTRAINTS, with a SHOW CREATE TABLE fallback for MariaDB < 10.5) as part of a cross-dialect JSON-typing overhaul. Shipped in v13.1.0 via #92. Closing in favour of #90 — thanks for the original work here.

@spinlud spinlud closed this Sep 11, 2026
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.

2 participants