Open jenky opened 6 months ago
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.
Or check this function https://www.php.net/manual/en/function.pg-escape-bytea.php
Thank you. However, if you refer to the original issue, I do not have control over how the data is being serialized.
No duplicates 🥲.
Database
PostgreSQL
What happened?
Original issue https://github.com/spiral/cycle-bridge/issues/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