Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix typo in --mysql-insert-method parameter #130

Merged
merged 8 commits into from
Oct 26, 2024
Merged

Conversation

techouse
Copy link
Owner

@techouse techouse commented Oct 26, 2024

Pull Request Template

Description

While reviewing #127 I noticed that MariaDB does not support aliasing VALUES that's why the tests were failing with MariaDB but worked with MySQL. Additionally, MySQL <8.0.19 also does not support this feature, so I have added an additional condition to work around this issue.

Supersedes #127 originally authored by @mackuba

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

The test suite passes with both MySQL and MariaDB.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@techouse techouse added the bug Something isn't working label Oct 26, 2024
@techouse techouse self-assigned this Oct 26, 2024
Copy link

coderabbitai bot commented Oct 26, 2024

Walkthrough

The changes introduce a new function, check_mysql_values_alias_support, to assess the support for the VALUES alias in MySQL based on the version string. It also modifies the existing functions check_mysql_json_support and check_mysql_fulltext_support to improve detection of MariaDB versions. Additionally, in the SQLite3toMySQL class, the parameter mysql_integer_type is renamed to mysql_insert_method, and the SQL statement generation logic is updated to conditionally include the alias based on the new function's result, enhancing compatibility with various MySQL versions.

Changes

File Path Change Summary
src/sqlite3_to_mysql/mysql_utils.py Added check_mysql_values_alias_support(version_string: str) -> bool. Modified check_mysql_json_support and check_mysql_fulltext_support to detect "mariadb" anywhere in the version string.
src/sqlite3_to_mysql/transporter.py Introduced check_mysql_values_alias_support from mysql_utils. Renamed parameter mysql_integer_type to mysql_insert_method in SQLite3toMySQL constructor. Updated SQL generation logic in transfer method to conditionally include alias based on MySQL version support.
tests/func/sqlite3_to_mysql_test.py Updated return type annotations for several test methods. Introduced FakeMySQLConnection for simulating MySQL errors in tests. Enhanced error handling tests.
tests/unit/mysql_utils_test.py Added new test class TestMySQLUtils with parameterized tests for check_mysql_json_support, check_mysql_values_alias_support, and check_mysql_fulltext_support.

Possibly related PRs

Suggested labels

enhancement, ci

Poem

In the realm of code, a change so bright,
A function to check if the values are right.
With MySQL’s version, it dances and plays,
Ensuring our queries shine in new ways.
So hop along, let’s celebrate this feat,
For every new line makes our logic complete! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@techouse techouse changed the title fix typo in --mysql-insert-method parameter 🐛 fix typo in --mysql-insert-method parameter Oct 26, 2024
Copy link

codecov bot commented Oct 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.15%. Comparing base (d5e5626) to head (e4a632e).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #130      +/-   ##
==========================================
+ Coverage   88.65%   89.15%   +0.49%     
==========================================
  Files           8        8              
  Lines         670      664       -6     
==========================================
- Hits          594      592       -2     
+ Misses         76       72       -4     

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

@techouse
Copy link
Owner Author

@coderabbitai review

Copy link

coderabbitai bot commented Oct 26, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d5e5626 and 93e9b51.

📒 Files selected for processing (2)
  • src/sqlite3_to_mysql/mysql_utils.py (2 hunks)
  • src/sqlite3_to_mysql/transporter.py (3 hunks)
🧰 Additional context used
🪛 Ruff
src/sqlite3_to_mysql/mysql_utils.py

138-140: Return the condition mysql_version.micro >= 19 directly

Replace with return mysql_version.micro >= 19

(SIM103)

🪛 GitHub Check: codecov/patch
src/sqlite3_to_mysql/mysql_utils.py

[warning] 134-140: src/sqlite3_to_mysql/mysql_utils.py#L134-L140
Added lines #L134 - L140 were not covered by tests

src/sqlite3_to_mysql/transporter.py

[warning] 729-729: src/sqlite3_to_mysql/transporter.py#L729
Added line #L729 was not covered by tests

🔇 Additional comments (3)
src/sqlite3_to_mysql/mysql_utils.py (2)

134-140: Add test coverage for version checking logic

The version checking branches lack test coverage.

Let's verify which test cases are missing:

#!/bin/bash
# Description: Check existing test coverage for version checks

echo "Checking test coverage for MySQL version checks..."
rg -l "check_mysql_values_alias_support" tests/
rg "def test.*check_mysql_values_alias_support" tests/

Would you like me to help generate comprehensive test cases covering all version scenarios?

🧰 Tools
🪛 Ruff

138-140: Return the condition mysql_version.micro >= 19 directly

Replace with return mysql_version.micro >= 19

(SIM103)

🪛 GitHub Check: codecov/patch

[warning] 134-140: src/sqlite3_to_mysql/mysql_utils.py#L134-L140
Added lines #L134 - L140 were not covered by tests


116-116: Improved MariaDB detection looks good!

The change from checking a specific suffix to checking for "mariadb" anywhere in the version string makes the detection more robust.

Let's verify this handles various MariaDB version strings correctly:

✅ Verification successful

The MariaDB version detection change is correct and well-implemented

The change to check for "mariadb" anywhere in the version string is a good improvement because:

  1. It correctly handles various MariaDB version string formats
  2. The version check logic remains intact, requiring MariaDB 10.2.7 or later for JSON support
  3. The implementation is consistent with other version checks in the codebase (e.g., check_mysql_values_alias_support and check_mysql_fulltext_support)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the MariaDB version string detection handles various formats

# Test cases with different MariaDB version string formats
echo "Testing MariaDB version detection..."
python3 -c "
from sqlite3_to_mysql.mysql_utils import check_mysql_json_support
test_versions = [
    '10.5.8-MariaDB',
    '10.5.8-mariadb-1:10.5.8+maria~focal',
    '5.5.5-10.5.8-MariaDB-1:10.5.8+maria~focal'
]
for v in test_versions:
    print(f'{v}: {check_mysql_json_support(v)}')
"

Length of output: 1104


Script:

#!/bin/bash
# Let's first check the implementation of check_mysql_json_support
echo "Checking implementation of check_mysql_json_support..."
rg -A 10 "def check_mysql_json_support" src/

# Then check if there are any tests for this function
echo -e "\nChecking tests for MariaDB version detection..."
rg "def test.*check_mysql_json_support" tests/

# Also look for test cases with MariaDB version strings
echo -e "\nLooking for MariaDB version string test cases..."
rg "MariaDB.*version" tests/

Length of output: 1352


Script:

#!/bin/bash
# Let's check the test file contents for version checks
echo "Checking test files for version checks..."
fd -e py -e test . tests/ -x cat {}

# Also check if there are any version-related test fixtures
echo -e "\nChecking test fixtures..."
fd fixtures -e py -e json -e yaml tests/ -x cat {}

Length of output: 91808


Script:

#!/bin/bash
# Let's check the actual implementation of check_mysql_json_support
echo "Checking check_mysql_json_support implementation..."
cat src/sqlite3_to_mysql/mysql_utils.py

Length of output: 4386

src/sqlite3_to_mysql/transporter.py (1)

757-757: ⚠️ Potential issue

Remove debugging print statement

The print(sql) statement at line 757 appears to be used for debugging. Leaving print statements can clutter the console output and potentially expose sensitive information.

Apply this diff to remove the unwanted print statement:

-    print(sql)

Likely invalid or redundant comment.

src/sqlite3_to_mysql/mysql_utils.py Outdated Show resolved Hide resolved
src/sqlite3_to_mysql/transporter.py Outdated Show resolved Hide resolved
src/sqlite3_to_mysql/transporter.py Outdated Show resolved Hide resolved
@techouse
Copy link
Owner Author

@coderabbitai review

Copy link

coderabbitai bot commented Oct 26, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 1

🧹 Outside diff range and nitpick comments (1)
src/sqlite3_to_mysql/transporter.py (1)

726-745: MariaDB compatibility fix looks good!

The code correctly handles the VALUES alias syntax based on MySQL version compatibility.

Consider refactoring SQL query construction

The SQL query construction logic could be more maintainable. Consider extracting the common parts into helper methods.

Here's a suggested refactor:

def _build_fields_clause(self, columns):
    return ("`{}`, " * len(columns)).rstrip(" ,").format(*columns)

def _build_values_clause(self, columns, use_alias):
    placeholders = ("%s, " * len(columns)).rstrip(" ,")
    if use_alias:
        return f"VALUES ({placeholders}) AS `__new__`"
    return f"VALUES ({placeholders})"

def _build_updates_clause(self, columns, use_alias):
    if use_alias:
        return ("`{}`=`__new__`.`{}`, " * len(columns)).rstrip(" ,")
    return ("`{}`=`{}`, " * len(columns)).rstrip(" ,")

def _build_insert_sql(self, table_name, columns):
    use_alias = (
        self._mysql_insert_method.upper() == "UPDATE"
        and check_mysql_values_alias_support(self._mysql_version)
    )
    
    if self._mysql_insert_method.upper() == "UPDATE":
        return """
            INSERT
            INTO `{table}` ({fields})
            {values_clause}
            ON DUPLICATE KEY UPDATE {field_updates}
        """.format(
            table=safe_identifier_length(table_name),
            fields=self._build_fields_clause(columns),
            values_clause=self._build_values_clause(columns, use_alias),
            field_updates=self._build_updates_clause(
                columns,
                use_alias
            ).format(*list(chain.from_iterable((column, column) for column in columns))),
        )
    
    return """
        INSERT {ignore}
        INTO `{table}` ({fields})
        VALUES ({placeholders})
    """.format(
        ignore="IGNORE" if self._mysql_insert_method.upper() == "IGNORE" else "",
        table=safe_identifier_length(table_name),
        fields=self._build_fields_clause(columns),
        placeholders=("%s, " * len(columns)).rstrip(" ,"),
    )

Then use it in the transfer method:

-                    sql: str
-                    if self._mysql_insert_method.upper() == "UPDATE":
-                        sql = """
-                            INSERT
-                            INTO `{table}` ({fields})
-                            {values_clause}
-                            ON DUPLICATE KEY UPDATE {field_updates}
-                        """.format(
-                            table=safe_identifier_length(table["name"]),
-                            fields=("`{}`, " * len(columns)).rstrip(" ,").format(*columns),
-                            values_clause=(
-                                "VALUES ({placeholders}) AS `__new__`"
-                                if check_mysql_values_alias_support(self._mysql_version)
-                                else "VALUES ({placeholders})"
-                            ).format(placeholders=("%s, " * len(columns)).rstrip(" ,")),
-                            field_updates=(
-                                ("`{}`=`__new__`.`{}`, " * len(columns)).rstrip(" ,")
-                                if check_mysql_values_alias_support(self._mysql_version)
-                                else ("`{}`=`{}`, " * len(columns)).rstrip(" ,")
-                            ).format(*list(chain.from_iterable((column, column) for column in columns))),
-                        )
-                    else:
-                        sql = """
-                            INSERT {ignore}
-                            INTO `{table}` ({fields})
-                            VALUES ({placeholders})
-                        """.format(
-                            ignore="IGNORE" if self._mysql_insert_method.upper() == "IGNORE" else "",
-                            table=safe_identifier_length(table["name"]),
-                            fields=("`{}`, " * len(columns)).rstrip(" ,").format(*columns),
-                            placeholders=("%s, " * len(columns)).rstrip(" ,"),
-                        )
+                    sql = self._build_insert_sql(table["name"], columns)

Benefits:

  • Improved readability and maintainability
  • Easier to test individual components
  • Reduced code duplication
  • Better separation of concerns
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 93e9b51 and 6721192.

📒 Files selected for processing (2)
  • src/sqlite3_to_mysql/mysql_utils.py (2 hunks)
  • src/sqlite3_to_mysql/transporter.py (3 hunks)
🔇 Additional comments (3)
src/sqlite3_to_mysql/mysql_utils.py (1)

116-116: Improved MariaDB version detection

The modification to use a case-insensitive substring search for "mariadb" is more robust than the previous exact suffix match. This change correctly handles various MariaDB version string formats across different distributions.

src/sqlite3_to_mysql/transporter.py (2)

42-42: LGTM!

The import is correctly placed with other related MySQL utility functions.


92-94: LGTM!

The parameter handling is robust with:

  • Proper default value ("IGNORE")
  • Case normalisation using upper()
  • Validation against MYSQL_INSERT_METHOD constant

src/sqlite3_to_mysql/mysql_utils.py Outdated Show resolved Hide resolved
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: 2

🧹 Outside diff range and nitpick comments (3)
tests/unit/mysql_utils_test.py (3)

11-24: Consider adding docstring to explain version boundaries.

The test cases effectively cover the version boundaries for both MySQL and MariaDB, but adding a docstring would help explain why 5.7.8 and 10.2.7 are the cutoff versions for JSON support.

 @pytest.mark.parametrize(
     "version_string,expected",
     [
         ("5.7.7", False),
         ("5.7.8", True),
         ("8.0.0", True),
         ("9.0.0", True),
         ("10.2.6-mariadb", False),
         ("10.2.7-mariadb", True),
         ("11.4.0-mariadb", True),
     ],
 )
 def test_check_mysql_json_support(self, version_string: str, expected: bool) -> None:
+    """Test JSON support detection across MySQL/MariaDB versions.
+    
+    MySQL added JSON support in version 5.7.8
+    MariaDB added JSON support in version 10.2.7
+    """
     assert check_mysql_json_support(version_string) == expected

26-40: Add docstring to document MariaDB limitation.

The test cases correctly reflect that VALUES alias is only supported in MySQL ≥8.0.19 and never in MariaDB. Adding a docstring would help explain this limitation.

 @pytest.mark.parametrize(
     "version_string,expected",
     [
         ("5.7.8", False),
         ("8.0.0", False),
         ("8.0.18", False),
         ("8.0.19", True),
         ("9.0.0", True),
         ("10.2.6-mariadb", False),
         ("10.2.7-mariadb", False),
         ("11.4.0-mariadb", False),
     ],
 )
 def test_check_mysql_values_alias_support(self, version_string: str, expected: bool) -> None:
+    """Test VALUES alias support detection across MySQL/MariaDB versions.
+
+    MySQL added VALUES alias support in version 8.0.19
+    MariaDB does not support VALUES alias in any version
+    """
     assert check_mysql_values_alias_support(version_string) == expected

42-56: Add docstring to document version requirements.

The test cases effectively cover FULLTEXT support boundaries for both MySQL and MariaDB. Adding a docstring would help explain the version requirements.

 @pytest.mark.parametrize(
     "version_string,expected",
     [
         ("5.0.0", False),
         ("5.5.0", False),
         ("5.6.0", True),
         ("8.0.0", True),
         ("10.0.4-mariadb", False),
         ("10.0.5-mariadb", True),
         ("10.2.6-mariadb", True),
         ("11.4.0-mariadb", True),
     ],
 )
 def test_check_mysql_fulltext_support(self, version_string: str, expected: bool) -> None:
+    """Test FULLTEXT support detection across MySQL/MariaDB versions.
+
+    MySQL added FULLTEXT support in version 5.6.0
+    MariaDB added FULLTEXT support in version 10.0.5
+    """
     assert check_mysql_fulltext_support(version_string) == expected
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6721192 and c93ebc0.

📒 Files selected for processing (3)
  • src/sqlite3_to_mysql/mysql_utils.py (2 hunks)
  • tests/func/sqlite3_to_mysql_test.py (1 hunks)
  • tests/unit/mysql_utils_test.py (1 hunks)
🔇 Additional comments (6)
tests/unit/mysql_utils_test.py (1)

1-10: LGTM! Clean and well-structured imports.

The imports are explicit and well-organised, following Python best practices.

src/sqlite3_to_mysql/mysql_utils.py (2)

129-144: Function implementation is correct

The version check logic accurately identifies MySQL 8.0.19+ for VALUES alias support whilst correctly handling MariaDB versions.


116-120: Improved MariaDB version detection looks good

The change from suffix-based to substring-based MariaDB detection is more robust and handles various MariaDB version string formats correctly.

Let's verify the version string handling with different formats:

✅ Verification successful

MariaDB version detection is well-tested and correctly implemented

The test suite demonstrates comprehensive coverage of MariaDB version string handling with various formats, including:

  • Standard MariaDB format (e.g., "10.2.7-mariadb")
  • Different major versions (10.x and 11.x)
  • Version boundary cases for JSON support:
    • "10.2.6-mariadb" (unsupported)
    • "10.2.7-mariadb" (supported)
    • "11.4.0-mariadb" (supported)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for version string handling test cases
# Look for test coverage of different MariaDB version formats
rg -A 3 "mariadb.*version|version.*mariadb" tests/

Length of output: 52


Script:

#!/bin/bash
# Let's check for test files related to MySQL version checks
fd -e py "test.*mysql" tests/

# Then look for any version-related test cases
rg -l "test.*version|version.*test" tests/

# Finally, let's examine the actual test implementations
ast-grep --pattern 'def test_$_version$_($_) { $$$ }'

Length of output: 186


Script:

#!/bin/bash
# Let's examine the test cases in mysql_utils_test.py
cat tests/unit/mysql_utils_test.py

Length of output: 1768

tests/func/sqlite3_to_mysql_test.py (3)

62-62: LGTM! Return type annotation improves type safety.

The addition of -> None return type annotation follows Python type hinting best practices and improves code clarity.


Line range hint 447-448: Well-implemented version-specific SQL syntax handling.

The conditional JOIN syntax based on MySQL version (8.0.19) ensures compatibility across different MySQL and MariaDB versions. This is particularly important for the foreign key information retrieval.


Line range hint 324-349: Consider adding MariaDB-specific test parameters.

While the test coverage is comprehensive for MySQL scenarios, consider adding specific test parameters or markers for MariaDB compatibility testing, especially given the PR's focus on MariaDB compatibility issues.

tests/unit/mysql_utils_test.py Outdated Show resolved Hide resolved
src/sqlite3_to_mysql/mysql_utils.py Outdated Show resolved Hide resolved
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: 1

🧹 Outside diff range and nitpick comments (3)
tests/unit/mysql_utils_test.py (2)

14-28: Consider adding edge cases for version parsing

Whilst the current test cases cover valid version strings well, consider adding tests for:

  • Malformed version strings (e.g., "8.0", "not-a-version")
  • Empty strings
  • None values

Example additions:

@pytest.mark.parametrize(
    "version_string,expected",
    [
        # ... existing cases ...
        pytest.param("8.0", pytest.raises(ValueError), id="incomplete_version"),
        pytest.param("not-a-version", pytest.raises(ValueError), id="invalid_version"),
        pytest.param("", pytest.raises(ValueError), id="empty_string"),
        pytest.param(None, pytest.raises(TypeError), id="none_value"),
    ],
)

76-87: Consider additional identifier length test cases

Whilst the current test cases cover length boundaries well, consider adding tests for:

  • Unicode characters (which might have different byte lengths)
  • Special characters in identifiers
  • Empty strings

Example additions:

@pytest.mark.parametrize(
    "identifier,expected",
    [
        # ... existing cases ...
        ("🐰" * 64, "🐰" * 32),  # Unicode characters
        ("test@#$%^&*", "test@#$%^&*"),  # Special characters
        ("", ""),  # Empty string
    ],
)
src/sqlite3_to_mysql/mysql_utils.py (1)

114-139: Overall changes improve MariaDB compatibility

The modifications across all version check functions create a more robust and consistent approach to handling MariaDB versions. This effectively addresses the compatibility issues mentioned in the PR objectives.

Consider adding integration tests that verify the behaviour with actual MariaDB instances, particularly focusing on the VALUES alias support detection.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c93ebc0 and e4a632e.

📒 Files selected for processing (2)
  • src/sqlite3_to_mysql/mysql_utils.py (1 hunks)
  • tests/unit/mysql_utils_test.py (1 hunks)
🔇 Additional comments (7)
tests/unit/mysql_utils_test.py (4)

1-13: Well-structured imports and class organisation

The imports are properly organised, with explicit imports and clear type hints. The test class structure follows pytest best practices.


29-43: Comprehensive JSON support test coverage

The test cases effectively cover the version boundaries for JSON support in both MySQL and MariaDB. The parameterised test data is well-organised and the assertions are clear.


44-59: Well-aligned test cases for VALUES alias support

The test cases effectively validate the PR's main objective regarding MariaDB compatibility. The version boundary at MySQL 8.0.19 is properly tested, and the distinction between MySQL and MariaDB support is clearly demonstrated.


60-75: Thorough fulltext support test coverage

The test cases effectively cover the version boundaries for fulltext support in both MySQL and MariaDB. The test data is well-structured and provides good coverage of the feature's availability across different versions.

src/sqlite3_to_mysql/mysql_utils.py (3)

114-118: Improved MariaDB detection looks good!

The change from suffix-based to substring-based MariaDB detection is more robust, and the version comparison logic is now more concise.


136-139: Consistent MariaDB detection approach looks good!

The changes align well with the other version check functions, making the codebase more consistent and maintainable.


120-131: Add test coverage for MariaDB edge cases

Whilst the implementation looks correct, we should ensure comprehensive test coverage for MariaDB-specific scenarios:

  1. MariaDB versions that might include "mariadb" in different cases (e.g., "MariaDB", "MARIADB")
  2. MariaDB versions with different version number formats

Let's verify the existing test coverage:

tests/unit/mysql_utils_test.py Show resolved Hide resolved
@techouse techouse merged commit 3fc65aa into master Oct 26, 2024
82 checks passed
@techouse techouse deleted the fix_insert_method branch October 26, 2024 11:50
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.

2 participants