Skip to content

Commit a9cd978

Browse files
authored
Avoid ambigous TABLE_NAME in query (#6275)
<!-- Fill in the relevant information below to help triage your pull request. --> | Q | A |------------- | ----------- | Type | bug | Fixed issues | #6274 #### Summary The current produced query leads to an ambigous column reference as described in the linked issue.
1 parent f78899c commit a9cd978

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Platforms/MariaDb1043Platform.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,19 @@ public function getColumnTypeSQLSnippet(string $tableAlias = 'c', ?string $datab
9292
);
9393
}
9494

95+
$subQueryAlias = 'i_' . $tableAlias;
96+
9597
$databaseName = $this->getDatabaseNameSQL($databaseName);
9698

9799
// The check for `CONSTRAINT_SCHEMA = $databaseName` is mandatory here to prevent performance issues
98100
return <<<SQL
99101
IF(
100102
$tableAlias.COLUMN_TYPE = 'longtext'
101103
AND EXISTS(
102-
SELECT * from information_schema.CHECK_CONSTRAINTS
103-
WHERE CONSTRAINT_SCHEMA = $databaseName
104-
AND TABLE_NAME = $tableAlias.TABLE_NAME
105-
AND CHECK_CLAUSE = CONCAT(
104+
SELECT * from information_schema.CHECK_CONSTRAINTS $subQueryAlias
105+
WHERE $subQueryAlias.CONSTRAINT_SCHEMA = $databaseName
106+
AND $subQueryAlias.TABLE_NAME = $tableAlias.TABLE_NAME
107+
AND $subQueryAlias.CHECK_CLAUSE = CONCAT(
106108
'json_valid(`',
107109
$tableAlias.COLUMN_NAME,
108110
'`)'

0 commit comments

Comments
 (0)