JordanMarr / SqlHydra

SqlHydra is a suite of NuGet packages for working with databases in F# including code generation tools and query expressions.
MIT License
212 stars 20 forks source link

Make a selected column from a leftJoined table option with `Some` #71

Open JordanMarr opened 7 months ago

JordanMarr commented 7 months ago

Should be able to make a selected column from a leftJoined table optional by wrapping it with Some.

For example:

    let! results = 
        selectTask HydraReader.Read (Create openContext)  {
            for o in Sales.SalesOrderHeader do
            leftJoin sr in Sales.SalesOrderHeaderSalesReason on (o.SalesOrderID = sr.Value.SalesOrderID)
            leftJoin r in Sales.SalesReason on (sr.Value.SalesReasonID = r.Value.SalesReasonID)
            where (isNullValue r.Value.Name)
            select (o.SalesOrderID, Some r.Value.ReasonType, Some r.Value.Name)
            take 10
        }

In the example above, the SalesReason table is optional because it is left joined. We should be able to wrap these individually selected columns with Some so that they are of option types.

Currently, v2.2.0 where expression parser fails when wrapping selected columns with Some.