@loomcore/api 0.1.105 → 0.1.106
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.
|
@@ -28,15 +28,23 @@ function getJoinAliasesAndParents(operations) {
|
|
|
28
28
|
return { aliases, parentByAlias };
|
|
29
29
|
}
|
|
30
30
|
const PREFIX_SEP = '__';
|
|
31
|
-
function setJoinValue(joinData, alias, value, parentByAlias) {
|
|
31
|
+
function setJoinValue(joinData, alias, value, parentByAlias, operations) {
|
|
32
32
|
const parent = parentByAlias.get(alias) ?? null;
|
|
33
33
|
if (parent) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
const parentValue = joinData[parent];
|
|
35
|
+
const parentOp = operations.find(op => (op instanceof LeftJoinMany || op instanceof LeftJoin || op instanceof InnerJoin) && op.as === parent);
|
|
36
|
+
const isParentArray = parentOp instanceof LeftJoinMany;
|
|
37
|
+
if (isParentArray && Array.isArray(parentValue)) {
|
|
38
|
+
joinData[alias] = value;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
let parentObj = parentValue;
|
|
42
|
+
if (parentObj == null || typeof parentObj !== 'object' || Array.isArray(parentObj)) {
|
|
43
|
+
parentObj = {};
|
|
44
|
+
joinData[parent] = parentObj;
|
|
45
|
+
}
|
|
46
|
+
parentObj[alias] = value;
|
|
38
47
|
}
|
|
39
|
-
parentObj[alias] = value;
|
|
40
48
|
}
|
|
41
49
|
else {
|
|
42
50
|
joinData[alias] = value;
|
|
@@ -87,7 +95,7 @@ export function transformJoinResults(rows, operations) {
|
|
|
87
95
|
const value = flatJoinValues[alias];
|
|
88
96
|
if (value === undefined)
|
|
89
97
|
continue;
|
|
90
|
-
setJoinValue(joinData, alias, value, parentByAlias);
|
|
98
|
+
setJoinValue(joinData, alias, value, parentByAlias, operations);
|
|
91
99
|
}
|
|
92
100
|
if (Object.keys(joinData).length > 0) {
|
|
93
101
|
transformed._joinData = joinData;
|