= semantics
This commit is contained in:
parent
6dc62f8d14
commit
4904644464
@ -82,8 +82,9 @@ export function evalQueryExpression(
|
|||||||
// Record property is an array, and value is a scalar: find the value in the array
|
// Record property is an array, and value is a scalar: find the value in the array
|
||||||
return val1.includes(val2);
|
return val1.includes(val2);
|
||||||
} else if (Array.isArray(val1) && Array.isArray(val2)) {
|
} else if (Array.isArray(val1) && Array.isArray(val2)) {
|
||||||
// Record property is an array, and value is an array: find the value in the array
|
// Record property is an array, and value is an array: compare the arrays
|
||||||
return val1.some((v) => val2.includes(v));
|
return val1.length === val2.length &&
|
||||||
|
val1.every((v) => val2.includes(v));
|
||||||
}
|
}
|
||||||
return val1 == val2;
|
return val1 == val2;
|
||||||
}
|
}
|
||||||
@ -92,8 +93,9 @@ export function evalQueryExpression(
|
|||||||
// Record property is an array, and value is a scalar: find the value in the array
|
// Record property is an array, and value is a scalar: find the value in the array
|
||||||
return !val1.includes(val2);
|
return !val1.includes(val2);
|
||||||
} else if (Array.isArray(val1) && Array.isArray(val2)) {
|
} else if (Array.isArray(val1) && Array.isArray(val2)) {
|
||||||
// Record property is an array, and value is an array: find the value in the array
|
// Record property is an array, and value is an array: compare the arrays
|
||||||
return !val1.some((v) => val2.includes(v));
|
return !(val1.length === val2.length &&
|
||||||
|
val1.every((v) => val2.includes(v)));
|
||||||
}
|
}
|
||||||
return val1 !== val2;
|
return val1 !== val2;
|
||||||
}
|
}
|
||||||
|
@ -83,15 +83,18 @@ Logical expressions:
|
|||||||
* or: `name = "this" or age > 10`
|
* or: `name = "this" or age > 10`
|
||||||
|
|
||||||
Binary expressions:
|
Binary expressions:
|
||||||
- `=` equals, e.g. `name = "Pete"`
|
* `=` equals.
|
||||||
- `!=` not equals, e.g. `name != "Pete"`
|
* For scalar values this performance an equivalence tests (e.g. `10 = 10`)
|
||||||
- `<` less than, e.g. `age < 10`
|
* If the left operand is an array and the right operand is _not_, this will will check if the right operand is _included_ in the left operand’s value, e.g. `[1, 2, 3] = 2` will be true.
|
||||||
- `<=` less than or equals, e.g. `age <= 10`
|
* If both operands are arrays, they will be compared for equivalence ignoring order, so this will be true: `[1, 2, 3] = [3, 2, 1]`
|
||||||
- `>` greater than, e.g. `age > 10`
|
* `!=` the exact inverse of the meaning of `=`, e.g. `name != "Pete"`
|
||||||
- `>=` greater than or equals, e.g. `age >= 10`
|
* `<` less than, e.g. `age < 10`
|
||||||
- `=~` to match against a regular expression, e.g. `name =~ /^template\//`
|
* `<=` less than or equals, e.g. `age <= 10`
|
||||||
- `!=~` to not match a regular expression, e.g. `name !=~ /^template\//`
|
* `>` greater than, e.g. `age > 10`
|
||||||
- `in` member of a list (e.g. `prop in ["foo", "bar"]`)
|
* `>=` greater than or equals, e.g. `age >= 10`
|
||||||
|
* `=~` to match against a regular expression, e.g. `name =~ /^template\//`
|
||||||
|
* `!=~` to not match a regular expression, e.g. `name !=~ /^template\//`
|
||||||
|
* `in` member of a list (e.g. `prop in ["foo", "bar"]`)
|
||||||
* `+` addition (can also concatenate strings), e.g. `10 + 12` or `name + "!!!"`
|
* `+` addition (can also concatenate strings), e.g. `10 + 12` or `name + "!!!"`
|
||||||
* `-` subtraction, e.g. `10 - 12`
|
* `-` subtraction, e.g. `10 - 12`
|
||||||
* `/` addition, e.g. `10 / 12`
|
* `/` addition, e.g. `10 / 12`
|
||||||
|
Loading…
Reference in New Issue
Block a user