[SQL SERVER] Dealing with nulls values and timestamp columns during insert
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
- 25/100
Hướng nghiên cứu
Bắt đầu với đường dẫn SQL Server bằng cách sử dụng localCtx.Dbo.WriteStorages.Create(x.ColumnValues), sau đó xem xét cách các giá trị null và các cột timestamp được xử lý trong quá trình chèn. Hoàn thành khi quá trình đồng bộ có thể chèn các bản ghi này mà không thay thế null bằng DBNull.Value hoặc lọc thủ công các cột timestamp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
As an exercise I've ported a small console application that sync tables in SQL SERVER DB from C# EF to F# SQLProvider.
In C# I was able to do the following:
foreach (Type t in types)
{
List<object> remoteEntities = await remoteContext.Set(t).ToListAsync();
var localEntities = await localContext.Set(t).ToListAsync();
localContext.Set(t).RemoveRange(localEntities);
localContext.Set(t).AddRange(remoteEntities);
}
await localContext.SaveChangesAsync();
In F# It became something like this:
...deleting old entities...
remoteCtx.Dbo.WriteStorages |> Seq.map (fun x-> localCtx.Dbo.WriteStorages.Create(x.ColumnValues)) |> Seq.toList
Actual behavior
This approach was failing due to 2 errors:
-
null had to be replaced with
System.DBNull.Valueand it was producing errors like:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll: 'The parameterized query '(@param0 uniqueidentifier,@param1 datetime,@param2 nvarchar(14),' expects the parameter '@param3', which was not supplied.' -
should filter Timestamp column from ColumnValues because of errors like:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll: 'Cannot insert an explicit value into a timestamp column. Use INSERT with a column list to exclude the timestamp column, or insert a DEFAULT into the timestamp column.'
For EF It's working out-of-box, so maybe SQLProvider could also take care of these cases?
Known workarounds
Do the replacements mentioned above.
Related information
- SQL SERVER
- Windows
- .NET Runtime
- 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
- Đọ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 fsprojects/SQLProvider
-
enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
fsprojects/SQLProvider#872 · 2 bình luận ·
-
Repo Assist? Đang mởenhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 10/100
fsprojects/SQLProvider#870 · 1 bình luận ·
-
postgresql
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 58/100
fsprojects/SQLProvider#869 · 2 bình luận ·
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 42/100
fsprojects/SQLProvider#868 · 2 bình luận ·
-
sql server
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
fsprojects/SQLProvider#851 · 1 bình luận ·
Tất cả issue của fsprojects/SQLProvider
Issue tương tự
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
-
[BUG] A column whose default is the empty string is drawn in the ER diagram as having no default Đang mởbug database-provider good first issue hacktoberfest
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
libredb/libredb-studio#1030 · 6 bình luận ·
-
comp-datalake
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
ClickHouse/ClickHouse#121222 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
bug redshift
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100