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

Query with `leftJoin` breaks in v2.5.0 #94

Closed stoft closed 2 weeks ago

stoft commented 2 weeks ago

The following leftJoin query works in v2.4.1 but generates an error in v2.5.0:

Query:

selectTask HydraReader.Read (Create openContext) {
    for i in insurance_policies do
        where (i.id = id)
        join ic in insurance_companies on (i.insurance_company_id = ic.id)
        leftJoin ip in insurance_policy_properties on (i.id = ip.Value.insurance_policy_id)
        select (i.id, ic.name, i.product_variant, i.insurance_type_id, ip)
})

Error:

System.NullReferenceException: Object reference not set to an instance of an object.

If we remove the leftJoin the query works. We're using Postgres (Npgsql.FSharp v5.7.0).

JordanMarr commented 2 weeks ago

There is a v2.5.1 patch released last month that may fix this. Please try it and let me know.

image
stoft commented 2 weeks ago

Sorry, we completely missed there was a 2.5.1. Which works. :)

JordanMarr commented 2 weeks ago

Btw, you can now pass openContext instead of Create openContext and it will implicitly convert it for you:

// Old

selectTask HydraReader.Read (Create openContext) {

// New

selectTask HydraReader.Read openContext {

Same with shared context:

// Old

selectTask HydraReader.Read (Shared ctx) {

// New

selectTask HydraReader.Read ctx {