Skip to content
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

Avoid ambigous TABLE_NAME in query #6275

Merged
merged 6 commits into from
Feb 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Platforms/MariaDb1043Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,19 @@ public function getColumnTypeSQLSnippet(string $tableAlias = 'c', ?string $datab
);
}

$subQueryAlias = 'i_' . $tableAlias;

$databaseName = $this->getDatabaseNameSQL($databaseName);

// The check for `CONSTRAINT_SCHEMA = $databaseName` is mandatory here to prevent performance issues
return <<<SQL
IF(
$tableAlias.COLUMN_TYPE = 'longtext'
AND EXISTS(
SELECT * from information_schema.CHECK_CONSTRAINTS
WHERE CONSTRAINT_SCHEMA = $databaseName
AND TABLE_NAME = $tableAlias.TABLE_NAME
AND CHECK_CLAUSE = CONCAT(
SELECT * from information_schema.CHECK_CONSTRAINTS $subQueryAlias
WHERE $subQueryAlias.CONSTRAINT_SCHEMA = $databaseName
AND $subQueryAlias.TABLE_NAME = $tableAlias.TABLE_NAME
AND $subQueryAlias.CHECK_CLAUSE = CONCAT(
'json_valid(`',
$tableAlias.COLUMN_NAME,
'`)'
Expand Down