Implement CASE operator

This also modifies the behavior of AND/OR operators to strictly return
true/false/null whereas previously they could return the value of the
first truthy/false operand. The purpose of this change is to maintain
expression equivalency before and after minimization.
This commit is contained in:
Zaid Abdulla committed 2020-08-15 14:07:45 -07:00
1 parent e3ef177842
commit 6cbd59c6ec
8 files changed
+598 -273

No files matched your search

+3
View File
@@ -24,6 +24,7 @@ import * as mongodbFunctions from "../mongodb-functions";
import * as expression from "../common/expression";
import { QueryOptions, Expression } from "../types";
import { Readable } from "stream";
import { minimize } from "../common/boolean-expression";
const CACHE_TTL = 300000;
@@ -105,6 +106,7 @@ export function query(
options = options || {};
let q;
filter = expression.evaluate(filter, null, Date.now());
filter = minimize(filter, true);
if (Array.isArray(filter)) {
if (resource === "devices") {
@@ -204,6 +206,7 @@ export function query(
export function count(resource: string, filter: Expression): Promise<number> {
let q;
filter = expression.evaluate(filter, null, Date.now());
filter = minimize(filter, true);
if (Array.isArray(filter)) {
if (resource === "devices")