Skip to content

Enable compilation query cache #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ydb_sqlalchemy/sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ class YqlDialect(StrCompileDialect):
supports_alter = False
max_identifier_length = 63
supports_sane_rowcount = False
supports_statement_cache = False
supports_statement_cache = True

supports_native_enum = False
supports_native_boolean = True
Expand Down Expand Up @@ -857,7 +857,7 @@ def do_execute(
class AsyncYqlDialect(YqlDialect):
driver = "ydb_async"
is_async = True
supports_statement_cache = False
supports_statement_cache = True

def connect(self, *cargs, **cparams):
return self.loaded_dbapi.async_connect(*cargs, **cparams)
1 change: 1 addition & 0 deletions ydb_sqlalchemy/sqlalchemy/dml.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Upsert(sa.sql.Insert):
__visit_name__ = "upsert"
_propagate_attrs = {"compile_state_plugin": "yql"}
stringify_dialect = "yql"
inherit_cache = False


@sa.sql.base.CompileState.plugin_for("yql", "upsert")
Expand Down
7 changes: 6 additions & 1 deletion ydb_sqlalchemy/sqlalchemy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@ class ListType(ARRAY):
__visit_name__ = "list_type"


class HashableDict(dict):
def __hash__(self):
return hash(tuple(self.items()))


class StructType(types.TypeEngine[Mapping[str, Any]]):
__visit_name__ = "struct_type"

def __init__(self, fields_types: Mapping[str, Union[Type[types.TypeEngine], Type[types.TypeDecorator]]]):
self.fields_types = fields_types
self.fields_types = HashableDict(dict(sorted(fields_types.items())))

@property
def python_type(self):
Expand Down
Loading