IsWriteable not working on Key columns
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
Hướng nghiên cứu
Bắt đầu với src/Dapper.Contrib/SqlMapperExtensions.cs tại dòng được liên kết, khoảng dòng 438, và tái hiện trường hợp bảng chỉ có một cột bằng mô hình C# được hiển thị. Theo dõi cách các trường khóa và các trường IsWriteable được chọn cho các thao tác cập nhật, sau đó xác định hành vi mong đợi đối với mệnh đề SET rỗng và việc ghi vào các cột khóa. Hoàn tất khi hành vi cho trường hợp được báo cáo này đã được xác định và bao quát.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
So here I sit and switch from EF to Dapper because CodeFirst with several thousands of AddOrUpdate in Seed was getting a bit irritating when debugging thanks to our beloved Change Tracking... usual story of people switching to Dapper...
... and then I encountered this:
public class WhoInTarnationThoughtThatDozensOfTablesWithOneColumnIsGoodIdea
{
[Key]
[Dapper.Contrib.Extensions.ExplicitKey] //dapper fails to detect his as Key automatically :(
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[StringLength(250)]
public string SomethingNotNamedIdToMakeMyDayWorse { get; set; }
}
So first issue was "Entity must have at least one [Key] or [ExplicitKey] property ", but there are already tickets for it and can be solved with that silly ExplicitKey attribute. No biggie. Build, start, make a tea while this overweight abomination of a project starts up and munches through hundred migrations... oh different exception.
System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'where'...
Here's the culprit:
https://github.com/DapperLib/Dapper.Contrib/blob/cf24f6bdc577b1e071c3764ddfb2cf3382531405/src/Dapper.Contrib/SqlMapperExtensions.cs#L438
(You won't get exception if you have non-key fields in table. Single-column table is a must.)
So there are 3 problems (aside of database design I got stuck with...):
- Key column detection sucks, but thats because Dapper isn't checking EF attributes and can be fixed with ExplicitKey attribute.
- Invalid SQL when there is no "non-id properties" as SET clause ends up empty. Would be nice to have explicit exception here instead of raw error.
- Due to offending line
[IsWriteable(true)]is not working on Key columns like[DatabaseGenerated(DatabaseGeneratedOption.None)]does in EF, because all Key columns are excluded from list of updateable fields.
So I'd like to ask, before wasting half an hour to fix it, IsWriteable vs ExplicitKey a feature or a bug?
- Ngôn ngữ chính
- C#
- Star
- 293
- Fork
- 108
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của DapperLib/Dapper.Contrib
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
DapperLib/Dapper.Contrib#22 · 2 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 42/100
DapperLib/Dapper.Contrib#174 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
DapperLib/Dapper.Contrib#173 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 10/100
DapperLib/Dapper.Contrib#172 · 1 bình luận · 4 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
DapperLib/Dapper.Contrib#169 ·
Tất cả issue của DapperLib/Dapper.Contrib
Issue tương tự
-
WPF: each page's `Title` overwrites the window title, and returning to a page does not restore itĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
agentic-workflows area/Docs partner/agentic-workflows
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
jamesmontemagno/tiny-clips#378 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
go 🏃 testing 🧪
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
valkey-io/valkey-glide#7239 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
SubtitleEdit/subtitleedit#15462 ·
Maintainer thường phản hồi trong vòng 1 ngày