I'm having trouble with using the the 'ON CONFLICT' clause with a SQLite database. Example:
> (query-exec db "drop table if exists peers")
> (query-exec db "create table if not exists peers (name text)")
> (query-exec db "INSERT INTO peers ( name ) VALUES ($1)" "hqwt")
> (query-rows db "SELECT * FROM peers")
'(#("hqwt"))
> (query-exec db "INSERT INTO peers ( name ) VALUES ($1) ON CONFLICT DO NOTHING" "hqwt")
; query-exec: near "ON": syntax error
; error code: 1
; [,bt for context]
I thought maybe there was some issue with the column not being marked UNIQUE, so I did that. No effect:
> (query-exec db "drop table if exists peers")
> (query-exec db "create table if not exists peers (name text UNIQUE)")
> (query-exec db "INSERT INTO peers ( name ) VALUES ($1)" "hqwt")
> (query-exec db "INSERT INTO peers ( name ) VALUES ($1)" "hqwt")
; query-exec: abort due to constraint violation
; error code: 2067
; SQL: "INSERT INTO peers ( name ) VALUES ($1)"
; [,bt for context]
> (query-exec db "INSERT INTO peers ( name ) VALUES ($1) ON CONFLICT DO NOTHING" "hqwt")
; query-exec: near "ON": syntax error
; error code: 1
; [,bt for context]
I've been through the SQLite documentation on the INSERT statement multiple times, and that last statement sure looks syntactically valid to me. Furthermore, it works fine if I use it in the OSX 10.11.6 sqlite3 CLI client.
What am I missing?