Skip to content

Commit c5810d7

Browse files
committed
♻️ update sqlglot expression imports for consistency
1 parent 83ca270 commit c5810d7

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/mysql_to_sqlite3/transporter.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
from mysql.connector import CharacterSet, errorcode
1616
from mysql.connector.abstracts import MySQLConnectionAbstract
1717
from mysql.connector.types import RowItemType
18-
from sqlglot import Expression, exp, parse_one
18+
from sqlglot import exp, parse_one
1919
from sqlglot.errors import ParseError
20+
from sqlglot.expressions import Expr
2021
from tqdm import tqdm, trange
2122

2223
try:
@@ -313,7 +314,7 @@ def _transpile_mysql_expr_to_sqlite(cls, expr_sql: str) -> t.Optional[str]:
313314
"""
314315
cleaned: str = expr_sql.strip().rstrip(";")
315316
try:
316-
tree: Expression = parse_one(cleaned, read="mysql")
317+
tree: Expr = parse_one(cleaned, read="mysql")
317318
return tree.sql(dialect="sqlite")
318319
except (ParseError, ValueError):
319320
return None
@@ -328,7 +329,7 @@ def _normalize_literal_with_sqlglot(cls, expr_sql: str) -> t.Optional[str]:
328329
"""Normalize a MySQL literal using sqlglot, returning SQLite SQL if literal-like."""
329330
cleaned: str = expr_sql.strip().rstrip(";")
330331
try:
331-
node: Expression = parse_one(cleaned, read="mysql")
332+
node: Expr = parse_one(cleaned, read="mysql")
332333
except (ParseError, ValueError):
333334
return None
334335
if isinstance(node, exp.Literal):
@@ -377,7 +378,7 @@ def _transpile_mysql_type_to_sqlite(
377378
# Wrap the type in a CAST expression so sqlglot can parse it consistently.
378379
expr_sql: str = f"CAST(NULL AS {column_type.strip()})"
379380
try:
380-
tree: Expression = parse_one(expr_sql, read="mysql")
381+
tree: Expr = parse_one(expr_sql, read="mysql")
381382
rendered: str = tree.sql(dialect="sqlite")
382383
except (ParseError, ValueError, AttributeError, TypeError):
383384
return None
@@ -922,7 +923,7 @@ def _mysql_viewdef_to_sqlite(self, view_select_sql: str, view_name: str) -> str:
922923
cleaned_sql = view_select_sql.strip().rstrip(";")
923924

924925
try:
925-
tree: Expression = parse_one(cleaned_sql, read="mysql")
926+
tree: Expr = parse_one(cleaned_sql, read="mysql")
926927
except (ParseError, ValueError, AttributeError, TypeError):
927928
# Fallback: try to remove schema qualifiers if requested, then return
928929
stripped_sql = cleaned_sql

0 commit comments

Comments
 (0)