-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add underscore equality operator to filter using keys in the request body #2405
base: main
Are you sure you want to change the base?
Conversation
data BodyOperator | ||
= BodyOpEqual | ||
deriving Eq |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to have _eq
as a special case for now, we can add underscore versions of the other operators later.
One question though, will this work for DELETE and RPC as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not work for DELETE in the PR because the body is ignored, but it should work with the changes in #2355 (unless those changes are done here to avoid breaking changes in the future).
RPC are a different story in which the filter of the result set is done outside of the pgrst_source
CTE in the QueryBuilder.hs file, so it won't work out of the box unless the filter is done inside the CTE (may break some things). The resulting query looks something like:
WITH pgrst_source AS (
WITH pgrst_payload AS (...).
pgrst_body AS (...),
pgrst_args AS (...)
SELECT ... -- The WHERE should be done here for the filter to get the data from pgrst_body
)
SELECT ...
FROM
(SELECT "table".*
FROM "pgrst_source" AS "table"
WHERE "table"."id" = "pgrst_recordset_body"."id") _postgrest_t -- it is done outside instead, which gives an error
15d5735
to
76b5a1e
Compare
Wait, the comment in #2125 (comment) says:
With the implementation in this PR, the ability to do column to column matches will be lost, right? |
Yes. It was one of the reasons I turned this into a draft for now. It should use a syntax like |
WIP - Needs more discussion
Using this idea #2125 (comment), the underscore operators will filter using the keys in the body. This PR implements the following:
_eq
operator to verify for equality with items in the body