-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PG::UntranslatableCharacter: ERROR #155
Comments
Hi! Can you please provide your table schema (which columns of which types) and example of data you're trying to insert? This may be Ruby script with migration class, or raw SQL |
It is in a JSON field, I think it is an issue with the data in the JSON field (that I got from Google Places API). I think user reviews are the issue. I tried to update to ignore the column but it is still failing on the column. |
Null bytes are not supported and will not be supported in PostgreSQL JSONB datatype. See this thread for details: https://www.postgresql.org/message-id/8239.1500489054%40sss.pgh.pa.us You can strip it from the input strings with SQL spells like this: https://dba.stackexchange.com/a/120718/61198 regexp_replace(stringWithNull, '\\u0000', '', 'g') |
I think, this line is failing: We try to convert to JSONB first and remove the ignored columns after that. I think, that could be solved by filtering before conversion. That would make ignoring the column work. |
I guess, we need to do that in Ruby before hitting the DB (since the actual failure is happening within the Logidze trigger function). |
Okay, as a work around I disabled versioning for this update, because I am doing raw SQL in this case, not using Active Record I used this to do so: Line 40 in 4b17b00
|
Curious, how do you do that? You are not using Active Record? I've tried to reproduce this exception with AR, and found that it catches the problem itself: User.where(id: user.id).update_all("name = 'Hip-\u0000Hop'")
=> ArgumentError: string contains null byte |
Tell us about your environment
Ruby Version: ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]
Rails Version: 5.0.6
PostgreSQL Version: 9.6.12
Logidze Version: 0.12.0
What did you do?
Ran a bulk update SQL.
What did you expect to happen?
Records to update.
What actually happened?
The text was updated successfully, but these errors were encountered: