@malloydata/malloy 0.0.56-dev230710162623 → 0.0.56-dev230710182711

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.
@@ -179,7 +179,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
179
179
  if (multiLineStr) {
180
180
  for (const part of (0, parse_utils_1.getStringParts)(multiLineStr)) {
181
181
  if (part instanceof antlr4ts_1.ParserRuleContext) {
182
- this.contextError(part, '%{ query }% illegal in this string');
182
+ this.contextError(part, '%{ query } illegal in this string');
183
183
  }
184
184
  else {
185
185
  safeParts.push(part);
@@ -128,10 +128,10 @@ describe('sql:', () => {
128
128
  model.update({ compileSQL: { [sql.name]: makeSchemaResponse(sql) } });
129
129
  expect(model).toTranslate();
130
130
  });
131
- it('turducken', () => {
131
+ it('simple turducken', () => {
132
132
  const m = new test_translator_1.TestTranslator(`
133
133
  sql: someSql is {
134
- select: """SELECT * FROM %{ a -> { group_by: astr } }% WHERE 1=1"""
134
+ select: """SELECT * FROM %{ a -> { group_by: astr } } WHERE 1=1"""
135
135
  }
136
136
  `);
137
137
  expect(m).toParse();
@@ -146,6 +146,56 @@ describe('sql:', () => {
146
146
  expect(where).toEqual({ sql: ' WHERE 1=1' });
147
147
  }
148
148
  });
149
+ it('old style ', () => {
150
+ const m = new test_translator_1.TestTranslator(`
151
+ sql: someSql is {
152
+ select: """SELECT * FROM %{ a -> { group_by: astr } } WHERE 1=1"""
153
+ }
154
+ `);
155
+ expect(m).toParse();
156
+ const compileSql = m.translate().compileSQL;
157
+ expect(compileSql).toBeDefined();
158
+ if (compileSql) {
159
+ const select = compileSql.select[0];
160
+ const star = compileSql.select[1];
161
+ const where = compileSql.select[2];
162
+ expect(select).toEqual({ sql: 'SELECT * FROM ' });
163
+ expect((0, model_1.isSQLFragment)(star)).toBeFalsy();
164
+ expect(where).toEqual({ sql: ' WHERE 1=1' });
165
+ }
166
+ });
167
+ it('turduckenzilla', () => {
168
+ const m = new test_translator_1.TestTranslator(`
169
+ run: duckdb.sql("""
170
+ SELECT * from (%{
171
+ duckdb.sql("""SELECT 2 as two""") {
172
+ query: b is {
173
+ nest: c is {
174
+ extend: {
175
+ join_one: d is duckdb.sql("""
176
+ SELECT * from (%{
177
+ duckdb.sql("""SELECT 3 as three""") {
178
+ query: b is {
179
+ nest: c is {
180
+ extend: {
181
+ join_one: d is duckdb.sql("""SELECT 4 as four""") on three = d.four - 1
182
+ }
183
+ group_by: three
184
+ }
185
+ }
186
+ } -> { group_by: three }
187
+ })
188
+ """) on two = d.three
189
+ }
190
+ group_by: two
191
+ }
192
+ }
193
+ } -> { group_by: two }
194
+ })
195
+ """) -> { group_by: two }
196
+ `);
197
+ expect(m).toParse();
198
+ });
149
199
  it('model preserved', () => {
150
200
  const shouldBeOK = `
151
201
  source: newa is a
@@ -101,7 +101,7 @@ describe('string parsing in language', () => {
101
101
  expect(m).toParse();
102
102
  });
103
103
  test('timezone with illegal query', () => {
104
- expect(`run: a->{timezone: """${tz}%{ab->aturtle}%"""; project: *}`).translationToFailWith('%{ query }% illegal in this string');
104
+ expect(`run: a->{timezone: """${tz}%{ab->aturtle}"""; project: *}`).translationToFailWith('%{ query } illegal in this string');
105
105
  });
106
106
  test('table single quote', () => {
107
107
  const m = new test_translator_1.TestTranslator("source: n is bigquery.table('n')");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.56-dev230710162623",
3
+ "version": "0.0.56-dev230710182711",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",