cinder.db.utils module

class Case(whens, value=None, else_=None)

Bases: object

Class for conditional value selection for conditional_update.

class Condition(value, field=None)

Bases: object

Class for normal condition values for conditional_update.

get_filter(model, field=None)
class Not(value, field=None, auto_none=True)

Bases: Condition

Class for negated condition values for conditional_update.

By default NULL values will be treated like Python treats None instead of how SQL treats it.

So for example when values are (1, 2) it will evaluate to True when we have value 3 or NULL, instead of only with 3 like SQL does.

get_filter(model, field=None)
condition_db_filter(model, field, value)

Create matching filter.

If value is an iterable other than a string, any of the values is a valid match (OR), so we’ll use SQL IN operator.

If it’s not an iterator == operator will be used.

condition_not_db_filter(model, field, value, auto_none=True)

Create non matching filter.

If value is an iterable other than a string, any of the values is a valid match (OR), so we’ll use SQL IN operator.

If it’s not an iterator == operator will be used.

If auto_none is True then we’ll consider NULL values as different as well, like we do in Python and not like SQL does.