@@ -801,6 +801,44 @@ public void testComputedCols() throws Exception {
801
801
}
802
802
}
803
803
804
+ /**
805
+ * Test bulk insert with no space after table name
806
+ *
807
+ * @throws Exception
808
+ */
809
+ @ Test
810
+ public void testNoSpaceInsert () throws Exception {
811
+ // table name with valid alphanumeric chars that don't need to be escaped, since escaping the table name would not test the space issue
812
+ String testNoSpaceInsertTableName = "testNoSpaceInsertTable" + RandomData .generateInt (false );
813
+ String valid = "insert into " + testNoSpaceInsertTableName + "(id, json)" + " values(?, ?)" ;
814
+
815
+ try (Connection connection = PrepUtil .getConnection (connectionString + ";useBulkCopyForBatchInsert=true;" );
816
+ SQLServerPreparedStatement pstmt = (SQLServerPreparedStatement ) connection .prepareStatement (valid );
817
+ Statement stmt = (SQLServerStatement ) connection .createStatement ();) {
818
+ Field f1 = SQLServerConnection .class .getDeclaredField ("isAzureDW" );
819
+ f1 .setAccessible (true );
820
+ f1 .set (connection , true );
821
+
822
+ TestUtils .dropTableIfExists (AbstractSQLGenerator .escapeIdentifier (tableNameBulkComputedCols ), stmt );
823
+ String createTable = "create table " + testNoSpaceInsertTableName
824
+ + " (id nvarchar(100) not null, json nvarchar(max) not null,"
825
+ + " vcol1 as json_value([json], '$.vcol1'), vcol2 as json_value([json], '$.vcol2'))" ;
826
+ stmt .execute (createTable );
827
+
828
+ String jsonValue = "{\" vcol1\" :\" " + UUID .randomUUID ().toString () + "\" ,\" vcol2\" :\" "
829
+ + UUID .randomUUID ().toString () + "\" }" ;
830
+ String idValue = UUID .randomUUID ().toString ();
831
+ pstmt .setString (1 , idValue );
832
+ pstmt .setString (2 , jsonValue );
833
+ pstmt .addBatch ();
834
+ pstmt .executeBatch ();
835
+ } finally {
836
+ try (Statement stmt = connection .createStatement ()) {
837
+ TestUtils .dropTableIfExists (AbstractSQLGenerator .escapeIdentifier (testNoSpaceInsertTableName ), stmt );
838
+ }
839
+ }
840
+ }
841
+
804
842
@ BeforeAll
805
843
public static void setupTests () throws Exception {
806
844
setConnection ();
0 commit comments