Skip to content

Commit acf7f6a

Browse files
Document why supports_statement_cache must be redeclared on the async dialect
The async dialect subclass ostensibly duplicates the base dialect's supports_statement_cache = True declaration, but the duplication is actually load-bearing. SQLAlchemy reads this attribute via ``self.__class__.__dict__.get("supports_statement_cache")`` (in engine/default.py::_supports_statement_cache), which is a single-class lookup, not an MRO walk. Removing the subclass declaration silently disables statement caching on the async dialect and emits a runtime warning on every engine startup. Leave an inline comment pointing at the SQLAlchemy code path so a future reader doesn't simplify this away. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e5ad595 commit acf7f6a

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/sqlalchemydqlite/aio.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ class DqliteDialect_aio(DqliteDialect): # noqa: N801
157157

158158
driver = "dqlitedbapi_aio"
159159
is_async = True
160+
# MUST be redeclared here even though the base class already sets it to
161+
# True: SQLAlchemy reads this attribute via
162+
# ``self.__class__.__dict__.get("supports_statement_cache")`` (see
163+
# engine/default.py::_supports_statement_cache), which is a
164+
# single-class lookup, not an MRO lookup. If this line is removed,
165+
# statement caching is silently disabled on the async dialect and a
166+
# warning fires on every engine startup.
160167
supports_statement_cache = True
161168

162169
@classmethod

0 commit comments

Comments
 (0)