mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2025-08-02 19:20:14 +03:00
use Q function support having
This commit is contained in:
parent
274e0103fa
commit
25f76833a3
|
@ -452,12 +452,24 @@ class QuerySet(object):
|
||||||
qs._order_by = field_names
|
qs._order_by = field_names
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
def having(self, having_str):
|
def having(self, *q, **kwargs):
|
||||||
"""
|
"""
|
||||||
Returns a copy of this queryset with the having changed.
|
Returns a copy of this queryset that includes only rows matching the having conditions.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
qs = copy(self)
|
qs = copy(self)
|
||||||
qs._having = having_str
|
|
||||||
|
condition = Q()
|
||||||
|
for arg in q:
|
||||||
|
if isinstance(arg, Q):
|
||||||
|
condition &= arg
|
||||||
|
else:
|
||||||
|
raise TypeError('Invalid argument "%r" to queryset filter' % arg)
|
||||||
|
|
||||||
|
if kwargs:
|
||||||
|
condition &= Q(**kwargs)
|
||||||
|
|
||||||
|
qs._having = condition.to_sql(self._model_cls)
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
def only(self, *field_names):
|
def only(self, *field_names):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user