@malloydata/malloy 0.0.56-dev230710210430 → 0.0.56-dev230710210438
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.
|
@@ -163,6 +163,9 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
163
163
|
}
|
|
164
164
|
getFilterShortcut(cx) {
|
|
165
165
|
const el = this.getFilterElement(cx.fieldExpr());
|
|
166
|
+
if (this.m4WarningsEnabled()) {
|
|
167
|
+
this.astError(el, 'Filter shortcut `{? condition }` is deprecated; use `{ where: condition } instead', 'warn');
|
|
168
|
+
}
|
|
166
169
|
return new ast.Filter([el]);
|
|
167
170
|
}
|
|
168
171
|
getPlainString(cx) {
|
|
@@ -278,7 +281,11 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
278
281
|
visitQueryByName(pcx) {
|
|
279
282
|
const query = new ast.ExistingQuery();
|
|
280
283
|
query.head = this.getModelEntryName(pcx);
|
|
281
|
-
|
|
284
|
+
const res = this.astAt(query, pcx);
|
|
285
|
+
if (this.m4WarningsEnabled() && pcx.ARROW()) {
|
|
286
|
+
this.astError(res, 'Leading arrow (`->`) when referencing a query is deprecated; remove the arrow', 'warn');
|
|
287
|
+
}
|
|
288
|
+
return res;
|
|
282
289
|
}
|
|
283
290
|
getSourceExtensions(pcx) {
|
|
284
291
|
const extensions = pcx === null || pcx === void 0 ? void 0 : pcx.exploreProperties();
|
|
@@ -530,7 +537,11 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
530
537
|
}
|
|
531
538
|
visitFilterByShortcut(pcx) {
|
|
532
539
|
const el = this.getFilterElement(pcx.fieldExpr());
|
|
533
|
-
|
|
540
|
+
const res = this.astAt(new ast.Filter([el]), pcx);
|
|
541
|
+
if (this.m4WarningsEnabled()) {
|
|
542
|
+
this.astError(el, 'Filter shortcut `{? condition }` is deprecated; use `{ where: condition } instead', 'warn');
|
|
543
|
+
}
|
|
544
|
+
return res;
|
|
534
545
|
}
|
|
535
546
|
visitWhereStatement(pcx) {
|
|
536
547
|
const where = this.visitFilterClauseList(pcx.filterClauseList());
|
|
@@ -65,6 +65,12 @@ describe('model statements', () => {
|
|
|
65
65
|
test('shorcut fitlered table', () => {
|
|
66
66
|
expect("source: xA is table('aTable') {? astr ~ 'a%' }").toTranslate();
|
|
67
67
|
});
|
|
68
|
+
test('shorcut fitlered table m4warning', () => {
|
|
69
|
+
expect(`
|
|
70
|
+
##! m4warnings
|
|
71
|
+
source: xA is conn.table('aTable') extend {? astr ~ 'a%' }
|
|
72
|
+
`).toTranslateWithWarnings('Filter shortcut `{? condition }` is deprecated; use `{ where: condition } instead');
|
|
73
|
+
});
|
|
68
74
|
test('fitlered table', () => {
|
|
69
75
|
expect("source: testA is table('aTable') { where: astr ~ 'a%' }").toTranslate();
|
|
70
76
|
});
|
|
@@ -130,6 +136,12 @@ describe('model statements', () => {
|
|
|
130
136
|
test('query with shortcut filtered turtle', () => {
|
|
131
137
|
expect("query: allA is ab->aturtle {? astr ~ 'a%' }").toTranslate();
|
|
132
138
|
});
|
|
139
|
+
test('query with shortcut filtered turtle m4warning', () => {
|
|
140
|
+
expect(`
|
|
141
|
+
##! m4warnings
|
|
142
|
+
query: allA is ab->aturtle refine {? astr ~ 'a%' }
|
|
143
|
+
`).toTranslateWithWarnings('Filter shortcut `{? condition }` is deprecated; use `{ where: condition } instead');
|
|
144
|
+
});
|
|
133
145
|
test('query with filtered turtle', () => {
|
|
134
146
|
expect("query: allA is ab->aturtle { where: astr ~ 'a%' }").toTranslate();
|
|
135
147
|
});
|
|
@@ -779,6 +791,14 @@ describe('source properties', () => {
|
|
|
779
791
|
}
|
|
780
792
|
`).toTranslate();
|
|
781
793
|
});
|
|
794
|
+
test('refined explore-query m4warning', () => {
|
|
795
|
+
expect(`
|
|
796
|
+
##! m4warnings
|
|
797
|
+
source: abNew is ab extend {
|
|
798
|
+
query: for1 is aturtle refine {? ai = 1 }
|
|
799
|
+
}
|
|
800
|
+
`).toTranslateWithWarnings('Filter shortcut `{? condition }` is deprecated; use `{ where: condition } instead');
|
|
801
|
+
});
|
|
782
802
|
test('chained explore-query', () => {
|
|
783
803
|
expect(`
|
|
784
804
|
source: c is a {
|
|
@@ -1345,6 +1365,15 @@ describe('expressions', () => {
|
|
|
1345
1365
|
}
|
|
1346
1366
|
`).toTranslate();
|
|
1347
1367
|
});
|
|
1368
|
+
test('shortcut filtered measure m4warning', () => {
|
|
1369
|
+
expect(`
|
|
1370
|
+
##! m4warnings
|
|
1371
|
+
run: a -> {
|
|
1372
|
+
group_by: ai
|
|
1373
|
+
aggregate: x is avg(ai) {? astr = 'why?' }
|
|
1374
|
+
}
|
|
1375
|
+
`).toTranslateWithWarnings('Filter shortcut `{? condition }` is deprecated; use `{ where: condition } instead');
|
|
1376
|
+
});
|
|
1348
1377
|
test('correctly flags filtered scalar', () => {
|
|
1349
1378
|
const e = new test_translator_1.BetaExpression('ai { where: true }');
|
|
1350
1379
|
expect(e).translationToFailWith('Filtered expression requires an aggregate computation');
|
|
@@ -3166,4 +3195,28 @@ describe('extend and refine', () => {
|
|
|
3166
3195
|
});
|
|
3167
3196
|
});
|
|
3168
3197
|
});
|
|
3198
|
+
describe('miscellaneous m4 warnings', () => {
|
|
3199
|
+
test('query leading arrow', () => {
|
|
3200
|
+
expect(`
|
|
3201
|
+
##! m4warnings
|
|
3202
|
+
query: x is a -> { project: * }
|
|
3203
|
+
run: x
|
|
3204
|
+
`).toTranslate();
|
|
3205
|
+
expect(`
|
|
3206
|
+
##! m4warnings
|
|
3207
|
+
query: x is a -> { project: * }
|
|
3208
|
+
run: x -> { project: * }
|
|
3209
|
+
`).toTranslate();
|
|
3210
|
+
expect(`
|
|
3211
|
+
##! m4warnings
|
|
3212
|
+
query: x is a -> { project: * }
|
|
3213
|
+
run: -> x
|
|
3214
|
+
`).toTranslateWithWarnings('Leading arrow (`->`) when referencing a query is deprecated; remove the arrow');
|
|
3215
|
+
expect(`
|
|
3216
|
+
##! m4warnings
|
|
3217
|
+
query: x is a -> { project: * }
|
|
3218
|
+
run: -> x -> { project: * }
|
|
3219
|
+
`).toTranslateWithWarnings('Leading arrow (`->`) when referencing a query is deprecated; remove the arrow');
|
|
3220
|
+
});
|
|
3221
|
+
});
|
|
3169
3222
|
//# sourceMappingURL=parse.spec.js.map
|