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

Fix Ignored `where` Clauses in `update` Queries #66

Closed devinlyons closed 8 months ago

devinlyons commented 8 months ago

This fixes a major bug that causes update statements to ignore where clauses in update queries that have multiple where clauses.

let query = 
    update {
        for c in sales.customer do
        set c.personid (Some 123)
        where (c.personid = Some 456) // <<-- this clause overwritten by the following `where`.
        where (c.customerid = 789) // <<-- this is the only clause that appears in the final query.
    }
devinlyons commented 8 months ago

@JordanMarr, I had some trouble with the unit tests. It might be worth running them yourself before merging this.

JordanMarr commented 8 months ago

Excellent work on identifying and fixing this issue. I hope this didn't lead to any production data problems for you. I verified that this doesn't affect the select and delete builders (as you probably did as well). I will make fixes to test as needed after the merge.

Thank you!

JordanMarr commented 8 months ago

New version published: https://www.nuget.org/packages/SqlHydra.Query/2.1.1

devinlyons commented 8 months ago

Thanks for the quick response on this.

devinlyons commented 8 months ago

@JordanMarr, the update package seems to depend on FSharp.Core 8.0.100-beta.23418.2. This is a prerelease package that I really don't want to use. Would you mind publishing a version that depends on FSharp.Core 7?

JordanMarr commented 8 months ago

Fixed here: https://www.nuget.org/packages/SqlHydra.Query/2.1.2

devinlyons commented 8 months ago

Confirmed. Thank you!