mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2024-11-22 17:16:34 +03:00
Add method to check instance types of field and its inner fields
This commit is contained in:
parent
a836031d36
commit
3fa18d32d9
|
@ -79,6 +79,22 @@ class Field(object):
|
||||||
else:
|
else:
|
||||||
return self.db_type
|
return self.db_type
|
||||||
|
|
||||||
|
def isinstance(self, types):
|
||||||
|
"""
|
||||||
|
Checks if the instance if one of the types provided or if any of the inner_field child is one of the types
|
||||||
|
provided, returns True if field or any inner_field is one of ths provided, False otherwise
|
||||||
|
:param types: Iterable of types to check inclusion of instance
|
||||||
|
:return: Boolean
|
||||||
|
"""
|
||||||
|
if isinstance(self, types):
|
||||||
|
return True
|
||||||
|
inner_field = getattr(self, 'inner_field', None)
|
||||||
|
while inner_field:
|
||||||
|
if isinstance(inner_field, types):
|
||||||
|
return True
|
||||||
|
inner_field = getattr(self, 'inner_field', None)
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class StringField(Field):
|
class StringField(Field):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user