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
awaitdb` update example set example_object = v.example_object::jsonb, from (values ${db(valuesArray)}) as v ( example_object ) where example.identifier = v.identifier;`;
example_object in this case is an object in my typescript code. However, if I try to insert it this way, it complains that it is an [object Object] and can't parse it. On the other hand, if I don't include the jsonb cast, it complains that it just text. Can someone please help me resolve this issue? As it is very mission critical.
awaitdb` update example set example_object = v.example_object::jsonb, from (values ${db(valuesArray)}) as v ( example_object ) where example.identifier = v.identifier;`;
example_object in this case is an object in my typescript code. However, if I try to insert it this way, it complains that it is an [object Object] and can't parse it. On the other hand, if I don't include the jsonb cast, it complains that it just text. Can someone please help me resolve this issue? As it is very mission critical.
Ran into this issue recently as well. Take into consideration how Postgres handles object serialization. Passing an object gets converted to a string representation [object Object]. You need to explicitly serialize the object to JSON before passing it to the query:
await db`
update example
set
example_object = v.example_object::jsonb
from (values ${db(valuesArray.map(v => ({ ...v, example_object: JSON.stringify(v.example_object) })))}) as v (
example_object
)
where example.identifier = v.identifier;
`;
Activity
henryzhang03 commentedon Dec 25, 2024
hello? Bumping this
robahtou commentedon Feb 2, 2025
Ran into this issue recently as well. Take into consideration how Postgres handles object serialization. Passing an object gets converted to a string representation
[object Object]. You need to explicitly serialize the object to JSON before passing it to the query:v4