OnConflict implementation for SQLite provider uses wrong feature of SQLite

オープン
#796 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
fsharp, sqlite
領域
databases

調査の方向性

Issue にはファイルやテストが記載されていないため、まず SQLite provider の現在の OnConflict 実装を特定し、リンクされている SQLite の ON CONFLICT および UPSERT のドキュメントを読んでください。他のサポート対象 provider の動作と、報告されている NOT NULL のケースを比較してください。選択した SQLite の動作、またはその文書化された警告について合意し、実装したうえで、後方互換性を考慮できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

sqlite

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:

  1. Fix SQLProvider implementation to use proper UPSERTS for SQLite, probably adding a configuration toggle somewhere to enable backward compatibility.
  2. 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.

主要言語
F#
スター
627
フォーク
147
平均マージ
2時間 2分
マージ済み PR(30日)
1

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

fsprojects/SQLProvider のほかの issue

fsprojects/SQLProvider の issue をすべて見る

似ている issue

Databases の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。