Skip to content

Commit

Permalink
Misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
grassick committed Dec 10, 2019
1 parent a794769 commit 9ea0797
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
4 changes: 3 additions & 1 deletion lib/ExprEvaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions lib/ExprUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/ExprUtils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9ea0797

Please sign in to comment.