Skip to content

Commit

Permalink
fix: Q.resolve compatibility problem
Browse files Browse the repository at this point in the history
  • Loading branch information
NightMarcher committed Nov 21, 2022
1 parent ceb4c3b commit 49739b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cryptography = "*"
faker = "*"
fastapi = "*"
uvicorn = "*"
tortoise-orm = "*"

[requires]
python_version = "3.7"
2 changes: 1 addition & 1 deletion fastapi_esql/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
timing,
)

__version__ = "0.0.5"
__version__ = "0.0.6"

__all__ = [
"QsParsingError",
Expand Down
9 changes: 7 additions & 2 deletions fastapi_esql/utils/sqlizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from json import dumps
from typing import Any, Dict, List, Optional, Union

from tortoise import Model
from tortoise import Model, __version__
from tortoise.queryset import Q
from tortoise.query_utils import QueryModifier

Expand Down Expand Up @@ -68,7 +68,12 @@ def resolve_wheres(

modifier = QueryModifier()
for q in qs:
modifier &= q.resolve(model, model._meta.basetable)
# NOTE method `Q.resolve` changed since V0.18.0
# https://github.com/tortoise/tortoise-orm/commit/37178e175bc12bc4767b93142dab0209f9240c55
if __version__ >= "0.18.0":
modifier &= q.resolve(model, model._meta.basetable)
else:
modifier &= q.resolve(model, {}, {}, model._meta.basetable)
return modifier.where_criterion.get_sql(quote_char="`")

@classmethod
Expand Down

0 comments on commit 49739b8

Please sign in to comment.