Skip to content

Conversation

techouse
Copy link
Owner

@techouse techouse commented Oct 6, 2025

This pull request adds support for creating SQLite tables in STRICT mode when the SQLite version supports it. A new CLI option is introduced to enable this feature, and appropriate checks and warnings are implemented for unsupported SQLite versions. The documentation is updated, and unit tests are added to ensure correct behavior.

New STRICT mode support:

  • Added a --strict (-M) CLI option to enable creation of SQLite STRICT tables when supported. This is reflected in both the CLI argument parsing (cli.py) and the documentation (README.md, docs/README.rst). [1] [2] [3] [4]
  • The MySQLtoSQLite class now accepts a sqlite_strict parameter, stores it as an attribute, and checks the SQLite version. If STRICT mode is requested but not supported (SQLite < 3.37.0), a warning is logged and STRICT mode is disabled. [1] [2] [3]
  • When enabled, STRICT is appended to CREATE TABLE statements in the generated SQL.

Testing and validation:

  • Added unit tests to verify that STRICT mode is enabled or disabled appropriately based on the SQLite version, and that the correct warnings are issued. Also tests that STRICT is appended to CREATE TABLE statements when enabled.
  • Updated test imports to support new tests.

Closes #106

@techouse techouse self-assigned this Oct 6, 2025
@techouse techouse added the enhancement New feature or request label Oct 6, 2025
Copy link

coderabbitai bot commented Oct 6, 2025

Walkthrough

Adds a new --strict (-M) CLI option to enable SQLite STRICT tables. The flag is threaded through the CLI into the transporter, which conditionally appends STRICT to CREATE TABLE statements when the SQLite version is >= 3.37.0. Documentation and tests are updated accordingly.

Changes

Cohort / File(s) Summary of Changes
Docs
README.md, docs/README.rst
Documented new CLI flag -M / --strict for creating SQLite STRICT tables when supported.
CLI + Params
src/mysql_to_sqlite3/cli.py, src/mysql_to_sqlite3/types.py
Added strict: bool CLI option; propagated as sqlite_strict into converter. Extended TypedDicts for params/attributes with strict fields.
Transporter Logic
src/mysql_to_sqlite3/transporter.py
Implemented _sqlite_strict handling. Enabled STRICT in CREATE TABLE SQL when supported; warns and disables on SQLite < 3.37.0. Adjusted statement terminator to append STRICT before ;.
Tests
tests/unit/test_transporter.py
Added unit tests covering version gating, warning emission, internal flag setting, and SQL generation with STRICT.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User
  participant CLI as CLI (mysql-to-sqlite3)
  participant Conv as MySQLtoSQLite
  participant Trans as Transporter
  participant SQLite as sqlite3

  User->>CLI: Run with --strict
  CLI->>Conv: Construct(sqlite_strict=True, ...)
  Conv->>Trans: Init(sqlite_strict=True)
  Trans->>SQLite: Check sqlite_version
  alt SQLite >= 3.37.0
    Trans-->>Trans: _sqlite_strict = True
    Note right of Trans: STRICT enabled
  else SQLite < 3.37.0
    Trans-->>Trans: _sqlite_strict = False
    Trans-->>CLI: Log warning (STRICT disabled)
  end
  CLI->>Trans: Create tables
  alt _sqlite_strict True
    Trans->>SQLite: CREATE TABLE ... ) STRICT;
  else
    Trans->>SQLite: CREATE TABLE ... );
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A whisker-twitch, a flag so neat,
I flip --strict and drum my feet—
Tables born with careful might,
Version checks by moonlit night.
Hop, hop! The schema’s tight;
SQLite nods, “All rules in sight.”
Carrots aligned—constraints just right.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The description provides a concise summary of the feature and links to the closed issue but omits several required template sections including the Type of change, How Has This Been Tested, and Checklist headings. Please populate the missing template sections by specifying the type of change, detailing the tests run under “How Has This Been Tested?”, and completing the checklist to ensure alignment with the repository’s PR standards.
Docstring Coverage ⚠️ Warning Docstring coverage is 43.75% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues Check ✅ Passed All objectives from issue #106 are addressed: a new CLI flag is introduced, CREATE TABLE statements include the STRICT modifier, and runtime version checks with warnings are implemented according to SQLite documentation.
Out of Scope Changes Check ✅ Passed All changes are directly related to enabling strict mode support, including documentation, CLI parsing, SQL generation, and tests, with no unrelated or misplaced modifications.
Title Check ✅ Passed The title clearly summarises the primary change by describing the addition of support for creating SQLite STRICT tables via the new –M/--strict CLI switch, ensuring the main feature is communicated directly.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/strict

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@techouse techouse changed the title 🦺 add support for SQLite STRICT tables 🦺 add support for SQLite STRICT tables via -M / --strict CLI switch Oct 6, 2025
@techouse techouse changed the title 🦺 add support for SQLite STRICT tables via -M / --strict CLI switch 🦺 add support for SQLite STRICT tables via -M/--strict CLI switch Oct 6, 2025
Copy link

codecov bot commented Oct 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.23%. Comparing base (e34caec) to head (30c4dcd).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #107      +/-   ##
==========================================
+ Coverage   94.14%   94.23%   +0.08%     
==========================================
  Files           8        8              
  Lines         649      659      +10     
==========================================
+ Hits          611      621      +10     
  Misses         38       38              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@techouse techouse changed the title 🦺 add support for SQLite STRICT tables via -M/--strict CLI switch 🦺 add support for creating SQLite STRICT tables via -M/--strict CLI switch Oct 6, 2025
@techouse techouse changed the title 🦺 add support for creating SQLite STRICT tables via -M/--strict CLI switch ✨ add support for creating SQLite STRICT tables via -M/--strict CLI switch Oct 6, 2025
@techouse techouse merged commit 8ddd91a into master Oct 7, 2025
63 checks passed
@techouse techouse deleted the feat/strict branch October 7, 2025 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add --strict option to create STRICT tables

1 participant