Skip to content

Commit

Permalink
Dialect: Fix get_pk_constraint to return list instead of set type
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Jan 16, 2024
1 parent 07bba7b commit 2064d6b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/sqlalchemy_cratedb/dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def result_fun(result):
(table_name, schema or self.default_schema_name)
)
pks = result_fun(pk_result)
return {'constrained_columns': pks,
return {'constrained_columns': list(sorted(pks)),
'name': 'PRIMARY KEY'}

@reflection.cache
Expand Down
4 changes: 2 additions & 2 deletions tests/dialect_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_primary_keys_2_3_0(self):
)
self.fake_cursor.fetchall = MagicMock(return_value=[["id"], ["id2"], ["id3"]])

eq_(insp.get_pk_constraint("characters")['constrained_columns'], {"id", "id2", "id3"})
eq_(insp.get_pk_constraint("characters")['constrained_columns'], ["id", "id2", "id3"])
self.fake_cursor.fetchall.assert_called_once_with()
in_("information_schema.key_column_usage", self.executed_statement)
in_("table_catalog = ?", self.executed_statement)
Expand All @@ -103,7 +103,7 @@ def test_primary_keys_3_0_0(self):
)
self.fake_cursor.fetchall = MagicMock(return_value=[["id"], ["id2"], ["id3"]])

eq_(insp.get_pk_constraint("characters")['constrained_columns'], {"id", "id2", "id3"})
eq_(insp.get_pk_constraint("characters")['constrained_columns'], ["id", "id2", "id3"])
self.fake_cursor.fetchall.assert_called_once_with()
in_("information_schema.key_column_usage", self.executed_statement)
in_("table_schema = ?", self.executed_statement)
Expand Down

0 comments on commit 2064d6b

Please sign in to comment.