SQLProvider icon indicating copy to clipboard operation
SQLProvider copied to clipboard

Cannot negate Option.IsSome condition?

Open halcwb opened this issue 4 years ago • 2 comments
trafficstars

Is your feature request related to a problem? Please describe. I seem not to be able to negate a boolean Option.IsSome or a boolean Option.IsNone.

Also the error messaging of what is unsupported is not very clear.

Describe the solution you'd like

let ctx = DataContext.getDataContextWithLog()
query {
    for p in ctx.Dbo.Patients do
    where (not p.DischargeDate.IsSome)
//    where (p.DischargeDate.IsNone)
    select p
}
|> Seq.length

This code fails with:

System.Exception: Unsupported expression. Ensure all server-side objects won't have any .NET-operators/methods that can't be converted to SQL. The In and Not In operators only support the inline array syntax. Not(get_IsSome(p.GetColumnOption("DischargeDate"))) at Microsoft.FSharp.Linq.RuntimeHelpers.LeafExpressionConverter.EvaluateQuotation(FSharpExpr e) in F:\workspace_work\1\s\src\fsharp\FSharp.Core\Linq.fs:line 718 at Microsoft.FSharp.Linq.QueryModule.EvalNonNestedInner(CanEliminate canElim, FSharpExpr queryProducingSequence) in F:\workspace_work\1\s\src\fsharp\FSharp.Core\Query.fs:line 1823 at Microsoft.FSharp.Linq.QueryModule.clo@1926-15.Microsoft.FSharp.Linq.ForwardDeclarations.IQueryMethods.Execute[a,b](FSharpExpr`1 q) in F:\workspace_work\1\s\src\fsharp\FSharp.Core\Query.fs:line 1928 at <StartupCode$FSI_0035>.$FSI_0035.main@() Stopped due to error

Describe alternatives you've considered See commented code line above, which works.

halcwb avatar Apr 13 '21 10:04 halcwb

seems reasonable and easy addition

Thorium avatar Apr 13 '21 22:04 Thorium

This should work with the latest version.

Thorium avatar Jun 28 '21 08:06 Thorium