Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion resources/puppetlabs/puppetdb/pql/pql-grammar.ebnf
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extract = <lbracket>, [<whitespace>], [extractfields], [<whitespace>], <rbracket
expr-or = expr-and { <whitespace>, or, <whitespace>, expr-or };
expr-and = expr-not { <whitespace>, and, <whitespace>, expr-and };
expr-not = ( not, [<whitespace>], expr-not ) | expr-rest;
<expr-rest> = ( <lparens>, [<whitespace>], expression, [<whitespace>], <rparens> ) | condexpression | condexpnull | subquery;
<expr-rest> = ( <lparens>, [<whitespace>], expression, [<whitespace>], <rparens> ) | condexpression | condexpnull | subquery | jsonbexpr;

(* Implicit subqueries *)
subquery = entity, [<whitespace>], where;
Expand Down Expand Up @@ -85,6 +85,10 @@ groupedarglist = <lparens>, [<whitespace>], [arglist], [<whitespace>], <rparens>
<arglist> = (field | string), [ [<whitespace>], <','>, [<whitespace>], stringlist ];
<stringlist> = string , [ [<whitespace>], <','>, [<whitespace>], stringlist ];

(* jsonb_typeof part *)
jsonbexpr = jsonb, <lparens>, [<whitespace>], field, [<whitespace>], <rparens>, [<whitespace>], condmatch, [<whitespace>], string;
<jsonb> = 'jsonb_typeof';

(* Represents a field from an entity *)
field = #'[a-zA-Z0-9_]+\??' | (dottedfield, fieldpath);
<fieldpath> = <'.'>, (quotedfield | standardfield | matchfield) , [fieldpath];
Expand Down
5 changes: 5 additions & 0 deletions src/puppetlabs/puppetdb/pql/transform.clj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
[entity args]
(vec (concat ["function" entity] args)))

(defn transform-jsonb-typeof
[func-name field eq-operator type]
[eq-operator ["function" func-name field] type])

(defn transform-condexpression
[a b c]
(case b
Expand Down Expand Up @@ -145,6 +149,7 @@
:expr-and transform-expr-and
:expr-not transform-expr-not
:function transform-function
:jsonbexpr transform-jsonb-typeof
:condexpression transform-condexpression
:condexpnull transform-condexpnull
:groupedarglist transform-groupedlist
Expand Down