Skip to content

Conversation

@techouse
Copy link
Owner

@techouse techouse commented Nov 1, 2025

This pull request enhances the handling of MySQL string literals and default values during migration to SQLite, improving both correctness and robustness. The main focus is on normalizing pre-quoted string literals using sqlglot and ensuring consistent escaping for SQLite compatibility.

Literal normalization and default value translation:

  • Added a new helper method _normalize_literal_with_sqlglot in transporter.py to robustly parse and normalize MySQL literals to SQLite SQL using sqlglot. This method handles both direct literals and parenthesized literals.
  • Updated _translate_default_from_mysql_to_sqlite to use the new normalization method for pre-quoted or parenthesized string defaults, falling back to manual escaping only if normalization fails. This improves handling of edge cases like MariaDB's pre-quoted defaults.

Testing improvements:

  • Added new unit tests for pre-quoted string literal defaults in test_types_and_defaults_extra.py, verifying correct normalization and escaping for various string formats.

Fixes #91

@techouse techouse self-assigned this Nov 1, 2025
@techouse techouse added the bug Something isn't working label Nov 1, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 1, 2025

Walkthrough

Added sqlglot-based normalisation for MySQL literals and identifiers in the transporter: new classmethod for literal normalisation, default translation now attempts sqlglot normalisation before escaping, and identifier quoting uses sqlglot preprocessing. A unit test for pre-quoted string defaults was added.

Changes

Cohort / File(s) Summary
Default and Identifier Normalisation via sqlglot
src/mysql_to_sqlite3/transporter.py
Added _normalize_literal_with_sqlglot() classmethod to normalise MySQL literals to SQLite-compatible form; enhanced _translate_default_from_mysql_to_sqlite() to attempt literal normalisation via sqlglot for literal-like or parenthesised defaults before falling back to escaping; reworked _quote_sqlite_identifier() to normalise identifiers via sqlglot prior to quoting.
Test Coverage for Pre-quoted String Defaults
tests/unit/test_types_and_defaults_extra.py
Added unit test test_translate_default_prequoted_string_literal() to verify normalization and escaping of pre-quoted string default values.

Sequence Diagram(s)

sequenceDiagram
    participant Transporter
    participant Translate as _translate_default_from_mysql_to_sqlite
    participant Normalize as _normalize_literal_with_sqlglot
    participant SQLGlot as sqlglot
    participant Fallback as Escape/Quote
    participant SQLite as SQLite DEFAULT

    Transporter->>Translate: provide MySQL default expression
    alt default looks literal-like or parenthesised
        Translate->>Normalize: pass expr_sql
        Normalize->>SQLGlot: parse & attempt conversion
        alt sqlglot returns literal
            SQLGlot-->>Normalize: normalized literal
            Normalize-->>Translate: normalized value
        else sqlglot fails
            SQLGlot-->>Normalize: error/None
            Normalize-->>Translate: None
        end
    end
    alt got normalized value
        Translate-->>SQLite: use normalized DEFAULT
    else
        Translate->>Fallback: escape or quote original default
        Fallback-->>SQLite: escaped DEFAULT
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Focused changes but affect SQL parsing/normalisation logic; review should check sqlglot usage, edge cases for quoted/parenthesised defaults, and identifier quoting.
  • Files to inspect closely:
    • src/mysql_to_sqlite3/transporter.py — new normalization logic and identifier quoting changes.
    • tests/unit/test_types_and_defaults_extra.py — new test validating pre-quoted literals.

Possibly related PRs

Suggested labels

mariadb

Suggested reviewers

  • zokkis

Poem

🐰 Hippity-hop, literals now mend,
sqlglot hops in to tidy each end,
Defaults once tripped on brackets and quote,
Now bound for SQLite, steady afloat,
I nibble a carrot and cheer as they go! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description provides a well-structured summary of changes with clear motivation and references the linked issue (#91), which aligns with the template's core requirements. However, the description notably omits several template sections: it lacks explicit "Type of change" checkboxes (Bug fix/New feature/Breaking change/Documentation update), the "How Has This Been Tested?" section with test details and reproduction instructions, and the complete "Checklist" section with all verification items. While the provided content is on-topic and informative, the departure from the template structure is significant enough to constitute incomplete compliance with the repository's PR description standards. The author should revise the PR description to follow the template structure more closely by adding the missing sections: explicitly selecting the type of change (this appears to be a bug fix based on the context), detailing the testing performed (both unit tests and any manual verification), and completing the verification checklist items. This will ensure the PR metadata is consistent with the repository's standards and provides reviewers with complete context.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% 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
Title Check ✅ Passed The PR title "enhance handling of MySQL string literals and default values" clearly describes the main change in the changeset. The title is specific and directly relates to the modifications made across transporter.py and test files, which all focus on improving normalization and translation of MySQL default values to SQLite-compatible SQL. Although the emoji could be considered decorative noise, the substantive portion of the title is sufficiently clear and descriptive to convey the primary change to a team member reviewing the history.
Linked Issues Check ✅ Passed The PR directly addresses the requirements from issue #91, which identified SQLite table creation failures when MySQL default values contain special characters like '[]'. The implementation adds _normalize_literal_with_sqlglot to robustly parse and normalise MySQL literals to SQLite-compatible SQL, and updates _translate_default_from_mysql_to_sqlite to apply this normalisation with a fallback to manual escaping. The PR also includes new unit tests validating the normalisation of pre-quoted string literals. These changes collectively fulfil the core objective stated in issue #91: ensuring default string literals are normalised or escaped so SQLite table creation succeeds.
Out of Scope Changes Check ✅ Passed All code changes in this PR are directly aligned with the stated objectives from issue #91. The modifications to transporter.py (adding the normalisation method, enhancing the translation logic, and reworking identifier quoting) and the addition of unit tests in test_types_and_defaults_extra.py are all focused on improving handling of MySQL string literals and default values during SQLite migration. No unrelated refactoring, architectural changes, or tangential improvements are present that would fall outside the scope of the linked issue.
✨ 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 fix/normalize-literals

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 46d2c35 and 6057781.

📒 Files selected for processing (1)
  • tests/unit/test_types_and_defaults_extra.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/unit/test_types_and_defaults_extra.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Test (python3.14, mariadb:5.5, 1, true, 3.14)
  • GitHub Check: Test (python3.11, mariadb:5.5, 1, true, 3.11)
  • GitHub Check: Test (python3.10, mariadb:10.0, 1, true, 3.10)
  • GitHub Check: Test (python3.13, mariadb:5.5, 1, true, 3.13)
  • GitHub Check: Test (python3.9, mariadb:10.0, 1, true, 3.9)
  • GitHub Check: Test (python3.12, mariadb:5.5, 1, true, 3.12)
  • GitHub Check: Test (python3.10, mariadb:5.5, 1, true, 3.10)
  • GitHub Check: Test (python3.9, mariadb:5.5, 1, true, 3.9)
  • GitHub Check: Codacy Static Code Analysis

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.

@codecov
Copy link

codecov bot commented Nov 1, 2025

Codecov Report

❌ Patch coverage is 82.35294% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.81%. Comparing base (d973233) to head (6057781).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/mysql_to_sqlite3/transporter.py 82.35% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #115      +/-   ##
==========================================
- Coverage   99.11%   98.81%   -0.31%     
==========================================
  Files           8        8              
  Lines         908      925      +17     
==========================================
+ Hits          900      914      +14     
- Misses          8       11       +3     

☔ 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
tests/unit/test_types_and_defaults_extra.py (1)

88-92: LGTM! Well-targeted test for pre-quoted defaults.

This test directly addresses the MariaDB pre-quoted default issue from #91, verifying that string literals with brackets, doubled quotes, and backslash-escaped quotes are correctly normalised to SQLite syntax.

Optionally, consider testing additional edge cases:

  • Empty string: "''"
  • Parenthesized literals: "('value')"
  • Literals with special characters: "'tab\there'"

These would provide more comprehensive coverage, though the current tests adequately validate the core fix.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d973233 and 46d2c35.

📒 Files selected for processing (2)
  • src/mysql_to_sqlite3/transporter.py (2 hunks)
  • tests/unit/test_types_and_defaults_extra.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
tests/**

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use pytest; keep tests under tests/ mirroring src/mysql_to_sqlite3/ structure

Files:

  • tests/unit/test_types_and_defaults_extra.py
tests/unit/test_*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

tests/unit/test_*.py: Add unit tests in tests/unit/ for isolated helpers; create targeted files named test_.py
Add at least one unit test covering new flag behavior/validation
Add unit tests for new type mappings in _translate_type_from_mysql_to_sqlite
Add unit tests for new default expression translations

Files:

  • tests/unit/test_types_and_defaults_extra.py
{src,tests}/**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Adhere to lint suite: Black line length 120 and isort profile=black import ordering for all Python files

Files:

  • tests/unit/test_types_and_defaults_extra.py
  • src/mysql_to_sqlite3/transporter.py
src/mysql_to_sqlite3/transporter.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/mysql_to_sqlite3/transporter.py: Implement and modify core transfer logic (schema introspection, batching, type/default translation, reconnection handling) in transporter.py
Convert AUTO_INCREMENT single primary keys to INTEGER PRIMARY KEY AUTOINCREMENT only when the translated type is integer; log a warning otherwise
Avoid index naming collisions: if an index name equals its table name or --prefix-indices is set, prefix with

_
Centralize default value translation in _translate_default_from_mysql_to_sqlite; extend this function for new MySQL constructs
Handle JSON columns: if SQLite has JSON1, map MySQL JSON to JSON; otherwise map to TEXT unless --json-as-text is set
Skip foreign key generation when a table subset restriction is applied
Use _setup_logger for logging; do not instantiate new loggers ad hoc
For large tables, prefer chunked transfer using fetchmany(self._chunk_size) and executemany inserts
On CR_SERVER_LOST during schema or data transfer, attempt a single reconnect; preserve this behavior
Disable PRAGMA foreign_keys during bulk load and re-enable in finally; ensure early returns still re-enable
Use INSERT OR IGNORE to handle potential duplicate inserts
Thread new CLI parameters through the MySQLtoSQLite constructor
Raise ValueError in constructor for invalid configuration
When --debug is not set, swallow and log errors; when --debug is set, re-raise for stack inspection
Extend _translate_type_from_mysql_to_sqlite when adding type mappings and add corresponding tests
Extend _translate_default_from_mysql_to_sqlite to support new default expressions and add tests
Centralize progress/UI changes around tqdm and honor the --quiet flag

Files:

  • src/mysql_to_sqlite3/transporter.py
src/**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Keep mypy passing (Python 3.9 baseline); avoid untyped dynamic attributes in source code

Files:

  • src/mysql_to_sqlite3/transporter.py
src/mysql_to_sqlite3/{cli.py,transporter.py}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/mysql_to_sqlite3/{cli.py,transporter.py}: Never log raw passwords
Support --skip-ssl to disable MySQL SSL; default to encrypted where possible and do not silently change defaults

Files:

  • src/mysql_to_sqlite3/transporter.py
🧠 Learnings (15)
📓 Common learnings
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to src/mysql_to_sqlite3/transporter.py : Extend _translate_default_from_mysql_to_sqlite to support new default expressions and add tests
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to src/mysql_to_sqlite3/transporter.py : Centralize default value translation in _translate_default_from_mysql_to_sqlite; extend this function for new MySQL constructs
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to src/mysql_to_sqlite3/transporter.py : Extend _translate_type_from_mysql_to_sqlite when adding type mappings and add corresponding tests
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to src/mysql_to_sqlite3/transporter.py : Implement and modify core transfer logic (schema introspection, batching, type/default translation, reconnection handling) in transporter.py
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to src/mysql_to_sqlite3/transporter.py : Handle JSON columns: if SQLite has JSON1, map MySQL JSON to JSON; otherwise map to TEXT unless --json-as-text is set
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to src/mysql_to_sqlite3/{cli.py,transporter.py} : Support --skip-ssl to disable MySQL SSL; default to encrypted where possible and do not silently change defaults
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to tests/unit/test_*.py : Add unit tests for new type mappings in _translate_type_from_mysql_to_sqlite
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to mysql_utils.py : Use mysql_utils.py for charset/collation sets and MySQL value adaptation; add related helpers here
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to src/mysql_to_sqlite3/types.py : Keep type hints exhaustive in types.py and update when MySQLtoSQLite constructor kwargs change
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to sqlite_utils.py : Use sqlite_utils.py for SQLite capability detection and value adaptation; add related helpers here
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to src/mysql_to_sqlite3/types.py : When constructor kwargs change, update types.py accordingly for mypy
📚 Learning: 2025-10-18T21:08:55.973Z
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to src/mysql_to_sqlite3/transporter.py : Extend _translate_default_from_mysql_to_sqlite to support new default expressions and add tests

Applied to files:

  • tests/unit/test_types_and_defaults_extra.py
  • src/mysql_to_sqlite3/transporter.py
📚 Learning: 2025-10-18T21:08:55.973Z
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to tests/unit/test_*.py : Add unit tests for new type mappings in _translate_type_from_mysql_to_sqlite

Applied to files:

  • tests/unit/test_types_and_defaults_extra.py
📚 Learning: 2025-10-18T21:08:55.973Z
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to src/mysql_to_sqlite3/transporter.py : Centralize default value translation in _translate_default_from_mysql_to_sqlite; extend this function for new MySQL constructs

Applied to files:

  • tests/unit/test_types_and_defaults_extra.py
  • src/mysql_to_sqlite3/transporter.py
📚 Learning: 2025-10-18T21:08:55.973Z
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to src/mysql_to_sqlite3/transporter.py : Extend _translate_type_from_mysql_to_sqlite when adding type mappings and add corresponding tests

Applied to files:

  • tests/unit/test_types_and_defaults_extra.py
  • src/mysql_to_sqlite3/transporter.py
📚 Learning: 2025-10-18T21:08:55.973Z
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to tests/unit/test_*.py : Add unit tests for new default expression translations

Applied to files:

  • tests/unit/test_types_and_defaults_extra.py
📚 Learning: 2025-10-18T21:08:55.973Z
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to tests/** : Use pytest; keep tests under tests/ mirroring src/mysql_to_sqlite3/ structure

Applied to files:

  • tests/unit/test_types_and_defaults_extra.py
📚 Learning: 2025-10-18T21:08:55.973Z
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to src/mysql_to_sqlite3/{cli.py,transporter.py} : Support --skip-ssl to disable MySQL SSL; default to encrypted where possible and do not silently change defaults

Applied to files:

  • tests/unit/test_types_and_defaults_extra.py
  • src/mysql_to_sqlite3/transporter.py
📚 Learning: 2025-10-18T21:08:55.973Z
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to src/mysql_to_sqlite3/types.py : Keep type hints exhaustive in types.py and update when MySQLtoSQLite constructor kwargs change

Applied to files:

  • tests/unit/test_types_and_defaults_extra.py
  • src/mysql_to_sqlite3/transporter.py
📚 Learning: 2025-10-18T21:08:55.973Z
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to tests/unit/test_*.py : Add at least one unit test covering new flag behavior/validation

Applied to files:

  • tests/unit/test_types_and_defaults_extra.py
📚 Learning: 2025-10-18T21:08:55.973Z
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to src/mysql_to_sqlite3/transporter.py : Handle JSON columns: if SQLite has JSON1, map MySQL JSON to JSON; otherwise map to TEXT unless --json-as-text is set

Applied to files:

  • tests/unit/test_types_and_defaults_extra.py
  • src/mysql_to_sqlite3/transporter.py
📚 Learning: 2025-10-18T21:08:55.973Z
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to src/mysql_to_sqlite3/transporter.py : Implement and modify core transfer logic (schema introspection, batching, type/default translation, reconnection handling) in transporter.py

Applied to files:

  • src/mysql_to_sqlite3/transporter.py
📚 Learning: 2025-10-18T21:08:55.973Z
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to src/mysql_to_sqlite3/transporter.py : Thread new CLI parameters through the MySQLtoSQLite constructor

Applied to files:

  • src/mysql_to_sqlite3/transporter.py
📚 Learning: 2025-10-18T21:08:55.973Z
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to src/mysql_to_sqlite3/transporter.py : Avoid index naming collisions: if an index name equals its table name or --prefix-indices is set, prefix with <table>_

Applied to files:

  • src/mysql_to_sqlite3/transporter.py
📚 Learning: 2025-10-18T21:08:55.973Z
Learnt from: CR
Repo: techouse/mysql-to-sqlite3 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-18T21:08:55.973Z
Learning: Applies to src/mysql_to_sqlite3/transporter.py : Use _setup_logger for logging; do not instantiate new loggers ad hoc

Applied to files:

  • src/mysql_to_sqlite3/transporter.py
🧬 Code graph analysis (2)
tests/unit/test_types_and_defaults_extra.py (1)
src/mysql_to_sqlite3/transporter.py (2)
  • MySQLtoSQLite (44-1241)
  • _translate_default_from_mysql_to_sqlite (456-601)
src/mysql_to_sqlite3/transporter.py (1)
tests/unit/test_transporter.py (1)
  • sql (175-176)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Test (python3.13, mariadb:5.5, 1, true, 3.13)
  • GitHub Check: Test (python3.10, mariadb:10.0, 1, true, 3.10)
  • GitHub Check: Test (python3.12, mariadb:5.5, 1, true, 3.12)
  • GitHub Check: Test (python3.11, mariadb:5.5, 1, true, 3.11)
  • GitHub Check: Test (python3.14, mariadb:5.5, 1, true, 3.14)
  • GitHub Check: Test (python3.9, mariadb:10.0, 1, true, 3.9)
  • GitHub Check: Test (python3.9, mariadb:5.5, 1, true, 3.9)
  • GitHub Check: Test (python3.10, mariadb:5.5, 1, true, 3.10)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (2)
src/mysql_to_sqlite3/transporter.py (2)

327-339: LGTM! Clean sqlglot-based literal normalization.

The method correctly:

  • Parses MySQL expressions with sqlglot
  • Identifies literal nodes and returns SQLite-compatible SQL
  • Unwraps parenthesized literals (e.g., ('value')'value')
  • Returns None for non-literal expressions, enabling fallback logic

586-592: LGTM! Robust pre-quoted default handling with fallback.

This addition correctly targets non-DEFAULT_GENERATED defaults that are pre-quoted or parenthesized (the MariaDB edge case from issue #91). The logic:

  1. Attempts sqlglot normalization for literal-like defaults
  2. Falls back to manual escaping if normalization fails

This ensures '[]' is properly handled as DEFAULT '[]' in SQLite, fixing the reported syntax error whilst maintaining backward compatibility.

@techouse techouse merged commit 0abb379 into master Nov 1, 2025
72 of 74 checks passed
@techouse techouse deleted the fix/normalize-literals branch November 1, 2025 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default value of text columns cause exception

2 participants