@malloydata/malloy 0.0.56-dev230710210339 → 0.0.56-dev230710210433

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) {
@@ -355,7 +358,11 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
355
358
  }
356
359
  visitSQLSourceName(pcx) {
357
360
  const name = this.getModelEntryName(pcx.sqlExploreNameRef());
358
- return this.astAt(new ast.FromSQLSource(name), pcx);
361
+ const res = this.astAt(new ast.FromSQLSource(name), pcx);
362
+ if (this.m4WarningsEnabled()) {
363
+ this.astError(res, '`from_sql` is deprecated; use `connection_name.sql(...)` as a source directly', 'warn');
364
+ }
365
+ return res;
359
366
  }
360
367
  visitSqlSource(pcx) {
361
368
  const connId = pcx.connectionId();
@@ -534,7 +541,11 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
534
541
  }
535
542
  visitFilterByShortcut(pcx) {
536
543
  const el = this.getFilterElement(pcx.fieldExpr());
537
- return this.astAt(new ast.Filter([el]), pcx);
544
+ const res = this.astAt(new ast.Filter([el]), pcx);
545
+ if (this.m4WarningsEnabled()) {
546
+ this.astError(el, 'Filter shortcut `{? condition }` is deprecated; use `{ where: condition } instead', 'warn');
547
+ }
548
+ return res;
538
549
  }
539
550
  visitWhereStatement(pcx) {
540
551
  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');
@@ -2908,6 +2937,18 @@ describe('sql expressions', () => {
2908
2937
  }
2909
2938
  expect(m).toTranslateWithWarnings('`sql:` statement is deprecated, use `connection_name.sql(...)` instead');
2910
2939
  });
2940
+ test('from_sql deprecation warning', () => {
2941
+ const m = new test_translator_1.TestTranslator(`##! m4warnings
2942
+ sql: bad_sql is {select: """SELECT 1 as one"""}
2943
+ source: foo is from_sql(bad_sql)`);
2944
+ const req = m.translate().compileSQL;
2945
+ if (req) {
2946
+ m.update({
2947
+ compileSQL: { [req.name]: getSelectOneStruct(req) },
2948
+ });
2949
+ }
2950
+ expect(m).toTranslateWithWarnings('`sql:` statement is deprecated, use `connection_name.sql(...)` instead', '`from_sql` is deprecated; use `connection_name.sql(...)` as a source directly');
2951
+ });
2911
2952
  test('reference to sql expression in run', () => {
2912
2953
  const m = new test_translator_1.TestTranslator(`
2913
2954
  run: bigquery.sql("""select 1 as one""")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.56-dev230710210339",
3
+ "version": "0.0.56-dev230710210433",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",