excluding order and limit from count queries
This commit is contained in:
@@ -138,10 +138,10 @@ class SelectStatement(BaseCQLStatement):
|
||||
if self.where_clauses:
|
||||
qs += [self._where]
|
||||
|
||||
if self.order_by:
|
||||
if self.order_by and not self.count:
|
||||
qs += ['ORDER BY {}'.format(', '.join(unicode(o) for o in self.order_by))]
|
||||
|
||||
if self.limit:
|
||||
if self.limit and not self.count:
|
||||
qs += ['LIMIT {}'.format(self.limit)]
|
||||
|
||||
if self.allow_filtering:
|
||||
|
||||
@@ -33,9 +33,11 @@ class SelectStatementTests(TestCase):
|
||||
self.assertEqual(unicode(ss), 'SELECT * FROM table WHERE "a" = :0', unicode(ss))
|
||||
|
||||
def test_count(self):
|
||||
ss = SelectStatement('table', count=True)
|
||||
ss = SelectStatement('table', count=True, limit=10, order_by='d')
|
||||
ss.add_where_clause(WhereClause('a', EqualsOperator(), 'b'))
|
||||
self.assertEqual(unicode(ss), 'SELECT COUNT(*) FROM table WHERE "a" = :0', unicode(ss))
|
||||
self.assertNotIn('LIMIT', unicode(ss))
|
||||
self.assertNotIn('ORDER', unicode(ss))
|
||||
|
||||
def test_context(self):
|
||||
ss = SelectStatement('table')
|
||||
|
||||
Reference in New Issue
Block a user