Unverified Commit b6d761af authored by Robert Roland's avatar Robert Roland Committed by GitHub

Merge pull request #2776 from rbrw/pdb-3471-support-notequality

(PDB-3417) support != and !~ in PQL
parents a31acb99 605e6ad0
......@@ -61,11 +61,13 @@ expr-not = ( not, [<whitespace>], expr-not ) | expr-rest;
subquery = entity, [<whitespace>], where;
(* Conditional expression *)
condexpression = (condexpregexp | condexpregexparray | condexpinequality | condexpmatch | condexpin);
condexpression = (condexpregexp | condexpregexparray | condexpinequality | condexpmatch | condexpnotmatch| condexpnotregexp | condexpin);
<condexpregexp> = field, [<whitespace>], condregexp, [<whitespace>], valueregexp;
<condexpregexparray> = field, [<whitespace>], condregexparray, [<whitespace>], valueregexparray;
<condexpinequality> = field, [<whitespace>], condinequality, [<whitespace>], valueordered;
<condexpmatch> = field, [<whitespace>], condmatch, [<whitespace>], literal;
<condexpnotmatch> = field, [<whitespace>], condnotmatch, [<whitespace>], literal;
<condexpnotregexp> = field, [<whitespace>], condnotregexp, [<whitespace>], literal;
<condexpin> = (field | groupedfieldlist), [<whitespace>], condin, [<whitespace>], valuein;
(* Special is null/is not null expression *)
......@@ -95,6 +97,8 @@ field = #'[a-zA-Z0-9_]+\??' | (dottedfield, fieldpath);
<condregexparray> = '~>';
<condinequality> = '>=' | '<=' | '<' | '>';
<condmatch> = '=';
<condnotmatch> = '!=';
<condnotregexp> = '!~';
<condin> = 'in';
<valueregexp> = string;
......
......@@ -54,7 +54,10 @@
(defn transform-condexpression
[a b c]
[b a c])
(case b
"!=" ["not" ["=" a c]]
"!~" ["not" ["~" a c]]
[b a c]))
(defn transform-condexpnull
[entity type]
......
......@@ -345,6 +345,12 @@
"certname > 4"
[:condexpression [:field "certname"] ">" [:integer "4"]]
"certname != 4"
[:condexpression [:field "certname"] "!=" [:integer "4"]]
"certname !~ 4"
[:condexpression [:field "certname"] "!~" [:integer "4"]]
"a in nodes [a] {}"
[:condexpression [:field "a"] "in" [:from "nodes" [:extract [:field "a"]]]])
......
......@@ -59,6 +59,12 @@
["from" "nodes"
["=" "a" 1]]
[:condexpression [:field "certname"] "!=" [:integer "4"]]
["not" ["=" "certname" 4]]
[:condexpression [:field "certname"] "!~" [:integer "4"]]
["not" ["~" "certname" 4]]
[:from "nodes"
[:extract "a" "b" "c"]]
["from" "nodes"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment