diff --git a/aiida/storage/sqlite_zip/orm.py b/aiida/storage/sqlite_zip/orm.py index 5b7a36182d..211346857d 100644 --- a/aiida/storage/sqlite_zip/orm.py +++ b/aiida/storage/sqlite_zip/orm.py @@ -263,14 +263,15 @@ def _cast_json_type(comparator: JSON.Comparator, value: Any) -> Tuple[ColumnElem if isinstance(value, (list, dict)): return case((type_filter, casted_entity == func.json(json.dumps(value))), else_=False) if isinstance(value, complex): - return case( - (type_filter, casted_entity == func.json(json.dumps({ + return case(( + type_filter, casted_entity + == func.json(json.dumps({ '__complex__': True, 'real': value.real, 'imag': value.imag - }))), - else_=False - ) + })) + ), + else_=False) # to-do not working for dict return case((type_filter, casted_entity == value), else_=False) if operator == '>': diff --git a/tests/orm/nodes/test_node.py b/tests/orm/nodes/test_node.py index 9c4a4da44c..be85c9480d 100644 --- a/tests/orm/nodes/test_node.py +++ b/tests/orm/nodes/test_node.py @@ -474,11 +474,11 @@ def test_attribute_complex(self): self.node.store() # ensure the returned node is a complex number assert self.node.base.attributes.get('a_val') == 1.1 + 2.1j - + def test_extra_complex(self): """Test that the `Node.set_attribute` method supports complex.""" self.node.base.extras.set('a_val', 1.1 + 2.1j) - self.node.store() #Only when stored the complex number is serialized + self.node.store() #Only when stored the complex number is serialized # ensure the returned node is a complex number assert self.node.base.extras.get('a_val') == 1.1 + 2.1j