Wraps only identifiers with backticks.
| 191 | |
| 192 | /// Wraps only identifiers with backticks. |
| 193 | std::string wrapIdentifiersWithBackticks(const ASTPtr & root) |
| 194 | { |
| 195 | if (auto identifier = std::dynamic_pointer_cast<ASTIdentifier>(root)) |
| 196 | return backQuote(identifier->name()); |
| 197 | |
| 198 | if (auto function = std::dynamic_pointer_cast<ASTFunction>(root)) |
| 199 | return function->name + '(' + wrapIdentifiersWithBackticks(function->arguments) + ')'; |
| 200 | |
| 201 | if (auto expression_list = std::dynamic_pointer_cast<ASTExpressionList>(root)) |
| 202 | { |
| 203 | Names function_arguments(expression_list->children.size()); |
| 204 | for (size_t i = 0; i < expression_list->children.size(); ++i) |
| 205 | function_arguments[i] = wrapIdentifiersWithBackticks(expression_list->children[0]); |
| 206 | return boost::algorithm::join(function_arguments, ", "); |
| 207 | } |
| 208 | |
| 209 | throw Exception("Primary key could be represented only as columns or functions from columns.", ErrorCodes::BAD_ARGUMENTS); |
| 210 | } |
| 211 | |
| 212 | |
| 213 | Names extractPrimaryKeyColumnNames(const ASTPtr & storage_ast) |