Replies: 4 comments 1 reply
-
The correct way to diagnose query-generated queries is to take the final query and execute it in pgAdmin. Then see what SQL change is needed to make the query pass. Publish the results here, then I can advise how to change your code to produce that correct query. In the meantime, I can only guess your SQL type casting is incorrect. Also, this code: new pgp.helpers.Column({ name: 'contacts', mod: ':json' }) can be reduced to just a string - |
Beta Was this translation helpful? Give feedback.
-
Thanks! |
Beta Was this translation helpful? Give feedback.
-
You didn't publish the issue you found, or the solution you used. How am I to advise you then? Not sure what better solution you search, given the lack of detail, but Column supports type casting, as |
Beta Was this translation helpful? Give feedback.
-
I see. const columns = new pgp.helpers.ColumnSet([
...Object.keys(omit(request.body, 'contacts')),
new pgp.helpers.Column({ name: 'contacts', mod: ':json' })
])
db.one(pgp.helpers.update(request.body, columns, 'users') + ' where...')); Currently, I need to const columns = new pgp.helpers.ColumnSet({
...request.body,
new pgp.helpers.Column({ name: 'contacts', mod: ':json' })
})
db.one(pgp.helpers.update(request.body, columns, 'users') + ' where...')); |
Beta Was this translation helpful? Give feedback.
-
One of our PATCH endpoints has the following body:
When trying to use the
update
helper like this:We get:
Because
contacts
field is fromjson
type in PG.This require us to use ColumnSet like this:
I want to mix "simple" values with Column:
Perhaps there is a more effective solution than the one I found?
Beta Was this translation helpful? Give feedback.
All reactions