Skip to content

Commit

Permalink
Merge pull request #54 from davidcim/master
Browse files Browse the repository at this point in the history
Makes FilterSet.aliased method compatible with SQLAlchemy 1.4
  • Loading branch information
art1415926535 authored May 16, 2021
2 parents 7baa457 + 73541e7 commit 6b59c1f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions graphene_sqlalchemy_filter/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,18 @@ def _aliases_from_query(cls, query: Query) -> 'Dict[str, _MapperEntity]':
Dictionary of model aliases.
"""
aliases = {
(mapper._target, mapper.name): mapper.entity
for mapper in query._join_entities
}

join_entities = getattr(query, '_join_entities', None)
if join_entities:
aliases = {
(mapper._target, mapper.name): mapper.entity
for mapper in join_entities
}
else:
aliases = {
(join_entity._target, join_entity.name): join_entity.entity
for join_entity in query._compile_state()._join_entities
}

return aliases

Expand Down

0 comments on commit 6b59c1f

Please sign in to comment.