@ronin/compiler 0.14.0-leo-ron-1099-1-experimental-312 → 0.14.0-leo-ron-1099-1-experimental-314
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/index.js +16 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -419,12 +419,16 @@ var handleSelecting = (models, model, statementParams, single, instructions, opt
|
|
419
419
|
const joinedSelectedFields = [];
|
420
420
|
const joinedColumns = [];
|
421
421
|
if (instructions.including) {
|
422
|
+
const symbol = getSymbol(instructions.including);
|
423
|
+
if (symbol?.type === "query") {
|
424
|
+
instructions.including.ronin_root = { ...instructions.including };
|
425
|
+
delete instructions.including[QUERY_SYMBOLS.QUERY];
|
426
|
+
}
|
422
427
|
const flatObject = flatten(instructions.including);
|
423
|
-
instructions.including = {};
|
424
428
|
for (const [key, value] of Object.entries(flatObject)) {
|
425
|
-
const
|
426
|
-
if (
|
427
|
-
const { queryModel, queryInstructions } = splitQuery(
|
429
|
+
const symbol2 = getSymbol(value);
|
430
|
+
if (symbol2?.type === "query") {
|
431
|
+
const { queryModel, queryInstructions } = splitQuery(symbol2.value);
|
428
432
|
const subQueryModel = getModelBySlug(models, queryModel);
|
429
433
|
isJoining = true;
|
430
434
|
if (queryInstructions?.selecting) options.expandColumns = true;
|
@@ -432,7 +436,7 @@ var handleSelecting = (models, model, statementParams, single, instructions, opt
|
|
432
436
|
const subSingle = queryModel !== subQueryModel.pluralSlug;
|
433
437
|
if (!model.tableAlias)
|
434
438
|
model.tableAlias = single && !subSingle ? `sub_${model.table}` : model.table;
|
435
|
-
const subMountingPath = `${options?.mountingPath ? `${options?.mountingPath}.` : ""}${subSingle ? key : `${key}[0]`}`;
|
439
|
+
const subMountingPath = key === "ronin_root" ? options.mountingPath : `${options?.mountingPath ? `${options?.mountingPath}.` : ""}${subSingle ? key : `${key}[0]`}`;
|
436
440
|
const { columns: nestedColumns, selectedFields: nestedSelectedFields } = handleSelecting(
|
437
441
|
models,
|
438
442
|
{ ...subQueryModel, tableAlias },
|
@@ -449,8 +453,8 @@ var handleSelecting = (models, model, statementParams, single, instructions, opt
|
|
449
453
|
continue;
|
450
454
|
}
|
451
455
|
let mountedValue = value;
|
452
|
-
if (
|
453
|
-
mountedValue = `(${parseFieldExpression(model, "including",
|
456
|
+
if (symbol2?.type === "expression") {
|
457
|
+
mountedValue = `(${parseFieldExpression(model, "including", symbol2.value)})`;
|
454
458
|
} else {
|
455
459
|
mountedValue = prepareStatementValue(statementParams, value);
|
456
460
|
}
|
@@ -1944,13 +1948,11 @@ var Transaction = class {
|
|
1944
1948
|
records.push(record);
|
1945
1949
|
continue;
|
1946
1950
|
}
|
1947
|
-
const joinFields = fields.reduce(
|
1948
|
-
(acc
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
);
|
1953
|
-
for (const arrayField of joinFields) {
|
1951
|
+
const joinFields = fields.reduce((acc, { mountingPath }) => {
|
1952
|
+
if (mountingPath.includes("[0]")) acc.add(mountingPath.split("[0]")[0]);
|
1953
|
+
return acc;
|
1954
|
+
}, /* @__PURE__ */ new Set());
|
1955
|
+
for (const arrayField of joinFields.values()) {
|
1954
1956
|
const currentValue = existingRecord[arrayField];
|
1955
1957
|
const newValue = record[arrayField];
|
1956
1958
|
currentValue.push(...newValue);
|
package/package.json
CHANGED