sqlite3
sqlite3 copied to clipboard
How to quote SQLite identifiers
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.