[MySQL-kit] Fix CHECK constraint column case mismatch causing MariaDB push failure#5566
Open
karthik-idikuda wants to merge 1 commit intodrizzle-team:mainfrom
Open
Conversation
… fix MariaDB compatibility On MariaDB, the mysql2 driver returns result column keys matching the case used in the SQL query. The CHECK constraints introspection query selected lowercase column names (table_name, constraint_name, check_clause) but the result mapping reads uppercase keys (TABLE_NAME, CONSTRAINT_NAME, CHECK_CLAUSE). This mismatch causes undefined values on MariaDB, leading to a runtime crash during `drizzle-kit push`. Fix: - Add explicit AS aliases to the SELECT columns so they always return uppercase keys regardless of the database engine. - Uncomment the tableInResult guard to safely skip CHECK constraints for tables not in the result set (e.g., filtered tables). Fixes drizzle-team#5550
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
drizzle-kit pushexits with code 1 on MariaDB databases containing CHECK constraints. The issue occurs during schema introspection ("Pulling schema from database...").Root Cause
The CHECK constraints introspection query selects columns with lowercase names:
But the result mapping reads uppercase keys:
On MySQL,
information_schemareturns uppercase column names regardless of the query, so this works. On MariaDB (withmysql2driver), result keys match the case used in the SQL query - returning lowercase keys. This mismatch producesundefinedvalues, which crash when accessingtableInResult.checkConstraint.Fix
ASaliases to the SELECT columns so they always return uppercase keys regardless of the database engine:tableInResultguard (was commented out) to safely skip CHECK constraints for tables not in the result set (e.g., filtered tables), preventing potential runtime crashes.Reproduction
npx drizzle-kit pushFixes #5550