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

Using compound fields in an IN clause #397

Open
chris-martin opened this issue Aug 3, 2024 · 2 comments
Open

Using compound fields in an IN clause #397

chris-martin opened this issue Aug 3, 2024 · 2 comments

Comments

@chris-martin
Copy link

chris-martin commented Aug 3, 2024

Does esqueleto offer a way to use compound fields in an IN clause? e.g.

SELECT * FROM table_name WHERE (a, b) IN (...);

One would want to write

where_ $ (entity ^. EntityA, entity ^. EntityB) `in_` valList ___

But of course this is not correct, as the left-hand side has type (SqlExpr (Value a), SqlExpr (Value b)) whereas we need SqlExpr (Value (a, b)). It seems to me naively that such a function ought to be possible to define and add amongst the "normal stuff" utilities.

@parsonsmatt
Copy link
Collaborator

I would be happy to support this - it would be useful for a lot of things.

@belevy
Copy link
Collaborator

belevy commented Aug 19, 2024

Is this syntax supported by multiple databases or just psql? It would require better support for row values as I believe it is essentially syntactic sugar over arrays of rows in postgres.

As a workaround you could always use a correlated sub query that selects from values, it's not ideal for sure but it might solve an immediate problem.

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

No branches or pull requests

3 participants