insert with InferModel not working
Hey, playing with Drizzle, like it a lot but I am having an issue where I inferred the model of a schema as
Here is the table schema (sqlite):
type NewUser = InferModel<typeof Users, "insert">;
and try to insert. It doesn't give an error, simply does nothing. In my app I have it do many different selects so I know the schema is fine and everything is connected and working. Yet when I execute this insert nothing is added to the db.Here is the table schema (sqlite):
3 Replies
Little bit of an update, drizzle won't write to the table at all. It can read it but not write. I removed the timestamp fields it still won't work. The only thing left to try is to remove the autoIncrement attribute
The Studio app can write to the db
Its not permissions related, gave everyone/thing permission to read/write
Think this is a bug in drizzle itself at this point
had to add .run() to the end of the inserts and it works now
https://github.com/drizzle-team/drizzle-orm/issues/815
GitHub
[BUG]: Undocumented - SQLite requires
.run()
to commit inserts · ...What version of drizzle-orm are you using? 0.27.0 What version of drizzle-kit are you using? 0.19.2 Describe the Bug Running an .insert while using SQLite3 (via better-sqlite3) doesn't do anyth...
- inserts won't run or produce errors if you don't include .run()
- inserts won't return data if you don't include .all()
- inserts won't run if they don't include returning data and you called it with .all() instead of .run()