Open RikvanToor opened 10 months ago
please add a test that would fail to work without this fix. As far as aliasing only on duplicates, how do we handle it with regular table joins?
please add a test that would fail to work without this fix. As far as aliasing only on duplicates, how do we handle it with regular table joins?
See https://github.com/bitemyapp/esqueleto/issues/372.
I'm pretty sure I've run into the same issue in our production app :)
Hello. :)
This PR fixes #372 by adding a fresh alias whenever a common table expression is used within a query.
As described in the issue, previously this Haskell code
would generated this SQL query
which is invalid. After this PR, it instead generates this SQL query:
I'm not 100% satisfied with this, as the aliasing is only required when a single CTE is used multiple times in a single query, but my PR applies the aliasing at all times. I was not sure how to check for such a situation from within the context of the
with
function, so perhaps this PR can serve as a conversation about that. Thanks a lot!After submitting your PR: