@@ -530,7 +530,6 @@ public void BulkCopyNullDataTable()
530
530
Assert . Throws < ArgumentNullException > ( ( ) => bulkCopy . WriteToServer ( default ( DataTable ) ) ) ;
531
531
}
532
532
533
- #if ! MYSQL_DATA
534
533
[ Fact ]
535
534
public void BulkCopyDataTableWithMySqlDecimal ( )
536
535
{
@@ -655,7 +654,6 @@ public void BulkCopyDataTableWithTimeOnly()
655
654
Assert . Equal ( new TimeOnly ( 1 , 2 , 3 , 456 ) , reader . GetTimeOnly ( 2 ) ) ;
656
655
}
657
656
}
658
- #endif
659
657
#endif
660
658
661
659
public static IEnumerable < object [ ] > GetBulkCopyData ( ) =>
@@ -713,6 +711,50 @@ public void BulkCopyDataTable(string columnType, object[] rows)
713
711
}
714
712
}
715
713
714
+ [ Fact ]
715
+ public void BulkCopyToColumnNeedingQuoting ( )
716
+ {
717
+ var dataTable = new DataTable ( )
718
+ {
719
+ Columns =
720
+ {
721
+ new DataColumn ( "id" , typeof ( int ) ) ,
722
+ new DataColumn ( "@a" , typeof ( string ) ) ,
723
+ } ,
724
+ } ;
725
+ dataTable . Rows . Add ( 2 , "two" ) ;
726
+
727
+ using var connection = new MySqlConnection ( GetLocalConnectionString ( ) ) ;
728
+ connection . Open ( ) ;
729
+ using ( var cmd = new MySqlCommand ( $ """
730
+ drop table if exists bulk_load_quoted_identifier;
731
+ create table bulk_load_quoted_identifier(id int, `@a` text);
732
+ insert into bulk_load_quoted_identifier values (1, 'one');
733
+ """ , connection ) )
734
+ {
735
+ cmd . ExecuteNonQuery ( ) ;
736
+ }
737
+
738
+ var bulkCopy = new MySqlBulkCopy ( connection )
739
+ {
740
+ DestinationTableName = "bulk_load_quoted_identifier" ,
741
+ } ;
742
+ var result = bulkCopy . WriteToServer ( dataTable ) ;
743
+ Assert . Equal ( 1 , result . RowsInserted ) ;
744
+ Assert . Empty ( result . Warnings ) ;
745
+
746
+ using ( var cmd = new MySqlCommand ( @"select `@a` from bulk_load_quoted_identifier order by id;" , connection ) )
747
+ {
748
+ using var reader = cmd . ExecuteReader ( ) ;
749
+ Assert . True ( reader . Read ( ) ) ;
750
+ Assert . Equal ( "one" , reader . GetString ( 0 ) ) ;
751
+ Assert . True ( reader . Read ( ) ) ;
752
+ Assert . Equal ( "two" , reader . GetString ( 0 ) ) ;
753
+ Assert . False ( reader . Read ( ) ) ;
754
+ Assert . False ( reader . NextResult ( ) ) ;
755
+ }
756
+ }
757
+
716
758
[ Fact ]
717
759
public void BulkCopyDataTableWithLongBlob ( )
718
760
{
0 commit comments