0

I use knex and objection.js with a postgresQL database. I updated knex from version 0.19.5 to 1.0.3 and part of one of my query stopped working. One of my table has a 'metadata' column, which is jsonb. The metadata object can contain a keyword property, which is an array of strings. I want to query for the presence of a word in that array.

Before:

   .where('Source.name', 'ilike', `%${search}%`)
   .orWhere('Attribution.normalizedName', 'ilike', `%${search}%`)
   .orWhere('Source.abstract', 'ilike', `%${search}%`)
   .orWhere('Source.description', 'ilike', `%${search}%`)
   .orWhereJsonSupersetOf('Source.metadata:keywords', [search])

This was working before I upgraded, but now I get an error saying that 'column Source.metadata:keywords does not exist'

I didn't see anything in the knex changelog that explained a breaking change there. (this was done with objection.js version 2.1.3)

Marie Pelletier
  • 417
  • 2
  • 4
  • 15
  • can you provide a sample of json data in that column? – M-Raw Mar 12 '22 at 12:29
  • Source.metadata would look like: { "publicationYear": 1980, "isbn": "12345...", "keywords": ["word1", "word2"] } It can contain other properties as well, but the keywords array is where I am having a problem. – Marie Pelletier Mar 14 '22 at 18:06

0 Answers0