Hi! I have a simple table in an app I am developin...
# squarelibraries
o
Hi! I have a simple table in an app I am developing using SQLDelight. I was trying to implement a simple upsert, however it doesn't work:
Copy code
CREATE TABLE MQTT(topic TEXT PRIMARY KEY, value TEST);
Copy code
upsertMQTTValue:
INSERT INTO MQTT(topic, value) VALUES(?,?)
ON CONFLICT(topic) DO UPDATE SET value=excluded.value
However, when I run the program, the following issue occurs:
Copy code
(1) ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint in [...]
I basically copied the instruction from the SQLite documentation, as far as I understand it should work - any ideas why it doesn't?
g
🤔 Can only suggest that the
MQTT
table was not created with a primary key e.g
CREATE TABLE MQTT(topic TEXT, value TEST);
as that would cause the error - double check that your sqlite database does indeed have your latest schema as the error is raised when the insert is made.