Skip to content

Commit 4ff679d

Browse files
authored
Merge pull request #6984 from mbeccati/fix-pgsql-non-deterministic
Deterministic ordering in schema manager results
2 parents ebdc51c + 014bb5e commit 4ff679d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Schema/PostgreSQLSchemaManager.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,8 @@ protected function selectTableNames(string $databaseName): Result
609609
AND table_name != 'geometry_columns'
610610
AND table_name != 'spatial_ref_sys'
611611
AND table_type = 'BASE TABLE'
612+
ORDER BY
613+
quote_ident(table_name)
612614
SQL;
613615

614616
return $this->_conn->executeQuery($sql, [$databaseName]);
@@ -695,7 +697,7 @@ protected function selectIndexColumns(string $databaseName, ?string $tableName =
695697
'c.relnamespace = n.oid',
696698
], $this->buildQueryConditions($tableName));
697699

698-
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ')';
700+
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ') ORDER BY quote_ident(ic.relname)';
699701

700702
return $this->_conn->executeQuery($sql);
701703
}
@@ -722,7 +724,7 @@ protected function selectForeignKeyColumns(string $databaseName, ?string $tableN
722724

723725
$conditions = array_merge(['n.oid = c.relnamespace'], $this->buildQueryConditions($tableName));
724726

725-
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ") AND r.contype = 'f'";
727+
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ") AND r.contype = 'f' ORDER BY quote_ident(r.conname)";
726728

727729
return $this->_conn->executeQuery($sql);
728730
}

0 commit comments

Comments
 (0)