Skip to content

Commit 8fc8484

Browse files
committed
⚡ detect UNSIGNED keyword using Regex
1 parent a5413ba commit 8fc8484

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sqlite3_to_mysql/transporter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class SQLite3toMySQL(SQLite3toMySQLAttributes):
4848

4949
COLUMN_PATTERN: t.Pattern[str] = re.compile(r"^[^(]+")
5050
COLUMN_LENGTH_PATTERN: t.Pattern[str] = re.compile(r"\(\d+\)")
51+
COLUMN_UNSIGNED_PATTERN: t.Pattern[str] = re.compile(r"\bUNSIGNED\b", re.IGNORECASE)
5152

5253
MYSQL_CONNECTOR_VERSION: version.Version = version.parse(mysql_connector_version_string)
5354

@@ -248,7 +249,7 @@ def _valid_column_type(cls, column_type: str) -> t.Optional[t.Match[str]]:
248249
def _translate_type_from_sqlite_to_mysql(self, column_type: str) -> str:
249250
"""This could be optimized even further, however is seems adequate."""
250251
full_column_type: str = column_type.upper()
251-
unsigned: bool = "UNSIGNED" in full_column_type
252+
unsigned: bool = self.COLUMN_UNSIGNED_PATTERN.search(full_column_type) is not None
252253
match: t.Optional[t.Match[str]] = self._valid_column_type(column_type)
253254
if not match:
254255
raise ValueError(f'"{column_type}" is not a valid column_type!')

0 commit comments

Comments
 (0)