mirror of
https://github.com/fastapi/sqlmodel.git
synced 2025-08-15 18:28:12 +08:00
♻️ Update expresion.py
, sync from Jinja2 template, implement inherit_cache
to solve errors like: SAWarning: Class SelectOfScalar will not make use of SQL compilation caching
(#422)
This commit is contained in:

committed by
GitHub

parent
f232166db5
commit
b51ebaf658
@ -29,14 +29,14 @@ _TSelect = TypeVar("_TSelect")
|
||||
if sys.version_info.minor >= 7:
|
||||
|
||||
class Select(_Select, Generic[_TSelect]):
|
||||
pass
|
||||
inherit_cache = True
|
||||
|
||||
# This is not comparable to sqlalchemy.sql.selectable.ScalarSelect, that has a different
|
||||
# purpose. This is the same as a normal SQLAlchemy Select class where there's only one
|
||||
# entity, so the result will be converted to a scalar by default. This way writing
|
||||
# for loops on the results will feel natural.
|
||||
class SelectOfScalar(_Select, Generic[_TSelect]):
|
||||
pass
|
||||
inherit_cache = True
|
||||
|
||||
else:
|
||||
from typing import GenericMeta # type: ignore
|
||||
@ -45,10 +45,10 @@ else:
|
||||
pass
|
||||
|
||||
class _Py36Select(_Select, Generic[_TSelect], metaclass=GenericSelectMeta):
|
||||
pass
|
||||
inherit_cache = True
|
||||
|
||||
class _Py36SelectOfScalar(_Select, Generic[_TSelect], metaclass=GenericSelectMeta):
|
||||
pass
|
||||
inherit_cache = True
|
||||
|
||||
# Cast them for editors to work correctly, from several tricks tried, this works
|
||||
# for both VS Code and PyCharm
|
||||
|
Reference in New Issue
Block a user