mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2024-11-25 02:03:46 +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`.
|
||||
'''
|
||||
field = self.get_field(name)
|
||||
if field:
|
||||
if field and (value != NO_VALUE):
|
||||
try:
|
||||
value = field.to_python(value, pytz.utc)
|
||||
field.validate(value)
|
||||
|
|
|
@ -60,6 +60,10 @@ class AliasFieldsTest(unittest.TestCase):
|
|||
def test_default_value(self):
|
||||
instance = ModelWithAliasFields()
|
||||
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):
|
||||
|
|
Loading…
Reference in New Issue
Block a user