Skip to content

Commit

Permalink
🎨 implement CodeRabbit suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
techouse committed Oct 26, 2024
1 parent 6721192 commit c93ebc0
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/sqlite3_to_mysql/mysql_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ def check_mysql_json_support(version_string: str) -> bool:
"""Check for MySQL JSON support."""
mysql_version: Version = get_mysql_version(version_string)
if "mariadb" in version_string.lower():
if mysql_version.major >= 10 and mysql_version.minor >= 2 and mysql_version.micro >= 7:
if mysql_version.major > 10:
return True
if mysql_version.major == 10:
return mysql_version.minor > 2 or (mysql_version.minor >= 2 and mysql_version.micro >= 7)
else:
if mysql_version.major >= 8:
return True
Expand Down Expand Up @@ -145,9 +147,11 @@ def check_mysql_values_alias_support(version_string: str) -> bool:
def check_mysql_fulltext_support(version_string: str) -> bool:
"""Check for FULLTEXT indexing support."""
mysql_version: Version = get_mysql_version(version_string)
if version_string.lower().endswith("-mariadb"):
if mysql_version.major >= 10 and mysql_version.minor >= 0 and mysql_version.micro >= 5:
if "mariadb" in version_string.lower():
if mysql_version.major > 10:
return True
if mysql_version.major == 10:
return mysql_version.minor > 0 or (mysql_version.minor >= 0 and mysql_version.micro >= 5)
else:
if mysql_version.major >= 8:
return True
Expand Down
2 changes: 1 addition & 1 deletion tests/func/sqlite3_to_mysql_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_valid_sqlite_file_and_valid_mysql_credentials(
mysql_credentials: MySQLCredentials,
helpers: Helpers,
quiet: bool,
):
) -> None:
with helpers.not_raises(FileNotFoundError):
SQLite3toMySQL( # type: ignore
sqlite_file=sqlite_database,
Expand Down
56 changes: 56 additions & 0 deletions tests/unit/mysql_utils_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import pytest

from sqlite3_to_mysql.mysql_utils import (
check_mysql_fulltext_support,
check_mysql_json_support,
check_mysql_values_alias_support,
)


class TestMySQLUtils:
@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:
assert check_mysql_json_support(version_string) == expected

@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:
assert check_mysql_values_alias_support(version_string) == expected

@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:
assert check_mysql_fulltext_support(version_string) == expected

0 comments on commit c93ebc0

Please sign in to comment.