Describe the bug
If I create following simple key-value pairs Postgresql database:
begin;
create table "Test" (
"ID" int4 generated by default as identity primary key,
"Value" int4 null
);
insert into "Test" ("ID", "Value") values
(0, 1),
(1, 1);
commit;
and run following code:
module Main
open System.Threading.Tasks
open FSharp.Data.Sql
open FSharp.Data.Sql.Common
[<Literal>]
let private resolutionPath = __SOURCE_DIRECTORY__ + "/obj/db-libs/"
[<Literal>]
let private connectionString = "Host=localhost;Port=5433;Database=test;User ID=test;Password=test"
type postgres =
SqlDataProvider<
DatabaseVendor = DatabaseProviderTypes.POSTGRESQL,
ResolutionPath = resolutionPath,
ConnectionString = connectionString,
UseOptionTypes = NullableColumnType.OPTION
>
let update (key : int) (value : int option) = task {
let ctx = postgres.GetDataContext connectionString
let row = ctx.Public.Test.Create()
row.Id <- key
row.Value <- value
row.OnConflict <- OnConflict.Update
do! ctx.SubmitUpdatesAsync()
}
[<EntryPoint>]
let main args =
Task.WaitAll(task {
try
do! update 0 None
with ex ->
printfn "Exception: %A" ex
})
0
I'd expect Value in the first row to be changed to NULL, but in fact nothing happens. Same goes for NullableColumnType.VALUE_OPTION and ValueNone. Something like update 0 (Some 69) and update 2 None work as expected.
Tested with SQLProvider 1.3.23 from nuget package.
Additional contextfsproj and docker-compose.yaml for reproduction:
Hi!
Describe the bug If I create following simple key-value pairs Postgresql database:
and run following code:
I'd expect
Value
in the first row to be changed toNULL
, but in fact nothing happens. Same goes forNullableColumnType.VALUE_OPTION
andValueNone
. Something likeupdate 0 (Some 69)
andupdate 2 None
work as expected.Tested with
SQLProvider
1.3.23 from nuget package.Additional context
fsproj
anddocker-compose.yaml
for reproduction:Complete example can be found here.