@malloydata/malloy 0.0.85 → 0.0.86-dev230921221205
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.
- package/dist/malloy.js +11 -11
- package/package.json +1 -1
package/dist/malloy.js
CHANGED
|
@@ -178,10 +178,13 @@ class Malloy {
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
static compileSQLBlock(partialModel, toCompile) {
|
|
181
|
-
let queryModel;
|
|
182
|
-
|
|
181
|
+
let queryModel = undefined;
|
|
182
|
+
let selectStr = '';
|
|
183
|
+
let parenAlready = false;
|
|
184
|
+
for (const segment of toCompile.select) {
|
|
183
185
|
if ((0, model_1.isSQLFragment)(segment)) {
|
|
184
|
-
|
|
186
|
+
selectStr += segment.sql;
|
|
187
|
+
parenAlready = segment.sql.match(/\(\s*$/) !== null;
|
|
185
188
|
}
|
|
186
189
|
else {
|
|
187
190
|
// TODO catch exceptions and throw errors ...
|
|
@@ -191,16 +194,13 @@ class Malloy {
|
|
|
191
194
|
}
|
|
192
195
|
queryModel = new model_1.QueryModel(partialModel);
|
|
193
196
|
}
|
|
194
|
-
|
|
197
|
+
const compiledSql = queryModel.compileQuery(segment, false).sql;
|
|
198
|
+
selectStr += parenAlready ? compiledSql : `(${compiledSql})`;
|
|
199
|
+
parenAlready = false;
|
|
195
200
|
}
|
|
196
|
-
}
|
|
201
|
+
}
|
|
197
202
|
const { name, connection } = toCompile;
|
|
198
|
-
return {
|
|
199
|
-
type: 'sqlBlock',
|
|
200
|
-
name,
|
|
201
|
-
connection,
|
|
202
|
-
selectStr: sqlStrings.join(''),
|
|
203
|
-
};
|
|
203
|
+
return { type: 'sqlBlock', name, connection, selectStr };
|
|
204
204
|
}
|
|
205
205
|
static async run({ connections, preparedResult, sqlStruct, connection, options, }) {
|
|
206
206
|
const sqlBlock = sqlStruct === null || sqlStruct === void 0 ? void 0 : sqlStruct.structSource.sqlBlock;
|