Skip to content

Commit c2a0294

Browse files
committed
Make StructType hashable
1 parent 19ccbc5 commit c2a0294

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ydb_sqlalchemy/sqlalchemy/types.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,16 @@ class ListType(ARRAY):
4343
__visit_name__ = "list_type"
4444

4545

46+
class HashableDict(dict):
47+
def __hash__(self):
48+
return hash(tuple(self.items()))
49+
50+
4651
class StructType(types.TypeEngine[Mapping[str, Any]]):
4752
__visit_name__ = "struct_type"
4853

4954
def __init__(self, fields_types: Mapping[str, Union[Type[types.TypeEngine], Type[types.TypeDecorator]]]):
50-
self.fields_types = fields_types
55+
self.fields_types = HashableDict(dict(sorted(fields_types.items())))
5156

5257
@property
5358
def python_type(self):

0 commit comments

Comments
 (0)