Merge pull request #27706 from hllustosa/master

Enables query parameters in request body
This commit is contained in:
Kseniia Sumarokova 2021-08-17 09:58:11 +03:00 committed by GitHub
commit 8ec6e6f209
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 1 deletions

View File

@ -944,7 +944,9 @@ bool DynamicQueryHandler::customizeQueryParam(ContextMutablePtr context, const s
{
/// Save name and values of substitution in dictionary.
const String parameter_name = key.substr(strlen("param_"));
context->setQueryParameter(parameter_name, value);
if (!context->getQueryParameters().contains(parameter_name))
context->setQueryParameter(parameter_name, value);
return true;
}
@ -970,8 +972,16 @@ std::string DynamicQueryHandler::getQuery(HTTPServerRequest & request, HTMLForm
std::string full_query;
/// Params are of both form params POST and uri (GET params)
for (const auto & it : params)
{
if (it.first == param_name)
{
full_query += it.second;
}
else
{
customizeQueryParam(context, it.first, it.second);
}
}
return full_query;
}

View File

@ -0,0 +1,3 @@
1
1
1 2

View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
curl -sS -F param_id=1 -X POST "${CLICKHOUSE_URL}&query=select%201%20as%20c%20where%20c%20%3D%20%7Bid%3AUInt8%7D";
curl -sS -X GET "${CLICKHOUSE_URL}&query=select%201%20as%20c%20where%20c%20%3D%20%7Bid%3AUInt8%7D&param_id=1";
curl -sS -F param_id=1 -X POST "${CLICKHOUSE_URL}&query=select%201%20as%20c%2C%202%20as%20c2%20where%20c%20%3D%20%7Bid%3AUInt8%7D%20and%20c2%20%3D%20%20%7Bid2%3AUInt8%7D&param_id2=2";