Correctly parse a top level json string as a value to a query param
See: https://discord.com/channels/933657521581858818/1318643604528431194
I just ran into this issue and stumbled on the discord thread above. Adding this error message here just in case anyone else searches the github issues for this problem.
Uncaught error: invalid input syntax for type json
If you're trying to use the syncShapeToTable API the workaround is to supply map a mapColumns function that translates the top level json string into an object. Something like this:
"Hello world" -> "{ value: "Hello world"}
mapColumns: (changes: any) => {
const { value: newValues } = changes;
return {
value: {value: newValues.value},
};
},
Then you can map the object as needed in application code.
In my case, the jsonb column was named value so that's why value is a little overloaded in the example above. 😅
This bug also breaks the useCopy option on the syncShapeToTable API. It throws this error message in combination with the one listed above.
Uncaught error: current transaction is aborted, commands ignored until end of transaction block