Skip to content

Commit f15923d

Browse files
Fix view creation in tests following SQLAlchemy change
Use updated example from https://github.com/sqlalchemy/sqlalchemy/wiki/Views for SQLA 2.0.38
1 parent 87af04a commit f15923d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

cardinal_pythonlib/sqlalchemy/tests/schema_tests.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,14 @@ def _attach_view(
307307
of "selectable") is created after the table is created, and dropped before
308308
the table is dropped, via listeners.
309309
"""
310-
t = table(tablename)
311-
312-
# noinspection PyProtectedMember
313-
t._columns._populate_separate_keys(
314-
col._make_proxy(t) for col in selectable.selected_columns
310+
t = table(
311+
tablename,
312+
*(
313+
Column(c.name, c.type, primary_key=c.primary_key)
314+
for c in selectable.selected_columns
315+
),
315316
)
317+
t.primary_key.update(c for c in t.c if c.primary_key)
316318

317319
event.listen(
318320
metadata,

0 commit comments

Comments
 (0)