Skip to content

Commit 0019631

Browse files
Pin non_native_boolean_check_constraint and update_returning_multifrom
The dqlite dialect already pins supports_native_boolean, supports_native_decimal, the insert/update/delete RETURNING flags, supports_multivalues_insert, supported_isolation_levels, and supports_statement_cache against upstream drift. Two adjacent flags inherit silently from SQLiteDialect: - non_native_boolean_check_constraint. SQLAlchemy's Boolean type compiler gates this behind not supports_native_boolean, so it is functionally inert today. Pin False so the pair stays coherent if a future SQLAlchemy release decouples the two. - update_returning_multifrom. Available on SQLite >= 3.33, which dqlite is. Pin True alongside the existing RETURNING trio so the same upstream-drift argument applies. Both pins use the local-declaration pattern established by the RETURNING pins (asserting the flag lives in DqliteDialect.__dict__, not just inherited), so silent re-inheritance would fail the pin tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8f141c9 commit 0019631

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/sqlalchemydqlite/base.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ class DqliteDialect(SQLiteDialect):
8181
# to emit a ``CHECK (col IN (0, 1))`` constraint — the wire
8282
# contract enforces the 0/1 invariant.
8383
supports_native_boolean = True
84+
# SQLAlchemy's Boolean type compiler gates
85+
# ``non_native_boolean_check_constraint`` behind
86+
# ``supports_native_boolean``, so the flag is functionally inert
87+
# for us today. Pin False anyway to document intent and to keep
88+
# the pin in lockstep with ``supports_native_boolean`` if a future
89+
# SQLAlchemy release decouples the two.
90+
non_native_boolean_check_constraint = False
8491

8592
# dqlite runs every statement through Raft consensus; there is no
8693
# exposed way to weaken isolation. Declaring this explicitly lets
@@ -102,9 +109,11 @@ class DqliteDialect(SQLiteDialect):
102109
# SQLiteDialect's RETURNING detection (e.g. version-gated discovery)
103110
# can't silently change dqlite behaviour. All three of SQLAlchemy 2.x's
104111
# tripartite RETURNING flags default to True on the parent class today.
112+
# Same reasoning applies to the multi-FROM RETURNING variant.
105113
insert_returning = True
106114
update_returning = True
107115
delete_returning = True
116+
update_returning_multifrom = True
108117

109118
# SQLite >= 3.7.11 supports multi-row INSERT VALUES, which SQLAlchemy's
110119
# insertmanyvalues optimisation depends on. Pin the flag so bulk-insert

tests/test_dialect.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,21 @@ def test_supports_multivalues_insert_pinned_locally(self) -> None:
7070
assert DqliteDialect.supports_multivalues_insert is True
7171
assert "supports_multivalues_insert" in DqliteDialect.__dict__
7272

73+
def test_non_native_boolean_check_constraint_pinned_locally(self) -> None:
74+
# dqlite declares supports_native_boolean = True, so the CHECK
75+
# constraint is semantically unnecessary. Pin to False so a
76+
# future SQLAlchemy release cannot silently flip the inherited
77+
# value while native boolean support is already claimed.
78+
assert DqliteDialect.non_native_boolean_check_constraint is False
79+
assert "non_native_boolean_check_constraint" in DqliteDialect.__dict__
80+
81+
def test_update_returning_multifrom_pinned_locally(self) -> None:
82+
# dqlite's SQLite is >= 3.35, which supports multi-FROM RETURNING.
83+
# Pin locally for the same upstream-drift reason as the three
84+
# RETURNING flags above.
85+
assert DqliteDialect.update_returning_multifrom is True
86+
assert "update_returning_multifrom" in DqliteDialect.__dict__
87+
7388
def test_dialect_description(self) -> None:
7489
# Pin the derived dialect_description so SQLAlchemy upgrades cannot
7590
# silently change the rendered identity in ORM error messages.

0 commit comments

Comments
 (0)