mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2024-11-13 04:46:33 +03:00
Allow assignment of NO_VALUE to fields
This commit is contained in:
parent
56cf86a246
commit
f0bef7f75d
|
@ -170,7 +170,7 @@ class Model(metaclass=ModelBase):
|
||||||
This may raise a `ValueError`.
|
This may raise a `ValueError`.
|
||||||
'''
|
'''
|
||||||
field = self.get_field(name)
|
field = self.get_field(name)
|
||||||
if field:
|
if field and (value != NO_VALUE):
|
||||||
try:
|
try:
|
||||||
value = field.to_python(value, pytz.utc)
|
value = field.to_python(value, pytz.utc)
|
||||||
field.validate(value)
|
field.validate(value)
|
||||||
|
|
|
@ -60,6 +60,10 @@ class AliasFieldsTest(unittest.TestCase):
|
||||||
def test_default_value(self):
|
def test_default_value(self):
|
||||||
instance = ModelWithAliasFields()
|
instance = ModelWithAliasFields()
|
||||||
self.assertEqual(instance.alias_str, NO_VALUE)
|
self.assertEqual(instance.alias_str, NO_VALUE)
|
||||||
|
# Check that NO_VALUE can be assigned to a field
|
||||||
|
instance.str_field = NO_VALUE
|
||||||
|
# Check that NO_VALUE can be assigned when creating a new instance
|
||||||
|
instance2 = ModelWithAliasFields(**instance.to_dict())
|
||||||
|
|
||||||
|
|
||||||
class ModelWithAliasFields(Model):
|
class ModelWithAliasFields(Model):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user