You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
In Postgres 13 and early if you wanted to find all medium shirts that are neon yellow you write some query:
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:
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
The text was updated successfully, but these errors were encountered: