@malloydata/malloy 0.0.179 → 0.0.180-dev240906180931

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -795,13 +795,17 @@ class QueryField extends QueryNode {
795
795
  case '*':
796
796
  case '%':
797
797
  case '/':
798
- case '=':
799
- case '!=':
800
798
  case '>':
801
799
  case '<':
802
800
  case '>=':
803
801
  case '<=':
802
+ case '=':
804
803
  return `${expr.kids.left.sql}${expr.node}${expr.kids.right.sql}`;
804
+ // Malloy inequality comparisons always return a boolean
805
+ case '!=': {
806
+ const notEqual = `${expr.kids.left.sql}!=${expr.kids.right.sql}`;
807
+ return `COALESCE(${notEqual},true)`;
808
+ }
805
809
  case 'and':
806
810
  case 'or':
807
811
  return `${expr.kids.left.sql} ${expr.node} ${expr.kids.right.sql}`;
@@ -809,12 +813,16 @@ class QueryField extends QueryNode {
809
813
  return `COALESCE(${expr.kids.left.sql},${expr.kids.right.sql})`;
810
814
  case 'like':
811
815
  return `${expr.kids.left.sql} LIKE ${expr.kids.right.sql}`;
812
- case '!like':
813
- return `${expr.kids.left.sql} NOT LIKE ${expr.kids.right.sql}`;
816
+ // Malloy inequality comparisons always return a boolean
817
+ case '!like': {
818
+ const notLike = `${expr.kids.left.sql} NOT LIKE ${expr.kids.right.sql}`;
819
+ return `COALESCE(${notLike},true)`;
820
+ }
814
821
  case '()':
815
822
  return `(${expr.e.sql})`;
816
823
  case 'not':
817
- return `NOT ${expr.e.sql}`;
824
+ // Malloy not operator always returns a boolean
825
+ return `COALESCE(NOT ${expr.e.sql},TRUE)`;
818
826
  case 'unary-':
819
827
  return `-${expr.e.sql}`;
820
828
  case 'is-null':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.179",
3
+ "version": "0.0.180-dev240906180931",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -1,3 +0,0 @@
1
- import { Expr } from '../../../model/malloy_types';
2
- import { EqualityMalloyOperator } from '../types/binary_operators';
3
- export declare function nullsafeNot(expr: Expr, op?: EqualityMalloyOperator): Expr;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright 2023 Google LLC
4
- *
5
- * Permission is hereby granted, free of charge, to any person obtaining
6
- * a copy of this software and associated documentation files
7
- * (the "Software"), to deal in the Software without restriction,
8
- * including without limitation the rights to use, copy, modify, merge,
9
- * publish, distribute, sublicense, and/or sell copies of the Software,
10
- * and to permit persons to whom the Software is furnished to do so,
11
- * subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be
14
- * included in all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
- */
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.nullsafeNot = void 0;
26
- function nullsafeNot(expr, op) {
27
- if (op === undefined || op === '!=' || op === '!~') {
28
- return {
29
- node: 'not',
30
- e: {
31
- node: 'coalesce',
32
- kids: { left: expr, right: { node: 'false' } },
33
- },
34
- };
35
- }
36
- return expr;
37
- }
38
- exports.nullsafeNot = nullsafeNot;
39
- //# sourceMappingURL=utils.js.map