Skip to content

Commit 9664586

Browse files
Pin supports_sane_rowcount flags on the dialect
Matches the same drift-defence policy already applied to supports_native_boolean, insert_returning, supports_multivalues_insert, etc. The values mirror the current SQLiteDialect defaults; pinning them on DqliteDialect itself prevents a future SQLAlchemy change to the parent class from silently altering dqlite's rowcount semantics.
1 parent 5af9f59 commit 9664586

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

src/sqlalchemydqlite/base.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,18 @@ class DqliteDialect(SQLiteDialect):
147147
# behaviour stays stable against upstream dialect drift.
148148
supports_multivalues_insert = True
149149

150+
# Rowcount truthfulness flags. SQLite (and therefore dqlite) reports
151+
# accurate UPDATE / DELETE rowcounts and accurate aggregated
152+
# executemany rowcounts. The two ``*_returning`` flags are False
153+
# because SQLAlchemy's insertmanyvalues-with-RETURNING path relies
154+
# on separate accounting; pinning False matches the inherited
155+
# SQLiteDialect behaviour but, like the other pins above, guards
156+
# against silent upstream drift.
157+
supports_sane_rowcount = True
158+
supports_sane_multi_rowcount = True
159+
supports_sane_rowcount_returning = False
160+
supports_sane_multi_rowcount_returning = False
161+
150162
# Insert-path flags inherited from SQLiteDialect. SQLAlchemy's
151163
# insertmanyvalues codegen, DEFAULT VALUES form, and rowid handling
152164
# all key on these. Pin locally for the same "against upstream

tests/test_dialect_dialect_config.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,26 @@ def test_is_disconnect_false_for_non_leader_codes(self, code: int) -> None:
325325
dialect = DqliteDialect()
326326
e = dqliteclient.exceptions.OperationalError(code, "application error")
327327
assert dialect.is_disconnect(e, None, None) is False
328+
329+
330+
class TestSupportsSaneRowcountFlags:
331+
"""Pin the ``supports_sane_rowcount`` quartet on the dialect class
332+
itself (not merely inherited from ``SQLiteDialect``) so an upstream
333+
change to the parent default cannot silently alter dqlite
334+
behaviour. The values mirror the current SQLiteDialect defaults.
335+
"""
336+
337+
@pytest.mark.parametrize(
338+
("attr", "expected"),
339+
[
340+
("supports_sane_rowcount", True),
341+
("supports_sane_multi_rowcount", True),
342+
("supports_sane_rowcount_returning", False),
343+
("supports_sane_multi_rowcount_returning", False),
344+
],
345+
)
346+
def test_flag_is_defined_on_dialect_class(self, attr: str, expected: bool) -> None:
347+
assert attr in vars(DqliteDialect), (
348+
f"{attr!r} must be defined on DqliteDialect, not merely inherited"
349+
)
350+
assert getattr(DqliteDialect, attr) is expected

0 commit comments

Comments
 (0)