Skip to content

Commit 1028919

Browse files
authored
Added an iterator method to the DjangoCassandraQuerySet class. Also added a check in the order_by method of the DjangoCassandraQuerySet class so instead of an exception, a warning is thrown when a the order_by method is called with django expressions instead of str column names. These two changes all me use use django-cassandra-engine with django-elasticsearch-dsl relatively seemlessly. (#137)
1 parent fe7d211 commit 1028919

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

django_cassandra_engine/models/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,9 @@ def order_by(self, *colnames):
750750
conditions = []
751751
for col in colnames:
752752
try:
753+
if hasattr(col, 'resolve_expression'):
754+
warnings.warn('Sorting by Django DB Expressions is not supported')
755+
continue
753756
conditions.append('"{0}" {1}'.format(
754757
*self._get_ordering_condition(col))
755758
)
@@ -790,6 +793,9 @@ def values_list(self, *fields, **kwargs):
790793

791794
def _clone(self):
792795
return copy.deepcopy(self)
796+
797+
def iterator(self, *args, **kwargs):
798+
return super(query.ModelQuerySet, self).all()
793799

794800

795801
class DjangoCassandraModel(

0 commit comments

Comments
 (0)