Dzoukr / Dapper.FSharp

Lightweight F# extension for StackOverflow Dapper with support for MSSQL, MySQL, PostgreSQL, and SQLite
MIT License
365 stars 35 forks source link

IsIn filter doesnt support optional values #46

Closed tforkmann closed 2 years ago

tforkmann commented 2 years ago

Hi there,

we have some optional table elements and we want to use the IsIn filter on them.

In our query is concerncostcentrals.Zuordnung a optional string parameter

let branches = [Some "EZ"; Some "BGA"; Some "KW"]
let! data =
        select {
            for concerncostcentrals in enmsSichtKstKonzern do
            where ( isIn (concerncostcentrals.Zuordnung) branches )
        }
        |> conn.SelectAsync<dbo.EnmsSicht_KstKonzern>

This query the will fail with an No mapping exists from object type Microsoft.FSharp.Core.FSharpOption1[[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] to a known managed provider native type.` exception

Any idea how we can get that working?

Thanks in advance!

Dzoukr commented 2 years ago

Just to be 💯 sure... Are you running Dapper.FSharp.OptionTypes.register()

JordanMarr commented 2 years ago

I will put a fix in version 3 which you can merge into master for a quick patch.

JordanMarr commented 2 years ago

It's odd.. I would expect that you would receive a "not implemented" exception for this, which is what I get.

tforkmann commented 2 years ago

I got that error before as well.

I think it depends where you put the optional tag. Can double check. But I’m pretty sure it’s failing in the not implemented area.

Jordan Marr @.***> schrieb am Mo. 13. Sept. 2021 um 15:07:

It's odd.. I would expect that you would receive a "not implemented" exception for this, which is what I get.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Dzoukr/Dapper.FSharp/issues/46#issuecomment-918492837, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7ZZ54ZBSFDZBYDMIOFZMTUBZDYNANCNFSM5D6KQ5HA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Tim Forkmann Haubachstr. 30 10585 Berlin 0151-15813418

JordanMarr commented 2 years ago

The fix is in. The supported syntax, at least for now, looks like this:

let branches = ["EZ"; "BGA"; "KW"]
let! data =
        select {
            for concerncostcentrals in enmsSichtKstKonzern do
            where (concerncostcentrals.Zuordnung.Value |=| branches)
        }
        |> conn.SelectAsync<dbo.EnmsSicht_KstKonzern>

Hopefully in the future it can also support the syntax you had.

tforkmann commented 2 years ago

Wow awesome! Thanks for the quick fix!!

Jordan Marr @.***> schrieb am Mo. 13. Sept. 2021 um 15:30:

The fix is in. The supported syntax, at least for now, looks like this:

let branches = ["EZ"; "BGA"; "KW"]let! data = select { for concerncostcentrals in enmsSichtKstKonzern do where (concerncostcentrals.Zuordnung.Value |=| branches) } |> conn.SelectAsync

Hopefully in the future it can also support the syntax you had.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Dzoukr/Dapper.FSharp/issues/46#issuecomment-918509711, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7ZZ53APT6DH6ZEPJBEAV3UBZGORANCNFSM5D6KQ5HA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Tim Forkmann Haubachstr. 30 10585 Berlin 0151-15813418

Dzoukr commented 2 years ago

Thanks @JordanMarr, merging now, will release a new version in a few minutes

Dzoukr commented 2 years ago

Released as v2.4.1

tforkmann commented 2 years ago

Merci guys! You are amazing!