Bug report
Bug description:
sqlite3.Connection.iterdump() raises sqlite3.OperationalError instead of
producing a dump when a table (or column) name contains a single quote, even
though such names are valid SQLite identifiers.
import sqlite3
con = sqlite3.connect(":memory:")
con.execute("""CREATE TABLE "a'b" (x)""")
con.execute("""INSERT INTO "a'b" VALUES (1)""")
list(con.iterdump())
This raises:
sqlite3.OperationalError: near "'": syntax error
The generated INSERT statements are built by embedding the double-quoted
table name inside a single-quoted SQL string literal. The name is quoted
correctly as an identifier for the FROM clause, but its single quotes are
not doubled for the string-literal copy, so a name containing ' produces
broken SQL. Names containing a double quote or a newline are already handled.
The dump should keep round-tripping: a name containing ' must be emitted so
the dump can be replayed with executescript().
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
Bug report
Bug description:
sqlite3.Connection.iterdump()raisessqlite3.OperationalErrorinstead ofproducing a dump when a table (or column) name contains a single quote, even
though such names are valid SQLite identifiers.
This raises:
The generated
INSERTstatements are built by embedding the double-quotedtable name inside a single-quoted SQL string literal. The name is quoted
correctly as an identifier for the
FROMclause, but its single quotes arenot doubled for the string-literal copy, so a name containing
'producesbroken SQL. Names containing a double quote or a newline are already handled.
The dump should keep round-tripping: a name containing
'must be emitted sothe dump can be replayed with
executescript().CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs