Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullable DateTime throwing exception #66

Open
Blener opened this issue Sep 18, 2021 · 0 comments
Open

Nullable DateTime throwing exception #66

Blener opened this issue Sep 18, 2021 · 0 comments

Comments

@Blener
Copy link

Blener commented Sep 18, 2021

Hi @Zaid-Ajaj
Nullable DateTime is throwing when trying to read from the database. When inserting the value in the database, the JToken used is StartObject, but when reading it expects DateTime, that throws an exception.

image

These are the test cases:

testCase "Documents with Nullable DateTime != null can be used" <| fun _ ->
            useDatabase mapper<| fun db ->
                let docs = db.GetCollection<RecNullableDateTime>()
                let date = Nullable DateTime.MinValue
                docs.Insert ({ Id = 1; Date = date }) |> ignore
                docs.FindAll()
                |> Seq.tryHead
                |> function
                    | None -> fail()
                    | Some doc ->
                        match doc.Id, doc.Date with
                        | 1, date -> pass()
                        | _ -> fail()
                        
        testCase "Documents with Nullable DateTime = null can be used" <| fun _ ->
            useDatabase mapper<| fun db ->
                let docs = db.GetCollection<RecNullableDateTime>()
                let date = Nullable()
                docs.Insert ({ Id = 1; Date = date }) |> ignore
                docs.FindAll()
                |> Seq.tryHead
                |> function
                    | None -> fail()
                    | Some doc ->
                        match doc.Id, doc.Date with
                        | 1, date -> pass()
                        | _ -> fail()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant