@malloydata/malloy 0.0.56-dev230710210438 → 0.0.56-dev230711015353
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.
|
@@ -358,7 +358,11 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
358
358
|
}
|
|
359
359
|
visitSQLSourceName(pcx) {
|
|
360
360
|
const name = this.getModelEntryName(pcx.sqlExploreNameRef());
|
|
361
|
-
|
|
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;
|
|
362
366
|
}
|
|
363
367
|
visitSqlSource(pcx) {
|
|
364
368
|
const connId = pcx.connectionId();
|
|
@@ -378,7 +382,11 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
378
382
|
visitQuerySource(pcx) {
|
|
379
383
|
const query = this.visit(pcx.query());
|
|
380
384
|
if (ast.isQueryElement(query)) {
|
|
381
|
-
|
|
385
|
+
const el = this.astAt(new ast.QuerySource(query), pcx);
|
|
386
|
+
if (this.m4WarningsEnabled()) {
|
|
387
|
+
this.astError(el, '`from(some_query)` is deprecated; use `some_query` directly', 'warn');
|
|
388
|
+
}
|
|
389
|
+
return el;
|
|
382
390
|
}
|
|
383
391
|
throw this.internalError(pcx, `Expect query definition, got a '${query.elementType}'`);
|
|
384
392
|
}
|
|
@@ -2937,6 +2937,18 @@ describe('sql expressions', () => {
|
|
|
2937
2937
|
}
|
|
2938
2938
|
expect(m).toTranslateWithWarnings('`sql:` statement is deprecated, use `connection_name.sql(...)` instead');
|
|
2939
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
|
+
});
|
|
2940
2952
|
test('reference to sql expression in run', () => {
|
|
2941
2953
|
const m = new test_translator_1.TestTranslator(`
|
|
2942
2954
|
run: bigquery.sql("""select 1 as one""")
|
|
@@ -3196,6 +3208,20 @@ describe('extend and refine', () => {
|
|
|
3196
3208
|
});
|
|
3197
3209
|
});
|
|
3198
3210
|
describe('miscellaneous m4 warnings', () => {
|
|
3211
|
+
test('from() is deprecated', () => {
|
|
3212
|
+
expect(`
|
|
3213
|
+
##! m4warnings
|
|
3214
|
+
query: q is a -> { project: * }
|
|
3215
|
+
source: c is from(q) extend {
|
|
3216
|
+
dimension: x is 1
|
|
3217
|
+
}`).toTranslateWithWarnings('`from(some_query)` is deprecated; use `some_query` directly');
|
|
3218
|
+
expect(`
|
|
3219
|
+
##! m4warnings
|
|
3220
|
+
query: q is a -> { project: * }
|
|
3221
|
+
source: c is q extend {
|
|
3222
|
+
dimension: x is 1
|
|
3223
|
+
}`).toTranslate();
|
|
3224
|
+
});
|
|
3199
3225
|
test('query leading arrow', () => {
|
|
3200
3226
|
expect(`
|
|
3201
3227
|
##! m4warnings
|