1
0
Fork 0

Bug fix 3.5/allow not like (#9991)

* allow NOT LIKE, NOT =~ and !~ in grammar

* updated CHANGELOG

* added derive files
This commit is contained in:
Jan 2019-09-12 15:59:40 +02:00 committed by KVS85
parent c7b0e68026
commit 8830aad557
6 changed files with 1144 additions and 1020 deletions

View File

@ -1,6 +1,10 @@
v3.5.1 (XXXX-XX-XX) v3.5.1 (XXXX-XX-XX)
------------------- -------------------
* Added support for AQL expressions such as `a NOT LIKE b`, `a NOT =~ b` and
`a NOT !~ b`. Previous versions of ArangoDB did not support these expressions,
and using them in an AQL query resulted in a parse error.
* Disallow creation of TTL indexes on sub-attributes. * Disallow creation of TTL indexes on sub-attributes.
Creation of such indexes was not caught before, but the resulting Creation of such indexes was not caught before, but the resulting

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,9 @@
/* A Bison parser, made by GNU Bison 3.0.5. */ /* A Bison parser, made by GNU Bison 3.3.2. */
/* Bison interface for Yacc-like parsers in C /* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -30,6 +31,9 @@
This special exception was added by the Free Software Foundation in This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */ version 2.2 of Bison. */
/* Undocumented macros, especially those whose name start with YY_,
are private implementation details. Do not rely on them. */
#ifndef YY_AQL_AQL_GRAMMAR_HPP_INCLUDED #ifndef YY_AQL_AQL_GRAMMAR_HPP_INCLUDED
# define YY_AQL_AQL_GRAMMAR_HPP_INCLUDED # define YY_AQL_AQL_GRAMMAR_HPP_INCLUDED
/* Debug traces. */ /* Debug traces. */
@ -126,7 +130,7 @@ extern int Aqldebug;
union YYSTYPE union YYSTYPE
{ {
#line 35 "Aql/grammar.y" /* yacc.c:1910 */ #line 35 "Aql/grammar.y" /* yacc.c:1921 */
arangodb::aql::AstNode* node; arangodb::aql::AstNode* node;
struct { struct {
@ -136,7 +140,7 @@ union YYSTYPE
bool boolval; bool boolval;
int64_t intval; int64_t intval;
#line 140 "Aql/grammar.hpp" /* yacc.c:1910 */ #line 144 "Aql/grammar.hpp" /* yacc.c:1921 */
}; };
typedef union YYSTYPE YYSTYPE; typedef union YYSTYPE YYSTYPE;

View File

@ -1,8 +1,9 @@
/* A Bison parser, made by GNU Bison 3.0.5. */ /* A Bison parser, made by GNU Bison 3.3.2. */
/* Bison interface for Yacc-like parsers in C /* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -30,6 +31,9 @@
This special exception was added by the Free Software Foundation in This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */ version 2.2 of Bison. */
/* Undocumented macros, especially those whose name start with YY_,
are private implementation details. Do not rely on them. */
#ifndef YY_AQL_AQL_GRAMMAR_HPP_INCLUDED #ifndef YY_AQL_AQL_GRAMMAR_HPP_INCLUDED
# define YY_AQL_AQL_GRAMMAR_HPP_INCLUDED # define YY_AQL_AQL_GRAMMAR_HPP_INCLUDED
/* Debug traces. */ /* Debug traces. */
@ -126,7 +130,7 @@ extern int Aqldebug;
union YYSTYPE union YYSTYPE
{ {
#line 35 "Aql/grammar.y" /* yacc.c:1910 */ #line 35 "Aql/grammar.y" /* yacc.c:1921 */
arangodb::aql::AstNode* node; arangodb::aql::AstNode* node;
struct { struct {
@ -136,7 +140,7 @@ union YYSTYPE
bool boolval; bool boolval;
int64_t intval; int64_t intval;
#line 140 "Aql/grammar.hpp" /* yacc.c:1910 */ #line 144 "Aql/grammar.hpp" /* yacc.c:1921 */
}; };
typedef union YYSTYPE YYSTYPE; typedef union YYSTYPE YYSTYPE;

View File

@ -1382,6 +1382,26 @@ operator_binary:
| expression T_NOT T_IN expression { | expression T_NOT T_IN expression {
$$ = parser->ast()->createNodeBinaryOperator(NODE_TYPE_OPERATOR_BINARY_NIN, $1, $4); $$ = parser->ast()->createNodeBinaryOperator(NODE_TYPE_OPERATOR_BINARY_NIN, $1, $4);
} }
| expression T_NOT T_LIKE expression {
AstNode* arguments = parser->ast()->createNodeArray(2);
arguments->addMember($1);
arguments->addMember($4);
AstNode* expression = parser->ast()->createNodeFunctionCall(TRI_CHAR_LENGTH_PAIR("LIKE"), arguments);
$$ = parser->ast()->createNodeUnaryOperator(NODE_TYPE_OPERATOR_UNARY_NOT, expression);
}
| expression T_NOT T_REGEX_MATCH expression {
AstNode* arguments = parser->ast()->createNodeArray(2);
arguments->addMember($1);
arguments->addMember($4);
AstNode* expression = parser->ast()->createNodeFunctionCall(TRI_CHAR_LENGTH_PAIR("REGEX_TEST"), arguments);
$$ = parser->ast()->createNodeUnaryOperator(NODE_TYPE_OPERATOR_UNARY_NOT, expression);
}
| expression T_NOT T_REGEX_NON_MATCH expression {
AstNode* arguments = parser->ast()->createNodeArray(2);
arguments->addMember($1);
arguments->addMember($4);
$$ = parser->ast()->createNodeFunctionCall(TRI_CHAR_LENGTH_PAIR("REGEX_TEST"), arguments);
}
| expression T_LIKE expression { | expression T_LIKE expression {
AstNode* arguments = parser->ast()->createNodeArray(2); AstNode* arguments = parser->ast()->createNodeArray(2);
arguments->addMember($1); arguments->addMember($1);

View File

@ -428,8 +428,52 @@ function ahuacatlParseTestSuite () {
assertEqual(7, sub[1].subNodes[0].value); assertEqual(7, sub[1].subNodes[0].value);
assertEqual("value", sub[1].subNodes[1].type); assertEqual("value", sub[1].subNodes[1].type);
assertEqual(8, sub[1].subNodes[1].value); assertEqual(8, sub[1].subNodes[1].value);
} },
testNotLike : function() {
let result = AQL_PARSE("RETURN 'a' NOT LIKE 'b'").ast;
assertEqual("root", result[0].type);
result = result[0].subNodes;
assertEqual("return", result[0].type);
result = result[0].subNodes;
assertEqual("unary not", result[0].type);
let sub = result[0].subNodes[0];
assertEqual("function call", sub.type);
assertEqual("LIKE", sub.name);
},
testNotMatches : function() {
let result = AQL_PARSE("RETURN 'a' NOT =~ 'b'").ast;
assertEqual("root", result[0].type);
result = result[0].subNodes;
assertEqual("return", result[0].type);
result = result[0].subNodes;
assertEqual("unary not", result[0].type);
let sub = result[0].subNodes[0];
assertEqual("function call", sub.type);
assertEqual("REGEX_TEST", sub.name);
},
testNotNotMatches : function() {
let result = AQL_PARSE("RETURN 'a' NOT !~ 'b'").ast;
assertEqual("root", result[0].type);
result = result[0].subNodes;
assertEqual("return", result[0].type);
result = result[0].subNodes;
assertEqual("function call", result[0].type);
assertEqual("REGEX_TEST", result[0].name);
}
}; };
} }