Skip to content

Commit bf679a1

Browse files
committed
🐛 improve identifier normalization and escaping in transporter
1 parent 45f44f7 commit bf679a1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/mysql_to_sqlite3/transporter.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,17 +328,18 @@ def _quote_sqlite_identifier(name: t.Union[str, bytes, bytearray]) -> str:
328328
"""
329329
if isinstance(name, (bytes, bytearray)):
330330
try:
331-
s = name.decode()
331+
s: str = name.decode()
332332
except (UnicodeDecodeError, AttributeError):
333333
s = str(name)
334334
else:
335335
s = str(name)
336336
try:
337337
# Normalize identifier using sqlglot, then wrap in quotes regardless
338-
normalized = exp.to_identifier(s).name
338+
normalized: str = exp.to_identifier(s).name
339339
except (AttributeError, ValueError, TypeError): # pragma: no cover - extremely unlikely
340340
normalized = s
341-
return f'"{normalized.replace("\"", "\"\"")}"'
341+
replaced: str = normalized.replace('"', '""')
342+
return f'"{replaced}"'
342343

343344
@staticmethod
344345
def _escape_mysql_backticks(identifier: str) -> str:

0 commit comments

Comments
 (0)