Skip to content

Commit

Permalink
Fix getting columns when sql mode is using ansi_quotes (#669)
Browse files Browse the repository at this point in the history
Co-authored-by: Markus Staab <maggus.staab@googlemail.com>
  • Loading branch information
lode and staabm committed Aug 3, 2024
1 parent 8d845bf commit 4962951
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/DbSchema/SchemaHasherMysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function hashDb(): string
$maxConcatQuery = 'SET SESSION group_concat_max_len = 1000000';
$this->connection->query($maxConcatQuery);

$query = '
$query = "
SELECT
MD5(
GROUP_CONCAT(
Expand All @@ -50,8 +50,8 @@ public function hashDb(): string
FROM (
SELECT
CONCAT(
COALESCE(COLUMN_NAME, ""),
COALESCE(EXTRA, ""),
COALESCE(COLUMN_NAME, ''),
COALESCE(EXTRA, ''),
COLUMN_TYPE,
IS_NULLABLE
) as columns
Expand All @@ -62,7 +62,7 @@ public function hashDb(): string
ORDER BY table_name, column_name
) as InnerSelect
GROUP BY
grouper';
grouper";

$hash = '';
if ($this->connection instanceof PDO) {
Expand Down
8 changes: 4 additions & 4 deletions src/QueryReflection/PdoMysqlQueryReflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ protected function checkInformationSchema(string $tableName): Iterator
if (null === $this->stmt) {
$this->stmt = $this->pdo->prepare(
// EXTRA, COLUMN_NAME seems to be nullable in mariadb
'SELECT
coalesce(COLUMN_NAME, "") as COLUMN_NAME,
coalesce(EXTRA, "") as EXTRA,
"SELECT
coalesce(COLUMN_NAME, '') as COLUMN_NAME,
coalesce(EXTRA, '') as EXTRA,
COLUMN_TYPE
FROM information_schema.columns
WHERE table_name = ? AND table_schema = DATABASE()'
WHERE table_name = ? AND table_schema = DATABASE()"
);
}

Expand Down

0 comments on commit 4962951

Please sign in to comment.