Database error: "NOT NULL constraint failed"
Hi! Amazing extras for sqlite-mode.
I get the following error when adding a new row with +:
funcall-interactively: Database error: "NOT NULL constraint failed: <table>.<col>"
I can add a new row by hand using the sqlite CLI program. Is your code expecting something specific I am not doing or is my schema acting up?
Thanks.
Hey, hard to tell without more details. Can you share a sample db with the same or similar schema? Alternatively, if you set an edebug breakpoint on sqlite-mode-extras-add-row and step through the code, we can get an idea of what's going wrong.
Apologies for the late reply!
Here the sqlite schema:
sqlite> .schema
CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE locations (
id INTEGER PRIMARY KEY,
location TEXT NOT NULL
);
CREATE TABLE people (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
website TEXT UNIQUE,
email TEXT UNIQUE,
type TEXT NOT NULL,
location_id INTEGER,
contacted TEXT,
responded TEXT,
notes TEXT
,
FOREIGN KEY (location_id) REFERENCES locations(id)
);
Let me know what else I can do. I am trying to learn how to use edebug.
sqlite-mode-extras-add-row currently depends on inserting a new row with default values ("INSERT INTO people DEFAULT VALUES;") and fails with no default columns.
You can still use sqlite-mode-extras-compose-and-execute as a workaround.
We could consider prompting users for all non-default values or maybe providing generic ones that can be overriden post insertion like defaults work now.
All clear, and not a big deal. Indeed, I've been enjoying using sqlite-mode-extras-compose-and-execute meanwhile and will start use it also for inserting new rows. Thanks!