Skip to content

Commit 0e5b785

Browse files
committed
SA14: Enable SQL compilation caching for CrateDialect and friends
This patch follows the documentation at [1] and adds the attributes `supports_statement_cache`, `cache_ok` and `inherit_cache` to the corresponding classes of `CrateDialect`, `UserDefinedType` and `ColumnElement`. The test suite thoroughly accepted this change of setting all attributes to `True`, effectively fully supporting SQL compilation caching. [1] https://docs.sqlalchemy.org/en/14/faq/performance.html
1 parent 40b697e commit 0e5b785

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

src/crate/client/sqlalchemy/dialect.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ class CrateDialect(default.DefaultDialect):
167167
ddl_compiler = CrateDDLCompiler
168168
type_compiler = CrateTypeCompiler
169169
supports_native_boolean = True
170+
supports_statement_cache = True
170171
colspecs = colspecs
171172
implicit_returning = True
172173

src/crate/client/sqlalchemy/predicates/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525

2626
class Match(ColumnElement):
27+
inherit_cache = True
2728

2829
def __init__(self, column, term, match_type=None, options=None):
2930
super(Match, self).__init__()

src/crate/client/sqlalchemy/types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def __eq__(self, other):
132132

133133

134134
class _Craty(sqltypes.UserDefinedType):
135+
cache_ok = True
135136

136137
class Comparator(sqltypes.TypeEngine.Comparator):
137138

@@ -165,6 +166,7 @@ class Any(expression.ColumnElement):
165166
166167
"""
167168
__visit_name__ = 'any'
169+
inherit_cache = True
168170

169171
def __init__(self, left, right, operator=operators.eq):
170172
self.type = sqltypes.Boolean()
@@ -174,6 +176,7 @@ def __init__(self, left, right, operator=operators.eq):
174176

175177

176178
class _ObjectArray(sqltypes.UserDefinedType):
179+
cache_ok = True
177180

178181
class Comparator(sqltypes.TypeEngine.Comparator):
179182
def __getitem__(self, key):
@@ -222,6 +225,7 @@ def get_col_spec(self, **kws):
222225

223226

224227
class Geopoint(sqltypes.UserDefinedType):
228+
cache_ok = True
225229

226230
class Comparator(sqltypes.TypeEngine.Comparator):
227231

@@ -247,6 +251,7 @@ def result_processor(self, dialect, coltype):
247251

248252

249253
class Geoshape(sqltypes.UserDefinedType):
254+
cache_ok = True
250255

251256
class Comparator(sqltypes.TypeEngine.Comparator):
252257

0 commit comments

Comments
 (0)