Skip to content

Fix: SQLite STRICT is not propagated in batch mode (#1758)#1792

Open
khanjan2708 wants to merge 1 commit intosqlalchemy:mainfrom
khanjan2708:fix-sqlite-strict-persistence
Open

Fix: SQLite STRICT is not propagated in batch mode (#1758)#1792
khanjan2708 wants to merge 1 commit intosqlalchemy:mainfrom
khanjan2708:fix-sqlite-strict-persistence

Conversation

@khanjan2708
Copy link

Fixes: #1758

Description

This PR addresses Issue #1758 where SQLite tables created with special keywords like STRICT or WITHOUT ROWID lost these properties whenever a batch migration was performed (e.g., dropping a column or changing a type).

Since SQLAlchemy's standard reflection does not currently capture these SQLite-specific table arguments, Alembic's batch mode would "forget" them when recreating the table.

Checklist

This pull request is:

  • A documentation / typographical error fix
    • Good to go, no issue or tests are needed
  • A short code fix
    • please include the issue number, and create an issue if none exists, which
      must include a complete example of the issue. one line code fixes without an
      issue and demonstration will not be accepted.
    • Please include: Fixes: #<issue number> in the commit message
    • please include tests. one line code fixes without tests will not be accepted.
  • A new feature implementation
    • please include the issue number, and create an issue if none exists, which must
      include a complete example of how the feature would look.
    • Please include: Fixes: #<issue number> in the commit message
    • please include tests.

Have a nice day!

…my#1758)

Introduced a new hook autogen_table_reflect in DefaultImpl to allow dialect-specific metadata adjustment after reflection.
In SQLiteImpl, this hook parses sqlite_master to detect and persist STRICT and WITHOUT ROWID properties when recreating tables in batch mode.
Added regression tests in tests/test_batch.py.
@khanjan2708 khanjan2708 marked this pull request as ready for review February 13, 2026 21:56
@CaselIT
Copy link
Member

CaselIT commented Feb 14, 2026

hi, this PR has a lot of formatting changes.
We have a pre-commit file with the formatters etc, could please run it so that only your changes are present?

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQLite STRICT is not propagated in batch mode

2 participants

Comments