I needed to query for incidents in state 6, 7, or 8 as well as those not in state 6, 7, or 8. I did not see an obvious way to do this. I was able to add the following functions to the Numeric() class in the numeric.py module to get what I needed:
def in_list(self, value):
"""
Example: impact.in_list([3, 4])
All records in which the Impact field has one of the values 3 or 4.
"""
value = ",".join(str(v) for v in value)
return self._condition(NumericOperator.ONEOF, value)
def not_in_list(self, value):
"""
Example: impact.not_in_list([3, 4])
All records in which the Impact field does not have one of the values 3 or 4.
"""
value = ",".join(str(v) for v in value)
return self._condition(NumericOperator.NOT_ONEOF, value)
I needed to query for incidents in state 6, 7, or 8 as well as those not in state 6, 7, or 8. I did not see an obvious way to do this. I was able to add the following functions to the Numeric() class in the numeric.py module to get what I needed:
I used the following in my select() to use it:
Incident.incident_state.not_in_list([6, 7, 8])
Should I have done this a different way?