@@ -718,9 +718,9 @@ TEST_P(ClientCase, Decimal) {
718
718
719
719
// Test special chars in names
720
720
TEST_P (ClientCase, ColEscapeNameTest) {
721
- client_->Execute (" DROP TABLE IF EXISTS test_clickhouse_cpp.\ " col_escape_\"\ " name_test\" ; " );
721
+ client_->Execute (R"sql( DROP TABLE IF EXISTS test_clickhouse_cpp."col_escape_" "name_test"; )sql " );
722
722
723
- client_->Execute (" CREATE TABLE IF NOT EXISTS test_clickhouse_cpp.\ " col_escape_\"\ " name_test\ " (\ " test space\ " UInt64, \ " test \"\ " quote\ " UInt64, \ " test \"\ " `'[]&_\\ all\ " UInt64) ENGINE = Memory" );
723
+ client_->Execute (R"sql( CREATE TABLE IF NOT EXISTS test_clickhouse_cpp."col_escape_" "name_test" ("test space" UInt64, "test " " quote" UInt64, "test " "`'[]&_\ all" UInt64) ENGINE = Memory)sql " );
724
724
725
725
auto col1 = std::make_shared<ColumnUInt64>();
726
726
col1->Append (1 );
@@ -732,18 +732,28 @@ TEST_P(ClientCase, ColEscapeNameTest) {
732
732
col3->Append (16 );
733
733
col3->Append (32 );
734
734
735
+ static const std::string column_names[] = {
736
+ " test space" ,
737
+ R"sql( test " quote)sql" ,
738
+ R"sql( test "`'[]&_\ all)sql"
739
+ };
740
+ static const auto columns_count = sizeof (column_names)/sizeof (column_names[0 ]);
741
+
735
742
Block block;
736
- block.AppendColumn (" test space " , col1);
737
- block.AppendColumn (" test \" quote " , col2);
738
- block.AppendColumn (" test \" `'[]&_ \\ all " , col3);
743
+ block.AppendColumn (column_names[ 0 ] , col1);
744
+ block.AppendColumn (column_names[ 1 ] , col2);
745
+ block.AppendColumn (column_names[ 2 ] , col3);
739
746
740
- client_->Insert (" test_clickhouse_cpp.\ " col_escape_\"\ " name_test\" " , block);
741
- client_->Select (" SELECT * FROM test_clickhouse_cpp.\ " col_escape_\"\ " name_test\" " , [] (const Block& sblock)
747
+ client_->Insert (R"sql( test_clickhouse_cpp."col_escape_" "name_test" )sql " , block);
748
+ client_->Select (R"sql( SELECT * FROM test_clickhouse_cpp."col_escape_" "name_test" )sql " , [] (const Block& sblock)
742
749
{
743
750
int row = sblock.GetRowCount ();
744
751
if (row <= 0 ) {return ;}
745
- int col = sblock.GetColumnCount ();
746
- EXPECT_EQ (col, 3 );
752
+ ASSERT_EQ (columns_count, sblock.GetColumnCount ());
753
+ for (size_t i = 0 ; i < columns_count; ++i) {
754
+ EXPECT_EQ (column_names[i], sblock.GetColumnName (i));
755
+ }
756
+
747
757
EXPECT_EQ (row, 2 );
748
758
EXPECT_EQ (sblock[0 ]->As <ColumnUInt64>()->At (0 ), 1u );
749
759
EXPECT_EQ (sblock[0 ]->As <ColumnUInt64>()->At (1 ), 2u );
0 commit comments