sqlite3 icon indicating copy to clipboard operation
sqlite3 copied to clipboard

How to quote SQLite identifiers

Open shofetim opened this issue 2 years ago • 0 comments

Test case:

Running this:

(import sqlite3 :as sql)
(def db (sql/open "test.db"))
(sql/eval db `CREATE TABLE customers (id INTEGER PRIMARY KEY, "first-name" TEXT);`)
(sql/eval db `INSERT INTO customers (id, "first-name") VALUES(:id, :first-name);`
          {:first-name "John" :id 12345})

Results in:

error: no such column: name
  in sqlite3/eval
  in _thunk [test.janet] (tailcall) on line 4, column 1

It should be possible to quote SQLite identifiers with any of "" `` [] for reference see: https://www.sqlite.org/lang_keywords.html

None of which appear to work.

Opening the same DB in the SQLite command line client and executing INSERT INTO customers (id, "first-name") VALUES(12345, 'John');

Works as expected.

shofetim avatar Jun 23 '23 21:06 shofetim