diff --git a/src/SQLite.jl b/src/SQLite.jl index 1ec7fad..4992469 100644 --- a/src/SQLite.jl +++ b/src/SQLite.jl @@ -784,7 +784,7 @@ function tables(db::DB, sink = columntable) DBTable( tbl, Tables.schema( - DBInterface.execute(db, "SELECT * FROM $(tbl) LIMIT 0"), + DBInterface.execute(db, "SELECT * FROM $(esc_id(tbl)) LIMIT 0"), ), ) for tbl in tblnames.name ] diff --git a/test/runtests.jl b/test/runtests.jl index 7c460c3..fb758ec 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -118,6 +118,14 @@ end @test String[] == [t.name for t in tables_v] DBInterface.close!(db) end + + @testset "#322: SQLite.tables should escape table name" begin + db = SQLite.DB() + DBInterface.execute(db, "CREATE TABLE 'I.Js' (i INTEGER, j INTEGER)") + tables_v = SQLite.tables(db) + @test ["I.Js"] == [t.name for t in tables_v] + DBInterface.close!(db) + end end @testset "Issue #207: 32 bit integers" begin