mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2025-08-03 11:40:20 +03:00
support having
This commit is contained in:
parent
7c90c1e4c3
commit
8959a84fed
|
@ -295,6 +295,7 @@ class QuerySet(object):
|
||||||
self._model_cls = model_cls
|
self._model_cls = model_cls
|
||||||
self._database = database
|
self._database = database
|
||||||
self._order_by = []
|
self._order_by = []
|
||||||
|
self._having = ''
|
||||||
self._where_q = Q()
|
self._where_q = Q()
|
||||||
self._prewhere_q = Q()
|
self._prewhere_q = Q()
|
||||||
self._grouping_fields = []
|
self._grouping_fields = []
|
||||||
|
@ -392,6 +393,9 @@ class QuerySet(object):
|
||||||
if self._grouping_with_totals:
|
if self._grouping_with_totals:
|
||||||
sql += ' WITH TOTALS'
|
sql += ' WITH TOTALS'
|
||||||
|
|
||||||
|
if self._having:
|
||||||
|
sql += '\nhaving ' + self.having_as_sql()
|
||||||
|
|
||||||
if self._order_by:
|
if self._order_by:
|
||||||
sql += '\nORDER BY ' + self.order_by_as_sql()
|
sql += '\nORDER BY ' + self.order_by_as_sql()
|
||||||
|
|
||||||
|
@ -413,6 +417,12 @@ class QuerySet(object):
|
||||||
for field in self._order_by
|
for field in self._order_by
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def having_as_sql(self):
|
||||||
|
"""
|
||||||
|
Returns the contents of the query's `Having` clause as a string.
|
||||||
|
"""
|
||||||
|
return self._having
|
||||||
|
|
||||||
def conditions_as_sql(self, prewhere=False):
|
def conditions_as_sql(self, prewhere=False):
|
||||||
"""
|
"""
|
||||||
Returns the contents of the query's `WHERE` or `PREWHERE` clause as a string.
|
Returns the contents of the query's `WHERE` or `PREWHERE` clause as a string.
|
||||||
|
@ -442,6 +452,14 @@ class QuerySet(object):
|
||||||
qs._order_by = field_names
|
qs._order_by = field_names
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
def having(self, having_str):
|
||||||
|
"""
|
||||||
|
Returns a copy of this queryset with the having changed.
|
||||||
|
"""
|
||||||
|
qs = copy(self)
|
||||||
|
qs._having = having_str
|
||||||
|
return qs
|
||||||
|
|
||||||
def only(self, *field_names):
|
def only(self, *field_names):
|
||||||
"""
|
"""
|
||||||
Returns a copy of this queryset limited to the specified field names.
|
Returns a copy of this queryset limited to the specified field names.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user