Skip to content

Commit 014bb5e

Browse files
committed
Deterministic ordering in schema manager results
1 parent 5dc61db commit 014bb5e

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
@@ -604,6 +604,8 @@ protected function selectTableNames(string $databaseName): Result
604604
AND table_name != 'geometry_columns'
605605
AND table_name != 'spatial_ref_sys'
606606
AND table_type = 'BASE TABLE'
607+
ORDER BY
608+
quote_ident(table_name)
607609
SQL;
608610

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

697-
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ')';
699+
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ') ORDER BY quote_ident(ic.relname)';
698700

699701
return $this->_conn->executeQuery($sql);
700702
}
@@ -721,7 +723,7 @@ protected function selectForeignKeyColumns(string $databaseName, ?string $tableN
721723

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

724-
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ") AND r.contype = 'f'";
726+
$sql .= ' WHERE ' . implode(' AND ', $conditions) . ") AND r.contype = 'f' ORDER BY quote_ident(r.conname)";
725727

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

0 commit comments

Comments
 (0)