tomjaguarpaw / haskell-opaleye

Other
599 stars 115 forks source link

Fixes for invalid SQL generated in WITH queries #572

Closed shane-circuithub closed 9 months ago

shane-circuithub commented 9 months ago

This PR contains two fixes pertaining to WITH queries. The first wraps an otherwise pointless SELECT * FROM around WITH queries to workaround PostgreSQL's arbitrary rejection of WITH foo AS (_) WITH bar AS (_) _ as invalid syntax. The second fixes a more serious issue whereby withExplicit is missing a Rebind and can generate a "valid" query that silently produces incorrect results.

tomjaguarpaw commented 9 months ago

Thanks! Can you also add tests that fail before this PR and pass after it?

shane-circuithub commented 9 months ago

I've added failing tests before the commits that subsequently fix them.

tomjaguarpaw commented 9 months ago

I should probably add with to the property tests. They ought to have caught this.

Thanks @duairc!

tomjaguarpaw commented 9 months ago

Released as https://hackage.haskell.org/package/opaleye-0.10.1.1, and deprecated 0.10.1.0.