[rhmessaging-commits] rhmessaging commits: r3906 - mgmt/newdata/rosemary/python/rosemary.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Wed Apr 14 08:33:15 EDT 2010
Author: eallen
Date: 2010-04-14 08:33:15 -0400 (Wed, 14 Apr 2010)
New Revision: 3906
Modified:
mgmt/newdata/rosemary/python/rosemary/sqlquery.py
Log:
Added optional HAVING clause to GROUP BY
Modified: mgmt/newdata/rosemary/python/rosemary/sqlquery.py
===================================================================
--- mgmt/newdata/rosemary/python/rosemary/sqlquery.py 2010-04-13 17:30:22 UTC (rev 3905)
+++ mgmt/newdata/rosemary/python/rosemary/sqlquery.py 2010-04-14 12:33:15 UTC (rev 3906)
@@ -45,7 +45,7 @@
if options:
if options.group_column:
- tokens.append(self.group_by.emit(options.group_column))
+ tokens.append(self.group_by.emit(options.group_column, options.group_having))
if options.sort_column:
tokens.append(self.order_by.emit(options.sort_column,
@@ -74,14 +74,20 @@
return "limit %s offset %i" % (str(limit), offset)
class GroupBy(object):
- def emit(self, column):
+ def emit(self, column, filters):
+ having = ""
+ if filters:
+ f_text = list()
+ f_text.extend([x.emit() for x in filters])
+ having = " having %s" % " and ".join(f_text)
+
column = getattr(column, "identifier", column)
+ return "group by %s%s" % (column, having)
- return "group by %s" % column
-
class SqlQueryOptions(object):
def __init__(self):
self.group_column = None
+ self.group_having = list()
self.sort_column = None
self.sort_ascending = True
self.limit = None
@@ -94,7 +100,7 @@
assert table
assert this
assert that
-
+
self.query = query
self.table = getattr(table, "identifier", table)
self.this = getattr(this, "identifier", this)
More information about the rhmessaging-commits
mailing list