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

Support for json style added - Postgres 14 #547

Open
avelino opened this issue Jun 3, 2021 · 0 comments
Open

Support for json style added - Postgres 14 #547

avelino opened this issue Jun 3, 2021 · 0 comments
Labels

Comments

@avelino
Copy link
Member

avelino commented Jun 3, 2021

In Postgres 13 and early if you wanted to find all medium shirts that are neon yellow you write some query:

SELECT *
FROM shirts
WHERE details->'attributes'->>'color' = 'neon yellow'
  AND details->'attributes'->>'size' = 'medium';

That use of -> and ->> while I'm familiar with it and recall, also felt painful. You essentially had two different operators, one to traverse the JSON document -> and then you'd add an extra > to extract the value as text.

In Postgres 14 though:

SELECT *
FROM shirts 
WHERE details['attributes']['color'] = '"neon yellow"'
  AND details['attributes']['size'] = '"medium"'

Note the use of the quotation marks: Postgres expects for you to use a JSON-style string when using it as a comparison using the subscripting method.

Implementation

We have to support the other versions, when the user uses the new style and Postgres old version we have to transcribe

@avelino avelino added enhancement feature New fetures product/api-server REST API Server labels Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant