Replies: 1 comment
-
sorry for the confusion. it turned out that my postgres database was not initialized on UTF8. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
I'm encountering a
Wide character in subroutine entry
exception when trying to update a PostgreSQL table usingMojo::Pg
. The error seems to be triggered when the JSON payload for the update contains non-ASCII characters.Environment
The Code
I have a generic
PUT
route that takes a table name, primary key, and JSON data to perform an update. Here is a simplified version of the route handler:How to Reproduce
The issue occurs when I send a
PUT
request with a JSON payload containing wide characters. Specifically, the followingcontent
value, which ends with an "en dash" (–
, U+2013), causes the error.Payload that causes the error:
The Exception
When the route is hit with the payload above, I get this exact error:
My Analysis
It appears that
Mojo::JSON
correctly decodes the incoming request into a Perl string with the UTF-8 flag enabled. However, when this data is passed toMojo::Pg
'supdate
method, it seems to trigger this low-level warning which is escalated to an exception byeval
. If I remove the trailing–
character, the update succeeds without any issues.My Question
What is the correct way to handle UTF-8 data for database updates with
Mojo::Pg
? Am I missing a configuration step, either in my database connection string or in the application itself, to ensure all character data is properly encoded before being passed to the database?Thanks in advance for any help or guidance
Beta Was this translation helpful? Give feedback.
All reactions