Fix Limit 0 QuerySet Empty List (#767)

* fix: debug condition check not none limit count

* test: write a test for check zero limit empty list

* fix: debug assert check empty list with is keyword
This commit is contained in:
Sepehr Bazyar
2022-07-29 19:53:10 +04:30
committed by GitHub
parent 8450c90420
commit e923513681
3 changed files with 16 additions and 2 deletions

View File

@ -20,6 +20,8 @@ class LimitQuery:
:return: modified query
:rtype: sqlalchemy.sql.selectable.Select
"""
if self.limit_count:
if self.limit_count is not None:
expr = expr.limit(self.limit_count)
return expr

View File

@ -282,10 +282,10 @@ class QuerySet(Generic[T]):
filter_clauses=self.filter_clauses,
exclude_clauses=self.exclude_clauses,
offset=offset or self.query_offset,
limit_count=limit or self.limit_count,
excludable=self._excludable,
order_bys=order_bys or self.order_bys,
limit_raw_sql=self.limit_sql_raw,
limit_count=limit if limit is not None else self.limit_count,
)
exp = qry.build_select_expression()
# print("\n", exp.compile(compile_kwargs={"literal_binds": True}))