Open wuzzapcom opened 3 years ago
Ran into the same problem, did you find any workarounds? @wuzzapcom
Unfortunately, I didn’t
I seem to run into the same problem. I bisected this to commit 4a7d9870ef6a5a247ef532192988b01bf13cc110
When I revert this commit from the latest release this works again.
Does this solve your problem, too?
Description
I'm implementing bulk insert using
pq.CopyIn
feature. One of column isjsonb
type and it contain non-latin symbols, for example:This json can be inserted with regular
INSERT
. When I've tried to wrap the code withpq.CopyIn
, I got the following error:When I insert same json with latin-only strings, all works properly.
code example
what I want to see
Inserted successfully
what I get
Same code with
Payload{Title: "title"}
inserts successfully.Research
I've discovered that this issue happens because input in
pq.CopyIn
mode is encoded astext
using appendEncodedText. So cyrillic symbols are encoded like this:Apparently PostgreSQL does not accept such json and returns the error. This is the reason why no issue appears on same json with latin value of the field
title
.On the other hand I've checked how regular
INSERT
handle this case. It uses encode. So json is just not encoded withencodeBytea
.Are there any workarounds for this issue?