You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know why this feature of SQLite was chosen back in the day. Even though ON CONFLICT was available in SQLite for decades and UPSERT was only added at 2018, when this feature was added to SQLProvider UPSERT had already been available.
Nevertheless, I think it's quite confusing. Behavior of this feature for SQLite is different from other supported providers. I suppose we have two options:
Fix SQLProvider implementation to use proper UPSERTS for SQLite, probably adding a configuration toggle somewhere to enable backward compatibility.
Add a warning to the docs stating that usage of OnConflict feature for SQLite has a broader scope than one could expect.
In my case, I set OnConflict.Ignore to one of my tables, expecting it to only deal with primary key violations.
In the meantime, I had an error in my app, one of the non-null column hasn't been filled, but SQLite hasn't complained about it and just silently refused to insert a row into a table. At the end, by debugging raw sql I was able to figure things out.
The text was updated successfully, but these errors were encountered:
gbtb
changed the title
OnConflict implementation for SQLite backend uses wrong feature of SQLite
OnConflict implementation for SQLite provider uses wrong feature of SQLite
Jul 9, 2023
With old .NET Framework and 32 bit IDEs, SQLite used to be the easiest database, one file, no configuration and always working. But then came .NET Core and 64 bit vs 32 bit, and all kind of driver issues.
As I come from finance background, my default go to solution has always been transactions. I've never needed OnConflict.
I know people have different use cases and some think they'll be able to gain bit more performance boost and scalability by not using transaction, with then tolerating some level incorrect program state, or handling with issues manually. Which is fine by me too.
So sure, if you feel it helps your usability, if you make PR, I'll probably accept it.
Describe the bug
I think that implementation of OnConflict uses wrong feature of SQLite.
If you check the SQLite docs mentioned in https://fsprojects.github.io/SQLProvider/core/crud.html#OnConflict you'll see that "ON CONFLICT clause applies to UNIQUE, NOT NULL, CHECK, and PRIMARY KEY constraints".
SQLite has another feature, specifically for UPSERTs - https://sqlite.org/lang_upsert.html . Docs for that feature mention that "UPSERT in SQLite follows the syntax established by PostgreSQL, with generalizations."
I don't know why this feature of SQLite was chosen back in the day. Even though ON CONFLICT was available in SQLite for decades and UPSERT was only added at 2018, when this feature was added to SQLProvider UPSERT had already been available.
Nevertheless, I think it's quite confusing. Behavior of this feature for SQLite is different from other supported providers. I suppose we have two options:
In my case, I set OnConflict.Ignore to one of my tables, expecting it to only deal with primary key violations.
In the meantime, I had an error in my app, one of the non-null column hasn't been filled, but SQLite hasn't complained about it and just silently refused to insert a row into a table. At the end, by debugging raw sql I was able to figure things out.
The text was updated successfully, but these errors were encountered: