Skip to content

Commit bca0cee

Browse files
author
Richard O'Dwyer
committed
Support ordering on column objects
1 parent 19d64f5 commit bca0cee

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

cassandra/cqlengine/columns.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,36 @@ def __init__(self,
168168
self.position = Column.instance_counter
169169
Column.instance_counter += 1
170170

171+
def __ne__(self, other):
172+
if isinstance(other, Column):
173+
return self.position != other.position
174+
return NotImplemented
175+
176+
def __eq__(self, other):
177+
if isinstance(other, Column):
178+
return self.position == other.position
179+
return NotImplemented
180+
181+
def __lt__(self, other):
182+
if isinstance(other, Column):
183+
return self.position < other.position
184+
return NotImplemented
185+
186+
def __le__(self, other):
187+
if isinstance(other, Column):
188+
return self.position <= other.position
189+
return NotImplemented
190+
191+
def __gt__(self, other):
192+
if isinstance(other, Column):
193+
return self.position > other.position
194+
return NotImplemented
195+
196+
def __ge__(self, other):
197+
if isinstance(other, Column):
198+
return self.position >= other.position
199+
return NotImplemented
200+
171201
def validate(self, value):
172202
"""
173203
Returns a cleaned and validated value. Raises a ValidationError

0 commit comments

Comments
 (0)