Skip to content

Commit 1835531

Browse files
build(deps): bump sqlalchemy from 2.0.18 to 2.0.19 (#752)
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Sam Bull <[email protected]>
1 parent 74fa464 commit 1835531

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

aiohttp_admin/backends/sqlalchemy.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,12 @@ def __init__(self, db: AsyncEngine, model_or_table: Union[sa.Table, type[Declara
197197
mapper = sa.inspect(model_or_table)
198198
assert mapper is not None # noqa: S101
199199
for name, relationship in mapper.relationships.items():
200+
# https://github.com/sqlalchemy/sqlalchemy/discussions/10161#discussioncomment-6583442
201+
assert relationship.local_remote_pairs # noqa: S101
200202
if len(relationship.local_remote_pairs) > 1:
201203
raise NotImplementedError("Composite foreign keys not supported yet.")
204+
if not isinstance(relationship.entity.persist_selectable, sa.Table):
205+
continue
202206
local, remote = relationship.local_remote_pairs[0]
203207

204208
props = {"reference": relationship.entity.persist_selectable.name,
@@ -214,11 +218,11 @@ def __init__(self, db: AsyncEngine, model_or_table: Union[sa.Table, type[Declara
214218
props["link"] = "show"
215219

216220
children = {}
217-
for c in relationship.target.c.values():
218-
if c is remote: # Skip the foreign key
221+
for kc in relationship.target.c.values():
222+
if kc is remote: # Skip the foreign key
219223
continue
220-
field, inp, c_props = get_components(c.type)
221-
children[c.name] = {"type": field, "props": c_props}
224+
field, inp, c_props = get_components(kc.type)
225+
children[kc.name] = {"type": field, "props": c_props}
222226
container = "Datagrid" if t == "ReferenceManyField" else "DatagridSingle"
223227
props["children"] = {"_": {"type": container, "props": {
224228
"children": children, "rowClick": "show"}}}

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ pydantic==1.10.9
88
pytest==7.4.0
99
pytest-aiohttp==1.0.4
1010
pytest-cov==4.1.0
11-
sqlalchemy==2.0.18
11+
sqlalchemy==2.0.19
1212
typing_extensions>=3.10; python_version<"3.10"

0 commit comments

Comments
 (0)