@malloydata/malloy 0.0.12 → 0.0.13-dev221205193434

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.
@@ -299,6 +299,7 @@ export declare class Document extends MalloyElement implements NameSpace {
299
299
  queryList: model.Query[];
300
300
  sqlBlocks: model.SQLBlockStructDef[];
301
301
  statements: RunList;
302
+ didInitModel: boolean;
302
303
  constructor(statements: DocStatement[]);
303
304
  initModelDef(extendingModelDef: model.ModelDef | undefined): void;
304
305
  compile(): DocumentCompileResult;
@@ -1408,10 +1408,14 @@ class Document extends MalloyElement {
1408
1408
  this.documentModel = {};
1409
1409
  this.queryList = [];
1410
1410
  this.sqlBlocks = [];
1411
+ this.didInitModel = false;
1411
1412
  this.statements = new RunList("topLevelStatements", statements);
1412
1413
  this.has({ statements });
1413
1414
  }
1414
1415
  initModelDef(extendingModelDef) {
1416
+ if (this.didInitModel) {
1417
+ return;
1418
+ }
1415
1419
  this.documentModel = {};
1416
1420
  this.queryList = [];
1417
1421
  this.sqlBlocks = [];
@@ -1424,6 +1428,7 @@ class Document extends MalloyElement {
1424
1428
  }
1425
1429
  }
1426
1430
  }
1431
+ this.didInitModel = true;
1427
1432
  }
1428
1433
  compile() {
1429
1434
  const needs = this.statements.executeList(this);
@@ -1174,6 +1174,22 @@ describe("sql:", () => {
1174
1174
  expect(where).toEqual({ sql: " WHERE 1=1" });
1175
1175
  }
1176
1176
  });
1177
+ it("model preserved", () => {
1178
+ const selStmt = "SELECT * FROM aTable";
1179
+ const shouldBeOK = `
1180
+ source: newa is a
1181
+ sql: someSql is { select: """${selStmt}""" }
1182
+ source: newaa is newa
1183
+ `;
1184
+ const model = new BetaModel(shouldBeOK);
1185
+ expect(model).modelParsed();
1186
+ const needReq = model.translate();
1187
+ const needs = needReq === null || needReq === void 0 ? void 0 : needReq.compileSQL;
1188
+ expect(needs).toBeDefined();
1189
+ const sql = (0, sql_block_1.makeSQLBlock)([{ sql: selStmt }]);
1190
+ model.update({ compileSQL: { [sql.name]: makeSchemaResponse(sql) } });
1191
+ expect(model).modelCompiled();
1192
+ });
1177
1193
  });
1178
1194
  describe("error handling", () => {
1179
1195
  test("field and query with same name does not overflow", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.12",
3
+ "version": "0.0.13-dev221205193434",
4
4
  "license": "GPL-2.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",