Skip to content

Commit 4b22cc4

Browse files
authored
Escape table name in SQLite.tables (#323)
1 parent d9e21ec commit 4b22cc4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/SQLite.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ function tables(db::DB, sink = columntable)
784784
DBTable(
785785
tbl,
786786
Tables.schema(
787-
DBInterface.execute(db, "SELECT * FROM $(tbl) LIMIT 0"),
787+
DBInterface.execute(db, "SELECT * FROM $(esc_id(tbl)) LIMIT 0"),
788788
),
789789
) for tbl in tblnames.name
790790
]

test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ end
118118
@test String[] == [t.name for t in tables_v]
119119
DBInterface.close!(db)
120120
end
121+
122+
@testset "#322: SQLite.tables should escape table name" begin
123+
db = SQLite.DB()
124+
DBInterface.execute(db, "CREATE TABLE 'I.Js' (i INTEGER, j INTEGER)")
125+
tables_v = SQLite.tables(db)
126+
@test ["I.Js"] == [t.name for t in tables_v]
127+
DBInterface.close!(db)
128+
end
121129
end
122130

123131
@testset "Issue #207: 32 bit integers" begin

0 commit comments

Comments
 (0)