@@ -1488,3 +1488,45 @@ TEST(SimpleClientTest, issue_335_reconnects_count) {
14881488 << " \t There was no attempt to connect to endpoint " << endpoint;
14891489 }
14901490}
1491+
1492+ TEST_P (ClientCase, QueryParameters) {
1493+ const std::string table_name = " test_clickhouse_cpp_query_parameter" ;
1494+ client_->Execute (" CREATE TEMPORARY TABLE IF NOT EXISTS " + table_name + " (id UInt64, name String)" );
1495+ {
1496+ Query query (" insert into " + table_name + " values ({id: UInt64}, {name: String})" );
1497+
1498+ query.SetParam (" id" , " 1" ).SetParam (" name" , " NAME" );
1499+ client_->Execute (query);
1500+
1501+ query.SetParam (" id" , " 123" ).SetParam (" name" , " FromParam" );
1502+ client_->Execute (query);
1503+
1504+ query.SetParam (" id" , " 333" )
1505+ .SetParam (" name" , std::string (" A\000 A\001 A\002 A\003 A\004 A\005 A\006 A\007 A\010 A\011 A\012 A\013 A\014 A\015 A\016 A\017 A\020 A\021 A\022 A"
1506+ " \023 A\024 A\025 A\026 A\027 A\030 A\031 A\032 A\033 A\034 "
1507+ " A\035 A\036 A\037 A" ,
1508+ 65 ));
1509+ client_->Execute (query);
1510+
1511+ unsigned char big_string[128 - 32 ];
1512+ for (unsigned int i = 0 ; i < sizeof (big_string); i++) big_string[i] = i + 32 ;
1513+ query.SetParam (" id" , " 444" ).SetParam (" name" , std::string ((char *)big_string, sizeof (big_string)));
1514+ client_->Execute (query);
1515+
1516+ query.SetParam (" id" , " 555" ).SetParam (" name" , " utf8Русский" );
1517+ client_->Execute (query);
1518+ }
1519+
1520+ Query query (" SELECT id, name, length(name) FROM " + table_name + " where id > {a: Int32}" );
1521+ query.SetParam (" a" , " 4" );
1522+ size_t total_count = 0 ;
1523+ SelectCallback cb ([&total_count](const Block& block) {
1524+ total_count += block.GetRowCount ();
1525+ // std::cout << PrettyPrintBlock{block} << std::endl;
1526+ });
1527+ query.OnData (cb);
1528+ client_->Select (query);
1529+ EXPECT_EQ (4u , total_count);
1530+
1531+ client_->Execute (" DROP TEMPORARY TABLE " + table_name);
1532+ }
0 commit comments