(Data): Small extensions to core data interfaces.

Add `LEQ` condition type.
Ensure that batch updates don't fire with nothing to update.
Add `cast_row` to `update_many` for handling typed `NULL`s.
This commit is contained in:
2021-09-19 09:54:08 +03:00
parent fa2435e93a
commit 4229fe8b18
3 changed files with 20 additions and 3 deletions

View File

@@ -45,6 +45,21 @@ class GEQ(Condition):
values.append(item)
class LEQ(Condition):
__slots__ = ('value',)
def __init__(self, value):
self.value = value
def apply(self, key, values, conditions):
item = self.value
if isinstance(item, (list, tuple)):
raise ValueError("Cannot apply LEQ condition to a list!")
else:
conditions.append("{} <= {}".format(key, _replace_char))
values.append(item)
class Constant(Condition):
__slots__ = ('value',)