Operators, precedence, and the two lowerings.

Generated from the language definition for language 1.0.

Expressions

One grammar, two lowerings: a record-local position (a guard, a validation, a browser gate) lowers to JSONLogic; a set-level position (a query, a related list, a rollup, a stat) lowers to a DAL statement. Comparisons do not chain; = is accepted and printed as ==.

Binary operators

OperatorPrecedenceJSONLogicDAL
or1 (or)orOr
and2 (and)andAnd
==4 (comparison)==Eq
!=4 (comparison)!=Ne
<4 (comparison)<Lt
<=4 (comparison)<=Le
>4 (comparison)>Gt
>=4 (comparison)>=Ge
like4 (comparison)not available (no pattern match)Like
+5 (additive)+not available (no arithmetic)
-5 (additive)-not available (no arithmetic)
*6 (multiplicative)*not available (no arithmetic)
/6 (multiplicative)/not available (no arithmetic)

Other forms

  • not x: logical negation
  • -x: arithmetic negation
  • x is null: null test (x is not null for the complement)
  • x in [a, b]: membership in a list of literals
  • x in (select …): membership in a subquery (set-level only)
  • exists (select …): a non-empty subquery (set-level only)
  • a.b: a field, or one level of ref traversal
  • this: the current record in a set-level position; this.field reads one of its fields
  • me: the current user (set-level only)
  • (x): grouping; parentheses survive round trips where precedence needs them

Functions

Set-level only: JSONLogic has no lower, upper, length or coalesce, and its substr counts from zero where the DAL's counts from one, so a record-local position refuses them rather than promise one meaning in two targets.

FunctionArgumentsDAL
lower1Lower
upper1Upper
coalesce2 or moreCoalesce
length1Length
substr2 to 3Substr

Aggregates

agg(Entity[.field] [where expr]); in a guard, count(…) op n and sum(…) op n compile to the engine's related-record guards.

AggregateDAL
countCount
sumSum
avgAvg
minMin
maxMax

JSONLogic operators the compiler may emit

A jsonlogic { … } literal may use any of them, and the sugar emits the ones its operators map to.

==, !=, ===, !==, !, !!, <, <=, >, >=, +, -, *, /, %, max, min, merge, in, cat, substr, log, var, missing, missing_some, if, ?:, or, and, map, filter, reduce, all, some, none

DAL vocabulary

  • Binary operators: Eq, Ne, Lt, Le, Gt, Ge, And, Or, In, NotIn, Like
  • Unary operators: Not, IsNull, IsNotNull
  • Functions: Lower, Upper, Coalesce, Length, Substr
  • Aggregates: Count, Sum, Avg, Min, Max
  • Built-in sources: jobs (Jobs), event_log (EventLog), fsm_schemas (FsmSchemas)