Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newer versions of sqlalchemy do not provide _legacy_setup_joins attribute #89

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions sqlalchemy_filters/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@ def get_query_models(query):
for mapper
in query._compile_state()._join_entities
)
except InvalidRequestError:
except (InvalidRequestError, AttributeError):
# query might not contain columns yet, hence cannot be compiled
# try to infer the models from various internals
for table_tuple in query._setup_joins + query._legacy_setup_joins:
table_tuple_list = query._setup_joins
if hasattr(query, "_legacy_setup_joins"):
table_tuple_list = table_tuple_list + query._legacy_setup_joins
for table_tuple in table_tuple_list:
model_class = get_model_from_table(table_tuple[0])
if model_class:
models.append(model_class)
Expand Down