Skip to content

Commit

Permalink
Fix #58 - enable NO_BACKSLASH_ESCAPE sql mode in connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Mytherin committed Apr 16, 2024
1 parent d509463 commit 8253d61
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/mysql_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ MySQLConnection MySQLConnection::Open(const string &connection_string) {
result.connection = make_shared<OwnedMySQLConnection>(MySQLUtils::Connect(connection_string));
result.dsn = connection_string;
result.Execute("SET character_set_results = 'utf8mb4';");
result.Execute("SET sql_mode = 'no_backslash_escapes';");
return result;
}

Expand Down
24 changes: 24 additions & 0 deletions test/sql/insert_backslash.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# name: test/sql/insert_backslash.test
# description: Issue #58 - value is "\" can not copy to mysql
# group: [sql]

require mysql_scanner

require-env MYSQL_TEST_DATABASE_AVAILABLE

statement ok
ATTACH 'host=localhost user=root port=0 database=mysqlscanner' AS msql (TYPE MYSQL_SCANNER)

statement ok
USE msql

statement ok
CREATE OR REPLACE TABLE backslash_tbl(v VARCHAR);

statement ok
INSERT INTO backslash_tbl VALUES ('\')

query I
SELECT * FROM backslash_tbl
----
\

0 comments on commit 8253d61

Please sign in to comment.