OnConflict implementation for SQLite provider uses wrong feature of SQLite

Đang mở
#796 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
fsharp, sqlite
Lĩnh vực
databases

Hướng nghiên cứu

Issue không nêu tệp hoặc test nào; hãy bắt đầu bằng cách xác định implementation hiện tại của OnConflict trong SQLite provider và đọc tài liệu SQLite được liên kết về ON CONFLICT và UPSERT. So sánh behavior với các provider được hỗ trợ khác và với trường hợp NOT NULL đã được báo cáo. Được xem là hoàn tất khi behavior SQLite được chọn hoặc cảnh báo được ghi lại về behavior đó đã được thống nhất và implement, đồng thời đã xem xét backward compatibility.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
F#
Star
627
Fork
147
Merge trung bình
2 giờ 2 phút
Pull request đã merge (30 ngày)
1

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của fsprojects/SQLProvider

Tất cả issue của fsprojects/SQLProvider

Issue tương tự

Thêm issue về Databases

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.