@malloydata/malloy 0.0.3 → 0.0.5
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.
|
@@ -141,7 +141,6 @@ export declare class ExprParens extends ExpressionDef {
|
|
|
141
141
|
readonly expr: ExpressionDef;
|
|
142
142
|
elementType: string;
|
|
143
143
|
constructor(expr: ExpressionDef);
|
|
144
|
-
apply(fs: FieldSpace, op: string, expr: ExpressionDef): ExprValue;
|
|
145
144
|
requestExpression(fs: FieldSpace): ExprValue | undefined;
|
|
146
145
|
getExpression(fs: FieldSpace): ExprValue;
|
|
147
146
|
}
|
|
@@ -426,9 +426,6 @@ class ExprParens extends ExpressionDef {
|
|
|
426
426
|
this.expr = expr;
|
|
427
427
|
this.elementType = "(expression)";
|
|
428
428
|
}
|
|
429
|
-
apply(fs, op, expr) {
|
|
430
|
-
return this.expr.apply(fs, op, expr);
|
|
431
|
-
}
|
|
432
429
|
requestExpression(fs) {
|
|
433
430
|
return this.expr.requestExpression(fs);
|
|
434
431
|
}
|
|
@@ -303,9 +303,9 @@ export declare class WildcardFieldReference extends MalloyElement {
|
|
|
303
303
|
}
|
|
304
304
|
export declare class OrderBy extends MalloyElement {
|
|
305
305
|
readonly field: number | FieldName;
|
|
306
|
-
readonly dir?: "
|
|
306
|
+
readonly dir?: "asc" | "desc" | undefined;
|
|
307
307
|
elementType: string;
|
|
308
|
-
constructor(field: number | FieldName, dir?: "
|
|
308
|
+
constructor(field: number | FieldName, dir?: "asc" | "desc" | undefined);
|
|
309
309
|
get modelField(): string | number;
|
|
310
310
|
getOrderBy(_fs: FieldSpace): model.OrderBy;
|
|
311
311
|
}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* GNU General Public License for more details.
|
|
14
14
|
*/
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
const model_1 = require("../../model");
|
|
16
17
|
const sql_block_1 = require("../../model/sql_block");
|
|
17
18
|
const ast_1 = require("../ast");
|
|
18
19
|
const field_space_1 = require("../field-space");
|
|
@@ -961,6 +962,34 @@ describe("expressions", () => {
|
|
|
961
962
|
`).compileToFailWith("pick type 'number', expected 'string'", "Cannot define 'd', value has unknown type");
|
|
962
963
|
});
|
|
963
964
|
});
|
|
965
|
+
test("paren and applied div", () => {
|
|
966
|
+
var _a, _b;
|
|
967
|
+
const modelSrc = `query: z is a -> { group_by: x is 1+(3/4) }`;
|
|
968
|
+
const m = new BetaModel(modelSrc);
|
|
969
|
+
expect(m).toTranslate();
|
|
970
|
+
const queryDef = (_b = (_a = m.translate()) === null || _a === void 0 ? void 0 : _a.translated) === null || _b === void 0 ? void 0 : _b.modelDef.contents.z;
|
|
971
|
+
expect(queryDef).toBeDefined();
|
|
972
|
+
expect(queryDef === null || queryDef === void 0 ? void 0 : queryDef.type).toBe("query");
|
|
973
|
+
if (queryDef && queryDef.type == "query") {
|
|
974
|
+
const x = queryDef.pipeline[0].fields[0];
|
|
975
|
+
if (typeof x != "string" &&
|
|
976
|
+
!(0, model_1.isFilteredAliasedName)(x) &&
|
|
977
|
+
(0, model_1.isFieldTypeDef)(x) &&
|
|
978
|
+
x.type == "number" &&
|
|
979
|
+
x.e) {
|
|
980
|
+
const firstFrag = x.e[0];
|
|
981
|
+
if (typeof firstFrag == "string") {
|
|
982
|
+
expect(firstFrag).toContain("(");
|
|
983
|
+
}
|
|
984
|
+
else {
|
|
985
|
+
fail("expression with parens compiled oddly");
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
else {
|
|
989
|
+
fail("expression with parens compiled oddly");
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
});
|
|
964
993
|
});
|
|
965
994
|
describe("sql backdoor", () => {
|
|
966
995
|
function makeSchemaResponse(sql) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"license": "GPL-2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"testLang": "npm run test --testPathPattern=packages/malloy/src/lang",
|
|
16
16
|
"clean": "rm -rf src/lang/lib",
|
|
17
17
|
"build": "npm run build-parser && tsc --build",
|
|
18
|
-
"malloyc": "ts-node ../../scripts/malloy-to-json"
|
|
18
|
+
"malloyc": "ts-node ../../scripts/malloy-to-json",
|
|
19
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
19
20
|
},
|
|
20
21
|
"dependencies": {
|
|
21
22
|
"antlr4ts": "^0.5.0-alpha.4",
|