Skip to content

Commit 2d28ceb

Browse files
Pin the four insert-path dialect flags against upstream drift
SQLAlchemy's SQLiteDialect explicitly overrides four insert-path flags that DefaultDialect sets to False: use_insertmanyvalues, supports_default_metavalue, supports_default_values, and insert_null_pk_still_autoincrements. The dqlite dialect inherited them silently, so a version-gated change in a future SQLAlchemy release could alter insert codegen, DEFAULT VALUES handling, or rowid autoincrement behaviour without any signal on our side. Declare all four locally in DqliteDialect with a comment block that ties them back to the RETURNING and multivalues_insert pins already present, and extend the parametrised pin test so re-inheritance would fail the pin-tests immediately. None of these flips observable behaviour today — the pinned values match what SQLiteDialect already sets — this is documentation-as- code plus a forward-compatibility guard. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0019631 commit 2d28ceb

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/sqlalchemydqlite/base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ class DqliteDialect(SQLiteDialect):
120120
# behaviour stays stable against upstream dialect drift.
121121
supports_multivalues_insert = True
122122

123+
# Insert-path flags inherited from SQLiteDialect. SQLAlchemy's
124+
# insertmanyvalues codegen, DEFAULT VALUES form, and rowid handling
125+
# all key on these. Pin locally for the same "against upstream
126+
# drift" reason as the RETURNING trio above — a version-gated
127+
# change in a future SQLAlchemy release would silently alter
128+
# dqlite's insert behaviour otherwise.
129+
use_insertmanyvalues = True
130+
supports_default_metavalue = True
131+
supports_default_values = True
132+
insert_null_pk_still_autoincrements = True
133+
123134
# Override the SQLite dialect's string-based DATE/DATETIME processors:
124135
# dqlitedbapi returns datetime objects (PEP 249), not ISO strings.
125136
colspecs = {

tests/test_dialect.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Tests for dqlite dialect."""
22

3+
import pytest
34
from sqlalchemy.engine import URL
45

56
from sqlalchemydqlite import DqliteDialect
@@ -85,6 +86,24 @@ def test_update_returning_multifrom_pinned_locally(self) -> None:
8586
assert DqliteDialect.update_returning_multifrom is True
8687
assert "update_returning_multifrom" in DqliteDialect.__dict__
8788

89+
@pytest.mark.parametrize(
90+
"flag",
91+
[
92+
"use_insertmanyvalues",
93+
"supports_default_metavalue",
94+
"supports_default_values",
95+
"insert_null_pk_still_autoincrements",
96+
],
97+
)
98+
def test_insert_path_flags_pinned_locally(self, flag: str) -> None:
99+
"""SQLAlchemy's SQLiteDialect sets these four insert-path flags
100+
explicitly. The dqlite dialect inherits them silently otherwise.
101+
Pin locally so upstream version-gated changes cannot alter
102+
insert codegen or rowid behaviour for dqlite.
103+
"""
104+
assert getattr(DqliteDialect, flag) is True
105+
assert flag in DqliteDialect.__dict__
106+
88107
def test_dialect_description(self) -> None:
89108
# Pin the derived dialect_description so SQLAlchemy upgrades cannot
90109
# silently change the rendered identity in ORM error messages.

0 commit comments

Comments
 (0)