Fix unit-tests again

This commit is contained in:
Ivan Lezhankin 2021-06-07 16:52:47 +03:00
parent 977fbbf1e4
commit 7aa08a04b5
5 changed files with 7 additions and 12 deletions

View File

@ -242,7 +242,7 @@ static inline bool parseRenameCommand(IParser::Pos & pos, ASTPtr & node, Expecte
}
else if (ParserKeyword("TO").ignore(pos, expected) || ParserKeyword("AS").ignore(pos, expected))
{
if (!ParserCompoundIdentifier(false).parse(pos, new_name, expected))
if (!ParserCompoundIdentifier(true).parse(pos, new_name, expected))
return false;
auto new_table_id = new_name->as<ASTTableIdentifier>()->getTableId();

View File

@ -36,7 +36,7 @@ bool ParserAlterQuery::parseImpl(IParser::Pos & pos, ASTPtr & node, Expected & e
if (!ParserKeyword("ALTER TABLE").ignore(pos, expected))
return false;
if (!ParserCompoundIdentifier(false).parse(pos, table, expected))
if (!ParserCompoundIdentifier(true).parse(pos, table, expected))
return false;
if (!ParserList(std::make_unique<ParserAlterCommand>(), std::make_unique<ParserToken>(TokenType::Comma)).parse(pos, command_list, expected))

View File

@ -68,14 +68,14 @@ bool ParserCreateQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
if (ParserKeyword("LIKE").ignore(pos, expected))
{
if (!ParserCompoundIdentifier(false).parse(pos, like_table, expected))
if (!ParserCompoundIdentifier(true).parse(pos, like_table, expected))
return false;
}
else if (ParserToken(TokenType::OpeningRoundBracket).ignore(pos, expected))
{
if (ParserKeyword("LIKE").ignore(pos, expected))
{
if (!ParserCompoundIdentifier(false).parse(pos, like_table, expected))
if (!ParserCompoundIdentifier(true).parse(pos, like_table, expected))
return false;
if (!ParserToken(TokenType::ClosingRoundBracket).ignore(pos, expected))

View File

@ -176,7 +176,7 @@ TEST(TransformQueryForExternalDatabase, MultipleAndSubqueries)
R"(SELECT "column" FROM "test"."table" WHERE 1 AND ("column" = 42) AND ("column" IN (1, 42)) AND ("column" != 4))");
check(state, 1,
"SELECT column FROM test.table WHERE toString(column) = '42' AND left(column, 10) = RIGHT(column, 10) AND column = 42",
R"(SELECT "column" FROM "test"."table" WHERE ("column" = 42))");
R"(SELECT "column" FROM "test"."table" WHERE "column" = 42)");
}
TEST(TransformQueryForExternalDatabase, Issue7245)

View File

@ -273,20 +273,15 @@ String transformQueryForExternalDatabase(
{
if (function->name == "and")
{
bool compatible_found = false;
auto new_function_and = makeASTFunction("and");
for (const auto & elem : function->arguments->children)
{
if (isCompatible(*elem))
{
new_function_and->arguments->children.push_back(elem);
compatible_found = true;
}
}
if (new_function_and->arguments->children.size() == 1)
new_function_and->name = "";
if (compatible_found)
select->setExpression(ASTSelectQuery::Expression::WHERE, std::move(new_function_and->arguments->children[0]));
else if (new_function_and->arguments->children.size() > 1)
select->setExpression(ASTSelectQuery::Expression::WHERE, std::move(new_function_and));
}
}