cqle: support more comparisons in LWT conditional
also fixes an issue where iff did not use the column's db_field PYTHON-528
This commit is contained in:
@@ -60,6 +60,11 @@ class EqualsOperator(BaseWhereOperator):
|
|||||||
cql_symbol = '='
|
cql_symbol = '='
|
||||||
|
|
||||||
|
|
||||||
|
class NotEqualsOperator(BaseWhereOperator):
|
||||||
|
symbol = 'NE'
|
||||||
|
cql_symbol = '!='
|
||||||
|
|
||||||
|
|
||||||
class InOperator(EqualsOperator):
|
class InOperator(EqualsOperator):
|
||||||
symbol = 'IN'
|
symbol = 'IN'
|
||||||
cql_symbol = 'IN'
|
cql_symbol = 'IN'
|
||||||
|
|||||||
@@ -560,10 +560,11 @@ class AbstractQuerySet(object):
|
|||||||
raise QueryException('{0} is not a valid query operator'.format(operator))
|
raise QueryException('{0} is not a valid query operator'.format(operator))
|
||||||
clone._conditional.append(operator)
|
clone._conditional.append(operator)
|
||||||
|
|
||||||
for col_name, val in kwargs.items():
|
for arg, val in kwargs.items():
|
||||||
if isinstance(val, Token):
|
if isinstance(val, Token):
|
||||||
raise QueryException("Token() values are not valid in conditionals")
|
raise QueryException("Token() values are not valid in conditionals")
|
||||||
|
|
||||||
|
col_name, col_op = self._parse_filter_arg(arg)
|
||||||
try:
|
try:
|
||||||
column = self.model._get_column(col_name)
|
column = self.model._get_column(col_name)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -574,7 +575,9 @@ class AbstractQuerySet(object):
|
|||||||
else:
|
else:
|
||||||
query_val = column.to_database(val)
|
query_val = column.to_database(val)
|
||||||
|
|
||||||
clone._conditional.append(ConditionalClause(col_name, query_val))
|
operator_class = BaseWhereOperator.get_operator(col_op or 'EQ')
|
||||||
|
operator = operator_class()
|
||||||
|
clone._conditional.append(WhereClause(column.db_field_name, operator, query_val))
|
||||||
|
|
||||||
return clone
|
return clone
|
||||||
|
|
||||||
|
|||||||
@@ -527,8 +527,6 @@ class BaseCQLStatement(UnicodeMixin):
|
|||||||
:param clause: The clause that will be added to the iff statement
|
:param clause: The clause that will be added to the iff statement
|
||||||
:type clause: ConditionalClause
|
:type clause: ConditionalClause
|
||||||
"""
|
"""
|
||||||
if not isinstance(clause, ConditionalClause):
|
|
||||||
raise StatementException('only instances of AssignmentClause can be added to statements')
|
|
||||||
clause.set_context_id(self.context_counter)
|
clause.set_context_id(self.context_counter)
|
||||||
self.context_counter += clause.get_context_size()
|
self.context_counter += clause.get_context_size()
|
||||||
self.conditionals.append(clause)
|
self.conditionals.append(clause)
|
||||||
|
|||||||
Reference in New Issue
Block a user