From af0c30e2f5153b69b36731294571b5224a01c715 Mon Sep 17 00:00:00 2001 From: Bradley Grainger Date: Sat, 4 Apr 2020 10:32:30 -0700 Subject: [PATCH] Quote table name in MySqlBulkCopy. Fixes #792 --- docs/content/api/mysql-bulk-copy.md | 2 +- src/MySqlConnector/MySql.Data.MySqlClient/MySqlBulkCopy.cs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/content/api/mysql-bulk-copy.md b/docs/content/api/mysql-bulk-copy.md index b0fdb4a36..99bc5733f 100644 --- a/docs/content/api/mysql-bulk-copy.md +++ b/docs/content/api/mysql-bulk-copy.md @@ -55,7 +55,7 @@ The number of seconds for the operation to complete before it times out, or `0` `public string DestinationTableName { get; set; }` -Name of the destination table on the server. +Name of the destination table on the server. (This name shouldn't be quoted or escaped.) `public int NotifyAfter { get; set; }` diff --git a/src/MySqlConnector/MySql.Data.MySqlClient/MySqlBulkCopy.cs b/src/MySqlConnector/MySql.Data.MySqlClient/MySqlBulkCopy.cs index cabf8bf49..fab275c42 100644 --- a/src/MySqlConnector/MySql.Data.MySqlClient/MySqlBulkCopy.cs +++ b/src/MySqlConnector/MySql.Data.MySqlClient/MySqlBulkCopy.cs @@ -24,6 +24,10 @@ public MySqlBulkCopy(MySqlConnection connection, MySqlTransaction? transaction = public int BulkCopyTimeout { get; set; } + /// + /// The name of the table to insert rows into. + /// + /// The table name shouldn't be quoted or escaped. public string? DestinationTableName { get; set; } /// @@ -119,7 +123,7 @@ private async ValueTask WriteToServerAsync(IOBehavior ioBehavior, CancellationTo Local = true, NumberOfLinesToSkip = 0, Source = this, - TableName = tableName, + TableName = QuoteIdentifier(tableName), Timeout = BulkCopyTimeout, };