Skip to content

Commit

Permalink
patched SmaryQuery._get_root_cls
Browse files Browse the repository at this point in the history
  • Loading branch information
aurthurm committed Jan 28, 2024
1 parent 285a530 commit 6da12c5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sqlalchemy_mixins/activerecordasync.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
from .activerecord import ModelNotFoundError
from . import smartquery as SmaryQuery


get_root_cls = SmaryQuery._get_root_cls
def async_root_cls(query):
"""Monkey patch SmaryQuery to handle async queries."""
try:
return SmaryQuery._get_root_cls(query)
return get_root_cls(query)
except ValueError:
# Handle async queries
if query.__dict__["_propagate_attrs"]["plugin_subject"].class_:
return query.__dict__["_propagate_attrs"]["plugin_subject"].class_
raise

SmaryQuery._get_root_cls = lambda query: async_root_cls(query)


Expand Down

0 comments on commit 6da12c5

Please sign in to comment.