asyncer-io / r2dbc-mysql

Reactive Relational Database Connectivity for MySQL. The official successor to mirromutth/r2dbc-mysql(dev.miku:r2dbc-mysql).
https://r2dbc.io
Apache License 2.0
208 stars 21 forks source link

[feature] Support sql mode `NO_BACKSLASH_ESCAPES` #267

Closed mirromutth closed 7 months ago

mirromutth commented 8 months ago

Is your feature request related to a problem? Please describe.

When sql_mode contains NO_BACKSLASH_ESCAPES, MySQL server does not allow the use of \ as an escape character. In this mode, we should not use \ to escape strings.

For example:

CREATE TABLE escape_test(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, value VARCHAR(50) NOT NULL);

INSERT INTO escape_test (`value`) VALUES ('my\ndata');

SELECT * FROM escape_test WHERE value = 'my
data'; -- 1 row
SELECT * FROM escape_test WHERE value = 'my\ndata'; -- 1 row

SET SESSION sql_mode = 'NO_BACKSLASH_ESCAPES';

SELECT * FROM escape_test WHERE value = 'my
data'; -- 1 row
SELECT * FROM escape_test WHERE value = 'my\ndata'; -- 0 row

Describe the solution you'd like