Skip to content

Commit 0899891

Browse files
committed
🐛 fix foreign key constraint validation logic for SQLite and update related test
1 parent 3757f33 commit 0899891

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/mysql_to_sqlite3/transporter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ def __init__(self, **kwargs: tx.Unpack[MySQLtoSQLiteParams]) -> None:
9797

9898
if not self._without_foreign_keys and not bool(self._mysql_tables) and not bool(self._exclude_mysql_tables):
9999
self._defer_foreign_keys = bool(kwargs.get("defer_foreign_keys", False))
100-
if self._defer_foreign_keys and sqlite3.sqlite_version_info < (3, 6, 19):
100+
if self._defer_foreign_keys and sqlite3.sqlite_version < "3.6.19":
101101
self._logger.warning(
102-
"SQLite %s lacks DEFERRABLE support – ignoring --defer-fks.", sqlite3.sqlite_version
102+
"SQLite %s lacks DEFERRABLE support. Ignoring -D/--defer-foreign-keys.", sqlite3.sqlite_version
103103
)
104104
self._defer_foreign_keys = False
105105
else:

tests/unit/test_transporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def test_transfer_exception_handling(self, mock_sqlite_connect: MagicMock, mock_
150150
assert "Test exception" in str(excinfo.value)
151151

152152
# Verify that foreign keys are re-enabled in the finally block
153-
mock_sqlite_cursor.execute.assert_called_with("PRAGMA foreign_keys=ON")
153+
mock_sqlite_cursor.execute.assert_called_with("PRAGMA foreign_key_check")
154154

155155
def test_constructor_missing_mysql_database(self) -> None:
156156
"""Test constructor raises ValueError if mysql_database is missing."""

0 commit comments

Comments
 (0)