Fix NOT parsing

This commit is contained in:
Azat Khuzhin 2021-06-20 22:34:18 +03:00
parent bf482f75a7
commit fabff86788
4 changed files with 20 additions and 5 deletions

View File

@ -22,9 +22,10 @@ const char * ParserMultiplicativeExpression::operators[] =
nullptr
};
const char * ParserUnaryMinusExpression::operators[] =
const char * ParserUnaryExpression::operators[] =
{
"-", "negate",
"NOT", "not",
nullptr
};
@ -539,7 +540,7 @@ bool ParserPrefixUnaryOperatorExpression::parseImpl(Pos & pos, ASTPtr & node, Ex
}
bool ParserUnaryMinusExpression::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
bool ParserUnaryExpression::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
{
/// As an exception, negative numbers should be parsed as literals, and not as an application of the operator.

View File

@ -245,14 +245,14 @@ protected:
};
class ParserUnaryMinusExpression : public IParserBase
class ParserUnaryExpression : public IParserBase
{
private:
static const char * operators[];
ParserPrefixUnaryOperatorExpression operator_parser {operators, std::make_unique<ParserTupleElementExpression>()};
protected:
const char * getName() const override { return "unary minus expression"; }
const char * getName() const override { return "unary expression"; }
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
};
@ -262,7 +262,7 @@ class ParserMultiplicativeExpression : public IParserBase
{
private:
static const char * operators[];
ParserLeftAssociativeBinaryOperatorList operator_parser {operators, std::make_unique<ParserUnaryMinusExpression>()};
ParserLeftAssociativeBinaryOperatorList operator_parser {operators, std::make_unique<ParserUnaryExpression>()};
protected:
const char * getName() const override { return "multiplicative expression"; }

View File

@ -0,0 +1,9 @@
-- { echo }
SELECT 1 != (NOT 1);
1
SELECT 1 != NOT 1;
1
EXPLAIN SYNTAX SELECT 1 != (NOT 1);
SELECT 1 != NOT 1
EXPLAIN SYNTAX SELECT 1 != NOT 1;
SELECT 1 != NOT 1

View File

@ -0,0 +1,5 @@
-- { echo }
SELECT 1 != (NOT 1);
SELECT 1 != NOT 1;
EXPLAIN SYNTAX SELECT 1 != (NOT 1);
EXPLAIN SYNTAX SELECT 1 != NOT 1;