Home > OS >  Why am I not able to query jsonb array in postgresql?
Why am I not able to query jsonb array in postgresql?

Time:12-28

In my jsonb column in the postgresql table. I can add any custom json in that jsonb column, so some keys might exists and some rows and might not in other. So, even though I have a key value pair of {"custom_json_field1221": ["13273235014770"]}. I'm not able to query this using

        custom_fields
from
        foo.jira_issues as issues
where
        ( custom_json_fields->'custom_json_field1221'  @> '"13273235014770"');

CodePudding user response:

The @> operator works on "objects", so you need to use an array on the right hand side as well:

custom_json_fields->'custom_json_field1221'  @> '["13273235014770"]'
  • Related