Skip to content

Commit 6817180

Browse files
authored
Merge pull request #51 Enable compilation query cache from LuckySting/feat/compilation-cache
Thanks for the PR :)
2 parents 8149b96 + c6fce1c commit 6817180

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

ydb_sqlalchemy/sqlalchemy/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ class YqlDialect(StrCompileDialect):
576576
supports_alter = False
577577
max_identifier_length = 63
578578
supports_sane_rowcount = False
579-
supports_statement_cache = False
579+
supports_statement_cache = True
580580

581581
supports_native_enum = False
582582
supports_native_boolean = True
@@ -857,7 +857,7 @@ def do_execute(
857857
class AsyncYqlDialect(YqlDialect):
858858
driver = "ydb_async"
859859
is_async = True
860-
supports_statement_cache = False
860+
supports_statement_cache = True
861861

862862
def connect(self, *cargs, **cparams):
863863
return self.loaded_dbapi.async_connect(*cargs, **cparams)

ydb_sqlalchemy/sqlalchemy/dml.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class Upsert(sa.sql.Insert):
55
__visit_name__ = "upsert"
66
_propagate_attrs = {"compile_state_plugin": "yql"}
77
stringify_dialect = "yql"
8+
inherit_cache = False
89

910

1011
@sa.sql.base.CompileState.plugin_for("yql", "upsert")

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)