Skip to content

Commit 4e89d47

Browse files
committed
Quote table name in MySqlBulkCopy. Fixes #792
1 parent 7caf5eb commit 4e89d47

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

docs/content/api/mysql-bulk-copy.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
lastmod: 2020-01-07
2+
lastmod: 2020-04-04
33
date: 2019-11-11
44
menu:
55
main:
@@ -55,7 +55,7 @@ The number of seconds for the operation to complete before it times out, or `0`
5555

5656
`public string DestinationTableName { get; set; }`
5757

58-
Name of the destination table on the server.
58+
Name of the destination table on the server. (This name shouldn't be quoted or escaped.)
5959

6060
`public int NotifyAfter { get; set; }`
6161

src/MySqlConnector/MySql.Data.MySqlClient/MySqlBulkCopy.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public MySqlBulkCopy(MySqlConnection connection, MySqlTransaction? transaction =
2424

2525
public int BulkCopyTimeout { get; set; }
2626

27+
/// <summary>
28+
/// The name of the table to insert rows into.
29+
/// </summary>
30+
/// <remarks>The table name shouldn't be quoted or escaped.</remarks>
2731
public string? DestinationTableName { get; set; }
2832

2933
/// <summary>
@@ -119,7 +123,7 @@ private async ValueTask WriteToServerAsync(IOBehavior ioBehavior, CancellationTo
119123
Local = true,
120124
NumberOfLinesToSkip = 0,
121125
Source = this,
122-
TableName = tableName,
126+
TableName = QuoteIdentifier(tableName),
123127
Timeout = BulkCopyTimeout,
124128
};
125129

0 commit comments

Comments
 (0)