mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Merge pull request #27706 from hllustosa/master
Enables query parameters in request body
This commit is contained in:
commit
8ec6e6f209
@ -944,6 +944,8 @@ bool DynamicQueryHandler::customizeQueryParam(ContextMutablePtr context, const s
|
||||
{
|
||||
/// Save name and values of substitution in dictionary.
|
||||
const String parameter_name = key.substr(strlen("param_"));
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -0,0 +1,3 @@
|
||||
1
|
||||
1
|
||||
1 2
|
9
tests/queries/0_stateless/02009_body_query_params.sh
Executable file
9
tests/queries/0_stateless/02009_body_query_params.sh
Executable 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¶m_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¶m_id2=2";
|
Loading…
Reference in New Issue
Block a user