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
SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type bytea
CONTEXT: unnamed portal parameter $5 = '...'
The payload contains an url. Upon json_encode, it will add backslashes to escape the uri e.g http:\/\/127.0.0.1:8080\/ which I guess somewhat invalid for bytea column. Removing the URL from the payload resolves the issue.
Version
Postgres 16.1
PHP 8.3
The text was updated successfully, but these errors were encountered:
In PostgreSQL, the BYTEA data type is designed to store binary data, such as images, sounds, and other raw byte sequences. The BYTEA type is intended for representing data in binary form, and inserting strings with backslashes may cause issues due to the intricacies of byte handling and escaping in SQL.
If you attempt to insert a string with backslashes directly into a BYTEA column, it can lead to confusion, as the backslash () in SQL is used for escaping special characters. Therefore, when inserting a string with backslashes, they should be properly escaped.
Example of a problematic string:
INSERT INTO your_table (binary_column) VALUES ('some data with a slash \');
In this case, PostgreSQL might interpret the backslash as the beginning of an escaped sequence, leading to an error or misinterpretation of the data.
To avoid such situations, you can use the E'...' function, which allows the use of escape sequences in strings:
INSERT INTO your_table (binary_column) VALUES (E'some data with a slash \\');
In this example, E'...' enables the use of an escaped backslash in the string. Note that each backslash must be doubled to prevent interpretation errors.
No duplicates 🥲.
Database
PostgreSQL
What happened?
Original issue spiral/cycle-bridge#85
The payload contains an url. Upon
json_encode
, it will add backslashes to escape the uri e.ghttp:\/\/127.0.0.1:8080\/
which I guess somewhat invalid forbytea
column. Removing the URL from the payload resolves the issue.Version
The text was updated successfully, but these errors were encountered: