diff --git a/pymilvus/client/abstract.py b/pymilvus/client/abstract.py index c200841c1..d0705ef3d 100644 --- a/pymilvus/client/abstract.py +++ b/pymilvus/client/abstract.py @@ -37,9 +37,9 @@ def __pack(self, raw: Any): self.is_primary = raw.is_primary_key self.description = raw.description self.auto_id = raw.autoID - self.type = raw.data_type + self.type = DataType(raw.data_type) self.is_partition_key = raw.is_partition_key - self.element_type = raw.element_type + self.element_type = DataType(raw.element_type) try: self.is_dynamic = raw.is_dynamic except Exception: @@ -82,9 +82,11 @@ def dict(self): "description": self.description, "type": self.type, "params": self.params or {}, - "element_type": self.element_type, } + if self.element_type: + _dict["element_type"] = self.element_type + if self.is_partition_key: _dict["is_partition_key"] = True if self.is_dynamic: diff --git a/pymilvus/orm/schema.py b/pymilvus/orm/schema.py index db5b9b1bf..f18e2144d 100644 --- a/pymilvus/orm/schema.py +++ b/pymilvus/orm/schema.py @@ -229,14 +229,12 @@ def enable_dynamic_field(self, value: bool): self._enable_dynamic_field = bool(value) def to_dict(self): - _dict = { + return { "auto_id": self.auto_id, "description": self._description, "fields": [s.to_dict() for s in self._fields], + "enable_dynamic_field": self.enable_dynamic_field, } - if self._enable_dynamic_field: - _dict["enable_dynamic_field"] = self._enable_dynamic_field - return _dict def verify(self): # final check, detect obvious problems