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
{{ message }}
Repository navigation
Postgres: JSONB sub columns can't make as JSONB #10599
dialect: postgresFor issues and PRs. Things that involve PostgreSQL (and do not involve all dialects).type: featureDEPRECATED: replace with the "feature" issue type
@papb
This issue is similar to #11671 but not duplicated.
My opinion is(regardless of the above issue) that when accessing JSONB object fields using nested key in sequelize, It needs to branch the operator to return TEXT type(->> or #>>) or JSONB type(-> or #>) depending on the additional operator.
In this case, like operator needs text type as left operand type
so, query should be
SELECT*FROM db AS"DB"WHERE"DB"."foo"#>> '{bar}' like 'z%'
case3(uncertain)
db.findAll(where: {foo: {bar: 'zoo'}})
Equal is uncertain. because both JSONB type and TEXT type can use equal(=) operator.
More discussion is needed in this case.
To use sequelize more effectively with PostgreSQL, it need the above features.
And could you please make options for choose ('#>', '#>>') or ('->', '->>') for accessing JSONB object fields using nested key. Indexes created using one operator do not interoperate with indexes created using the other operator.
You can still use the previous text value by writing this:
User.findAll(where: {foo: {// :unquote is a modifier that "unquotes" JSON.// It's equivalent to json_unquote in most dialects, // or the #>> and ->> operators in postgres)// The resulting value is TEXT, not JSON'bar:unquote': {[Op.like]: 'z%'}}})
dialect: postgresFor issues and PRs. Things that involve PostgreSQL (and do not involve all dialects).type: featureDEPRECATED: replace with the "feature" issue type
Activity
stale commentedon Jun 20, 2019
papb commentedon Jan 15, 2020
Related: #11671
papb commentedon Jan 15, 2020
Actually, do you agree this a duplicate of #11671? Or is there something different?
haracejacob commentedon Jan 15, 2020
@papb
This issue is similar to #11671 but not duplicated.
My opinion is(regardless of the above issue) that when accessing JSONB object fields using nested key in sequelize, It needs to branch the operator to return TEXT type(
->>or#>>) or JSONB type(->or#>) depending on the additional operator.case(jsonb)
In this case, contains(
@>) operator needs jsonb type as left operand typeso, query should be
case2(text)
In this case, like operator needs text type as left operand type
so, query should be
case3(uncertain)
Equal is uncertain. because both JSONB type and TEXT type can use equal(
=) operator.More discussion is needed in this case.
To use sequelize more effectively with PostgreSQL, it need the above features.
And could you please make options for choose ('#>', '#>>') or ('->', '->>') for accessing JSONB object fields using nested key. Indexes created using one operator do not interoperate with indexes created using the other operator.
papb commentedon Jan 16, 2020
Thanks!
Please open a PR, that would be great!
ephys commentedon Feb 25, 2023
#15598 implements this. The JSON extraction syntax now produces JSON instead of text, so this should just work:
You can still use the previous text value by writing this: