You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug:
When I use limit & select_related together in QuerySet;
if I do not set limit_raw_sql to True, I get an Error.
And if I do;
The limit does not apply to the number of rows in the parent model.
To Reproduce:
# ModelsclassUser(PrimaryKeyMixin, ormar.Model):
"""User Model Class to Implement Method for Operations of User Entity"""mobile: str=ormar.String(unique=True, index=True, max_length=10, pattern=MOBILE_PATTERN)
password: str=ormar.String(max_length=128)
level: str=ormar.String(max_length=1, choices=list(Level), default=Level.STAFF.value)
email: Optional[EmailStr] =ormar.String(max_length=255, nullable=True, default=None)
avatar: Optional[str] =ormar.String(max_length=255, nullable=True, default=None)
fullname: Optional[str] =ormar.String(max_length=64, nullable=True, default=None)
is_active: bool=ormar.Boolean(index=True, nullable=False, default=True)
classMeta(MainMeta):
orders_by= ["-is_active", "-level"]
classTask(PrimaryKeyMixin, ormar.Model):
"""Task Model Class to Implement Method for Operations of Task Entity"""name: str=ormar.String(max_length=64, nullalbe=False)
description: Optional[str] =ormar.Text(nullable=True, default=None)
start_date: Optional[date] =ormar.Date(nullable=True, default=None)
end_date: Optional[date] =ormar.Date(nullable=True, default=None)
is_halted: bool=ormar.Boolean(index=True, nullable=False, default=True)
user: User=ormar.ForeignKey(to=User)
classMeta(MainMeta):
orders_by= ["-end_date", "-start_date"]
constraints= [
ormar.UniqueColumns("user", "name"),
]
# QuerySet# (I have two users, each with two tasks)>>>awaitUser.objects.limit(2, limit_raw_sql=True).select_related(User.tasks).all()
>>>awaitUser.objects.select_related(User.tasks).limit(2, limit_raw_sql=True).all()
[User({'id': UUID('0bc2ec3f-5756-4cd0-ae4a-bbe7b53aad23'), 'mobile': '9928917653', 'password': '$argon2id$v=19$m=65536,t=3,p=4$wNh7z7mXcu49x9j7P8eYUw$s1q1w/ZXKnO1tx4k6eqWgf22z/wYVlRDEntdWkVkiH4', 'level': '1', 'email': None, 'avatar': None, 'fullname': None, 'is_active': True, 'member': [], 'teamuser': None, 'tasks': [Task({'id': UUID('31a4be3d-055d-400d-b3b6-0b3b4379cdc2'), 'name': 'first', 'description': None, 'start_date': None, 'end_date': None, 'is_halted': True, 'user': <weakproxyat0x0000022667234A40toUserat0x0000022668178580>}), Task({'id': UUID('0922c607-6eaf-4ff6-8aa8-0766f49bc7b9'), 'name': 'two', 'description': None, 'start_date': None, 'end_date': None, 'is_halted': True, 'user': <weakproxyat0x0000022667234A40toUserat0x0000022668178580>})]})]
>>>awaitUser.objects.limit(2).select_related(User.tasks).all()
>>>awaitUser.objects.select_related(User.tasks).limit(2).all()
File~/Desktop/MyProject/venv/Lib/site-packages/asyncpg/protocol/protocol.pyx:168, inprepare()
UndefinedFunctionError: functionmax(boolean) doesnotexistHINT: Nofunctionmatchesthegivennameandargumenttypes. Youmightneedtoaddexplicittypecasts.
Versions:
Database backend: PostgreSQL
Python version: 3.10.1
ormar version: 0.11.1
pydantic version: 1.9.0
The text was updated successfully, but these errors were encountered:
* fix schema with enum fields - issue #699
* fix drivers dependencies - make them optional
* fix command
* provide extras
* add bolean field to related model
* add test with select related and boolean
* new test case based on issue
* fix bool issue in postgres limit queries - issue #704
* fix coverage
* bump version and add release info
Describe the bug:
When I use
limit
&select_related
together in QuerySet;if I do not set
limit_raw_sql
toTrue
, I get an Error.And if I do;
The limit does not apply to the number of rows in the parent model.
To Reproduce:
Versions:
ormar
version: 0.11.1pydantic
version: 1.9.0The text was updated successfully, but these errors were encountered: