Skip to content

Commit c93ebc0

Browse files
committed
🎨 implement CodeRabbit suggestions
1 parent 6721192 commit c93ebc0

File tree

3 files changed

+64
-4
lines changed

3 files changed

+64
-4
lines changed

src/sqlite3_to_mysql/mysql_utils.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,10 @@ def check_mysql_json_support(version_string: str) -> bool:
114114
"""Check for MySQL JSON support."""
115115
mysql_version: Version = get_mysql_version(version_string)
116116
if "mariadb" in version_string.lower():
117-
if mysql_version.major >= 10 and mysql_version.minor >= 2 and mysql_version.micro >= 7:
117+
if mysql_version.major > 10:
118118
return True
119+
if mysql_version.major == 10:
120+
return mysql_version.minor > 2 or (mysql_version.minor >= 2 and mysql_version.micro >= 7)
119121
else:
120122
if mysql_version.major >= 8:
121123
return True
@@ -145,9 +147,11 @@ def check_mysql_values_alias_support(version_string: str) -> bool:
145147
def check_mysql_fulltext_support(version_string: str) -> bool:
146148
"""Check for FULLTEXT indexing support."""
147149
mysql_version: Version = get_mysql_version(version_string)
148-
if version_string.lower().endswith("-mariadb"):
149-
if mysql_version.major >= 10 and mysql_version.minor >= 0 and mysql_version.micro >= 5:
150+
if "mariadb" in version_string.lower():
151+
if mysql_version.major > 10:
150152
return True
153+
if mysql_version.major == 10:
154+
return mysql_version.minor > 0 or (mysql_version.minor >= 0 and mysql_version.micro >= 5)
151155
else:
152156
if mysql_version.major >= 8:
153157
return True

tests/func/sqlite3_to_mysql_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_valid_sqlite_file_and_valid_mysql_credentials(
5959
mysql_credentials: MySQLCredentials,
6060
helpers: Helpers,
6161
quiet: bool,
62-
):
62+
) -> None:
6363
with helpers.not_raises(FileNotFoundError):
6464
SQLite3toMySQL( # type: ignore
6565
sqlite_file=sqlite_database,

tests/unit/mysql_utils_test.py

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import pytest
2+
3+
from sqlite3_to_mysql.mysql_utils import (
4+
check_mysql_fulltext_support,
5+
check_mysql_json_support,
6+
check_mysql_values_alias_support,
7+
)
8+
9+
10+
class TestMySQLUtils:
11+
@pytest.mark.parametrize(
12+
"version_string,expected",
13+
[
14+
("5.7.7", False),
15+
("5.7.8", True),
16+
("8.0.0", True),
17+
("9.0.0", True),
18+
("10.2.6-mariadb", False),
19+
("10.2.7-mariadb", True),
20+
("11.4.0-mariadb", True),
21+
],
22+
)
23+
def test_check_mysql_json_support(self, version_string: str, expected: bool) -> None:
24+
assert check_mysql_json_support(version_string) == expected
25+
26+
@pytest.mark.parametrize(
27+
"version_string,expected",
28+
[
29+
("5.7.8", False),
30+
("8.0.0", False),
31+
("8.0.18", False),
32+
("8.0.19", True),
33+
("9.0.0", True),
34+
("10.2.6-mariadb", False),
35+
("10.2.7-mariadb", False),
36+
("11.4.0-mariadb", False),
37+
],
38+
)
39+
def test_check_mysql_values_alias_support(self, version_string: str, expected: bool) -> None:
40+
assert check_mysql_values_alias_support(version_string) == expected
41+
42+
@pytest.mark.parametrize(
43+
"version_string,expected",
44+
[
45+
("5.0.0", False),
46+
("5.5.0", False),
47+
("5.6.0", True),
48+
("8.0.0", True),
49+
("10.0.4-mariadb", False),
50+
("10.0.5-mariadb", True),
51+
("10.2.6-mariadb", True),
52+
("11.4.0-mariadb", True),
53+
],
54+
)
55+
def test_check_mysql_fulltext_support(self, version_string: str, expected: bool) -> None:
56+
assert check_mysql_fulltext_support(version_string) == expected

0 commit comments

Comments
 (0)