drizzle-team / drizzle-team/drizzle-orm
[FEATURE]: INSERT OR REPLACE INTO for SQLite
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Feature hasn't been suggested before.
- [x] I have verified this feature I'm about to request hasn't been suggested before.
### Describe the enhancement you want to request
SQLite supports `INSERT` queries that begin as `INSERT OR REPLACE INTO` (see https://www.sqlite.org/lang_insert.html).
This causes SQLite to insert any rows that are new, or entirely delete and replace any rows present in the values to insert which already exist in the database by their primary keys.
Drizzle does support `onConflictDoUpdate`, however this is not quite the same thing:
* You have to manually specify every column that gets updated
* Only the columns that are being inserted are updated --- e.g. if you have some nullable columns which aren't present in the insert but are present in the existing row, then INSERT OR REPLACE INTO will set those to null (as it replaces the whole row), whereas ON CONFLICT UPDATE will leave them with the existing values
Would it be possible to consider a `.orReplace()` addition to the SQLite Query Builder which simply changes the initial `INSERT INTO` to `INSERT OR REPLACE INTO`?
Contributor guide
Assessment
This issue has not been assessed yet.