@nocobase/database 2.1.34 → 2.1.35
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.
|
@@ -50,6 +50,23 @@ const pushAttribute = /* @__PURE__ */ __name((node, attribute) => {
|
|
|
50
50
|
node.attributes.push(attribute);
|
|
51
51
|
}
|
|
52
52
|
}, "pushAttribute");
|
|
53
|
+
const getRootModelOrderFields = /* @__PURE__ */ __name((node) => {
|
|
54
|
+
if (!import_lodash.default.isArray(node.order)) {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
const fields = [];
|
|
58
|
+
for (const orderItem of node.order) {
|
|
59
|
+
if (!import_lodash.default.isArray(orderItem) || orderItem.length !== 2 || !import_lodash.default.isString(orderItem[0])) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const fieldName = orderItem[0];
|
|
63
|
+
const attribute = node.model.rawAttributes[fieldName] || Object.values(node.model.rawAttributes).find((item) => item.field === fieldName);
|
|
64
|
+
if (attribute) {
|
|
65
|
+
fields.push(attribute.field || fieldName);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return fields;
|
|
69
|
+
}, "getRootModelOrderFields");
|
|
53
70
|
const EagerLoadingNodeProto = {
|
|
54
71
|
afterBuild(db) {
|
|
55
72
|
const collection = db.modelCollection.get(this.model);
|
|
@@ -218,11 +235,15 @@ const _EagerLoadingTree = class _EagerLoadingTree {
|
|
|
218
235
|
if (!primaryKeyField) {
|
|
219
236
|
throw new Error(`Model ${node.model.name} does not have primary key`);
|
|
220
237
|
}
|
|
238
|
+
const group = [`${node.model.name}.${primaryKeyField}`];
|
|
239
|
+
if (this.db.inDialect("mssql") || this.db.isMySQLCompatibleDialect()) {
|
|
240
|
+
group.push(...getRootModelOrderFields(node).map((field) => `${node.model.name}.${field}`));
|
|
241
|
+
}
|
|
221
242
|
const ids2 = (await node.model.findAll({
|
|
222
243
|
...this.rootQueryOptions,
|
|
223
244
|
includeIgnoreAttributes: false,
|
|
224
245
|
attributes: [primaryKeyField],
|
|
225
|
-
group:
|
|
246
|
+
group: import_lodash.default.uniq(group),
|
|
226
247
|
transaction,
|
|
227
248
|
include: (0, import_utils.processIncludes)(includeForFilter, node.model),
|
|
228
249
|
raw: true
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/database",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.35",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/logger": "2.1.
|
|
10
|
-
"@nocobase/utils": "2.1.
|
|
9
|
+
"@nocobase/logger": "2.1.35",
|
|
10
|
+
"@nocobase/utils": "2.1.35",
|
|
11
11
|
"async-mutex": "^0.3.2",
|
|
12
12
|
"chalk": "^4.1.1",
|
|
13
13
|
"cron-parser": "4.4.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
39
39
|
"directory": "packages/database"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "d844133f9bd61a3506a3be1af25a1cb06dafbc6f"
|
|
42
42
|
}
|