Sorry if this isn’t the right place to ask, but I’...
# squarelibraries
f
Sorry if this isn’t the right place to ask, but I’m having some trouble with inserting a record without specifying an ID. My table&insert look like:
Copy code
CREATE TABLE Recipe (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    title TEXT NOT NULL,
    duration TEXT NOT NULL,
    difficulty TEXT NOT NULL,
    calories INTEGER AS Int NOT NULL
);

insert:
INSERT INTO Recipe (title, duration, difficulty, calories)
VALUES (?, ?, ?, ?);
now, when I call
recipeQueries.insert
, I get a
NOT NULL constraint failed: Recipe.id
.. I’ve been looking around SQLite docs as well, but still can’t figure it out..
e
new to sql syntax but I think that you need to make
id
NOT NULL
m
Yeah, in my existing usages of
AUTOINCREMENT
, I have it set as:
INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL