From 9ea07973c598df335e7fbe18e3d0268c08b09295 Mon Sep 17 00:00:00 2001 From: Clayton Grassick Date: Tue, 10 Dec 2019 10:41:15 -0500 Subject: [PATCH] Misc fixes --- lib/ExprEvaluator.js | 4 +++- lib/ExprUtils.js | 14 +++++++------- package-lock.json | 8 ++++---- src/ExprUtils.coffee | 6 +++--- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/ExprEvaluator.js b/lib/ExprEvaluator.js index 8840412..1d8cd6b 100644 --- a/lib/ExprEvaluator.js +++ b/lib/ExprEvaluator.js @@ -1257,7 +1257,9 @@ function () { return callback(null, result); }); - } + } // NOTE: This is not technically correct. It's not a window function (as window + // functions can't be used in where clauses) but rather a special query + }, { key: "evaluateIsLatest", value: function evaluateIsLatest(table, exprs, context, callback) { diff --git a/lib/ExprUtils.js b/lib/ExprUtils.js index 6d95dfe..51dca5c 100644 --- a/lib/ExprUtils.js +++ b/lib/ExprUtils.js @@ -51,7 +51,7 @@ function () { function ExprUtils(schema) { var variables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; (0, _classCallCheck2["default"])(this, ExprUtils); - // Replace variables with literal values + // Replace variables with literal values. this.inlineVariableValues = this.inlineVariableValues.bind(this); this.schema = schema; this.variables = variables; @@ -795,7 +795,7 @@ function () { value: function summarizeExpr(expr, locale) { var _this3 = this; - var opItem, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, variable; + var opItem, ref, ref1, ref10, ref11, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, variable; if (!expr) { return "None"; // TODO localize @@ -813,26 +813,26 @@ function () { case "op": // Special case for contains/intersects with literal RHS - if (expr.op === "contains" && ((ref2 = expr.exprs[1]) != null ? ref2.type : void 0) === "literal") { + if (expr.op === "contains" && ((ref2 = expr.exprs[1]) != null ? ref2.type : void 0) === "literal" && ((ref3 = expr.exprs[1]) != null ? ref3.valueType : void 0) === "enumset") { return this.summarizeExpr(expr.exprs[0], locale) + " includes all of " + this.stringifyLiteralValue("enumset", expr.exprs[1].value, locale, this.getExprEnumValues(expr.exprs[0])); } - if (expr.op === "intersects" && ((ref3 = expr.exprs[1]) != null ? ref3.type : void 0) === "literal") { + if (expr.op === "intersects" && ((ref4 = expr.exprs[1]) != null ? ref4.type : void 0) === "literal" && ((ref5 = expr.exprs[1]) != null ? ref5.valueType : void 0) === "enumset") { return this.summarizeExpr(expr.exprs[0], locale) + " includes any of " + this.stringifyLiteralValue("enumset", expr.exprs[1].value, locale, this.getExprEnumValues(expr.exprs[0])); } // Special case for = any with literal RHS - if (expr.op === "= any" && ((ref4 = expr.exprs[1]) != null ? ref4.type : void 0) === "literal") { + if (expr.op === "= any" && ((ref6 = expr.exprs[1]) != null ? ref6.type : void 0) === "literal" && ((ref7 = expr.exprs[1]) != null ? ref7.valueType : void 0) === "enumset") { return this.summarizeExpr(expr.exprs[0], locale) + " is any of " + this.stringifyLiteralValue("enumset", expr.exprs[1].value, locale, this.getExprEnumValues(expr.exprs[0])); } // Special case for = with literal RHS - if (expr.op === "=" && ((ref5 = expr.exprs[1]) != null ? ref5.type : void 0) === "literal" && ((ref6 = expr.exprs[1]) != null ? ref6.valueType : void 0) === "enum") { + if (expr.op === "=" && ((ref8 = expr.exprs[1]) != null ? ref8.type : void 0) === "literal" && ((ref9 = expr.exprs[1]) != null ? ref9.valueType : void 0) === "enum") { return this.summarizeExpr(expr.exprs[0], locale) + " is " + this.stringifyLiteralValue("enum", expr.exprs[1].value, locale, this.getExprEnumValues(expr.exprs[0])); } // Special case for <> with literal RHS - if (expr.op === "<>" && ((ref7 = expr.exprs[1]) != null ? ref7.type : void 0) === "literal" && ((ref8 = expr.exprs[1]) != null ? ref8.valueType : void 0) === "enum") { + if (expr.op === "<>" && ((ref10 = expr.exprs[1]) != null ? ref10.type : void 0) === "literal" && ((ref11 = expr.exprs[1]) != null ? ref11.valueType : void 0) === "enum") { return this.summarizeExpr(expr.exprs[0], locale) + " is not " + this.stringifyLiteralValue("enum", expr.exprs[1].value, locale, this.getExprEnumValues(expr.exprs[0])); } // Special case for count diff --git a/package-lock.json b/package-lock.json index 98ec9c7..edca50d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6049,9 +6049,9 @@ "dev": true }, "js-yaml": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", - "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" @@ -6206,7 +6206,7 @@ "dev": true }, "jsonql": { - "version": "github:mWater/jsonql#becb73ddd13727b03078369b101c1902c00b7469", + "version": "github:mWater/jsonql#b9c21ac49cb1e3b0b77fc3411d85431249b0a003", "from": "github:mWater/jsonql", "requires": { "js-yaml": "^3.3.1", diff --git a/src/ExprUtils.coffee b/src/ExprUtils.coffee index 3317597..f2ed5a8 100644 --- a/src/ExprUtils.coffee +++ b/src/ExprUtils.coffee @@ -410,14 +410,14 @@ module.exports = class ExprUtils return @localizeString(@schema.getTable(expr.table)?.name, locale) when "op" # Special case for contains/intersects with literal RHS - if expr.op == "contains" and expr.exprs[1]?.type == "literal" + if expr.op == "contains" and expr.exprs[1]?.type == "literal" and expr.exprs[1]?.valueType == "enumset" return @summarizeExpr(expr.exprs[0], locale) + " includes all of " + @stringifyLiteralValue("enumset", expr.exprs[1].value, locale, @getExprEnumValues(expr.exprs[0])) - if expr.op == "intersects" and expr.exprs[1]?.type == "literal" + if expr.op == "intersects" and expr.exprs[1]?.type == "literal" and expr.exprs[1]?.valueType == "enumset" return @summarizeExpr(expr.exprs[0], locale) + " includes any of " + @stringifyLiteralValue("enumset", expr.exprs[1].value, locale, @getExprEnumValues(expr.exprs[0])) # Special case for = any with literal RHS - if expr.op == "= any" and expr.exprs[1]?.type == "literal" + if expr.op == "= any" and expr.exprs[1]?.type == "literal" and expr.exprs[1]?.valueType == "enumset" return @summarizeExpr(expr.exprs[0], locale) + " is any of " + @stringifyLiteralValue("enumset", expr.exprs[1].value, locale, @getExprEnumValues(expr.exprs[0])) # Special case for = with literal RHS