Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid rebinding PrimExprs that were created in the Aggregator itself #586

Merged
merged 3 commits into from
Feb 6, 2024

Conversation

tomjaguarpaw
Copy link
Owner

No description provided.

@tomjaguarpaw tomjaguarpaw changed the title WIP Avoid rebinding PrimExprs that were created in the Aggregator itself Avoid rebinding PrimExprs that were created in the Aggregator itself Jan 21, 2024
@tomjaguarpaw
Copy link
Owner Author

I'd like to understand why @duairc made the change circuithub/rel8#305 (comment), because I'm concerned that this PR has an impact I'm not aware of. Besides that, this PR is ready to go.

It's redundant because we only need to rebind PrimExprs that came from
a lateral subquery.  As explained at [1], rather than carefully
analysing which PrimExprs came from a lateral subquery we can just
rebind everything.  A previous commit [2] changed things so that
everything mentioned in aggregator order expressions is rebound.
Instead we probably should have done what this commit does, that is,
added an Unpackspec constraint to aggregate.

Fixes #587

This is a simpler approach to resolving the issues discussed at

* #585
* #578

This still suffers from the problem described at:

#578 (comment)

i.e. if we find a way of duplicating field names, such as

    O.asc (\x -> snd x O..++ snd x)

then we can still create crashing queries.  The benefit of this
comment is that there is a way of generating non-crashing queries!

[1] https://github.com/tomjaguarpaw/haskell-opaleye/blob/52a4063188dd617ff91050dc0f2e27fc0570633c/src/Opaleye/Internal/Aggregate.hs#L111-L114

[2] d848317, part of
    #576
@tomjaguarpaw
Copy link
Owner Author

Still hoping I'll hear back from @duairc about this before merge.

@shane-circuithub
Copy link
Contributor

Hey @tomjaguarpaw, sorry I took so long to get back to you. Yes, the changes you see on the Rel8 side are all just to account for the additional Table Expr constraint we now incur. countRows doesn't really care about the specific layout of columns though which is why we just map const true over the input query.

@tomjaguarpaw tomjaguarpaw merged commit 3ae95d4 into master Feb 6, 2024
12 checks passed
@tomjaguarpaw tomjaguarpaw deleted the aggregate branch February 6, 2024 17:57
@tomjaguarpaw
Copy link
Owner Author

Thanks, that's OK. Released at https://hackage.haskell.org/package/opaleye-0.10.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants