Skip to content

Pattern match comparisons and generate PostgreSQL row value comparisons #2111

Description

@roji

PG supports (x, y) > (1, 2), which is the same as x > 1 || x == 1 && y > 2. We can pattern-match the latter and simplify it to the former.

For background, this is particularly useful for keyset pagination with multiple columns.

Not sure if the simplification has actual benefits beyond prettier SQL - but this is a weekend project for playing around with expression trees :)

Activity

  1. added this to the 7.0.0 milestone on Nov 20, 2021
  2. self-assigned this
    on Nov 20, 2021
  3. added a commit that references this issue on Nov 20, 2021
    33e4318
  4. added a commit that references this issue on Nov 20, 2021
    423cc58
  5. roji commented on Nov 25, 2021

    @roji
    MemberAuthor

    Assuming we do something in dotnet/efcore#26822, this should be reverted.

  6. reopened this on Nov 25, 2021
  7. roji commented on Jan 13, 2022

    @roji
    MemberAuthor

    I am reverting this. As per dotnet/efcore#26822 (comment), the right way for users to specify this is via C# tuple syntax - even if that isn't supported today (except maybe via explicit new ValueTuple(..)). The pattern matching approach here will probably miss various tree shapes, and if it's released it would be problematic to remove it later.

  8. removed this from the 7.0.0 milestone on Jan 13, 2022
  9. roji commented on May 4, 2022

    @roji
    MemberAuthor

    Note: #2349 represents a better approach to this.

  10. added theissue type on Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions