@malloydata/malloy 0.0.320 → 0.0.321
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.
|
@@ -925,7 +925,7 @@ function isSingleValueFilterNode(e) {
|
|
|
925
925
|
return [];
|
|
926
926
|
if ((result.parsed.operator === 'null' && !result.parsed.not) ||
|
|
927
927
|
(result.kind === 'boolean' &&
|
|
928
|
-
['false', 'true'].includes(result.parsed.operator) &&
|
|
928
|
+
['true', '=false', '=true'].includes(result.parsed.operator) &&
|
|
929
929
|
!result.parsed.not) ||
|
|
930
930
|
(result.kind === 'date' &&
|
|
931
931
|
result.parsed.operator === 'in' &&
|
|
@@ -3,7 +3,7 @@ import type { Dialect, QueryInfo } from '../dialect';
|
|
|
3
3
|
export declare const FilterCompilers: {
|
|
4
4
|
compile(t: string, c: FilterExpression | null, x: string, d: Dialect, qi?: QueryInfo): string;
|
|
5
5
|
numberCompile(nc: NumberFilter, x: string, d: Dialect): string;
|
|
6
|
-
booleanCompile(bc: BooleanFilter, x: string,
|
|
6
|
+
booleanCompile(bc: BooleanFilter, x: string, d: Dialect): string;
|
|
7
7
|
stringCompile(sc: StringFilter, x: string, d: Dialect): string;
|
|
8
8
|
temporalCompile(tc: TemporalFilter, x: string, d: Dialect, t: "date" | "timestamp", qi?: QueryInfo): string;
|
|
9
9
|
};
|
|
@@ -100,19 +100,52 @@ exports.FilterCompilers = {
|
|
|
100
100
|
.join(` ${nc.operator.toUpperCase()} `);
|
|
101
101
|
}
|
|
102
102
|
},
|
|
103
|
-
booleanCompile(bc, x,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
booleanCompile(bc, x, d) {
|
|
104
|
+
const px = `(${x})`;
|
|
105
|
+
/*
|
|
106
|
+
* We have the following truth table for boolean filters.
|
|
107
|
+
* The default malloy operations treat null as false. The '='
|
|
108
|
+
* variants exist for cases where that is not desired.
|
|
109
|
+
*
|
|
110
|
+
* filter expression | x=true | x=false | x=null
|
|
111
|
+
* true | T | F | F
|
|
112
|
+
* not true | F | T | T
|
|
113
|
+
* =true | T | F | NULL
|
|
114
|
+
* not =true | F | T | NULL
|
|
115
|
+
* false | F | T | T
|
|
116
|
+
* not false | T | F | F
|
|
117
|
+
* =false | F | T | NULL
|
|
118
|
+
* not =false | T | F | NULL
|
|
119
|
+
*/
|
|
120
|
+
if (bc.operator === '=true') {
|
|
121
|
+
return bc.not ? `NOT ${px}` : x;
|
|
122
|
+
}
|
|
123
|
+
else if (bc.operator === '=false') {
|
|
124
|
+
return bc.not ? x : `NOT ${px}`;
|
|
125
|
+
}
|
|
126
|
+
else if (bc.operator === 'null') {
|
|
127
|
+
return bc.not ? `${px} IS NOT NULL` : `${px} IS NULL`;
|
|
128
|
+
}
|
|
129
|
+
// For some databases checking NULL combined with a boolean check
|
|
130
|
+
// is faster than a COALESCE, for now, just detect if the expression
|
|
131
|
+
// is just a column reference, and if so, don't use COALECSE.
|
|
132
|
+
const quoteChar = d.sqlMaybeQuoteIdentifier('select')[0];
|
|
133
|
+
const isColumn = x.match(`^[()${quoteChar}\\w.]+$`);
|
|
134
|
+
if (isColumn) {
|
|
135
|
+
if (bc.operator === 'true') {
|
|
108
136
|
return bc.not
|
|
109
|
-
?
|
|
110
|
-
:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
137
|
+
? `${px} IS NULL OR ${px} = false`
|
|
138
|
+
: `${px} IS NOT NULL AND ${px}`;
|
|
139
|
+
}
|
|
140
|
+
return bc.not
|
|
141
|
+
? `${px} IS NOT NULL AND ${px}` // not false: exclude null
|
|
142
|
+
: `${px} IS NULL OR ${px} = false`; // false: include null
|
|
143
|
+
}
|
|
144
|
+
if (bc.operator === 'true') {
|
|
145
|
+
return bc.not ? `NOT COALESCE(${x}, false)` : `COALESCE(${x}, false)`;
|
|
115
146
|
}
|
|
147
|
+
// else bc.operator === 'false'
|
|
148
|
+
return bc.not ? `COALESCE(${x}, false)` : `NOT COALESCE(${x}, false)`;
|
|
116
149
|
},
|
|
117
150
|
stringCompile(sc, x, d) {
|
|
118
151
|
switch (sc.operator) {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MALLOY_VERSION = "0.0.
|
|
1
|
+
export declare const MALLOY_VERSION = "0.0.321";
|
package/dist/version.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MALLOY_VERSION = void 0;
|
|
4
4
|
// generated with 'generate-version-file' script; do not edit manually
|
|
5
|
-
exports.MALLOY_VERSION = '0.0.
|
|
5
|
+
exports.MALLOY_VERSION = '0.0.321';
|
|
6
6
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.321",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"generate-version-file": "VERSION=$(npm pkg get version --workspaces=false | tr -d \\\")\necho \"// generated with 'generate-version-file' script; do not edit manually\\nexport const MALLOY_VERSION = '$VERSION';\" > src/version.ts"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@malloydata/malloy-filter": "0.0.
|
|
45
|
-
"@malloydata/malloy-interfaces": "0.0.
|
|
46
|
-
"@malloydata/malloy-tag": "0.0.
|
|
44
|
+
"@malloydata/malloy-filter": "0.0.321",
|
|
45
|
+
"@malloydata/malloy-interfaces": "0.0.321",
|
|
46
|
+
"@malloydata/malloy-tag": "0.0.321",
|
|
47
47
|
"antlr4ts": "^0.5.0-alpha.4",
|
|
48
48
|
"assert": "^2.0.0",
|
|
49
49
|
"jaro-winkler": "^0.2.8",
|