@nocobase/database 2.1.0-alpha.18 → 2.1.0-alpha.19
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.
|
@@ -75,16 +75,20 @@ const queryParentSQL = /* @__PURE__ */ __name((options) => {
|
|
|
75
75
|
const targetKeyField = collection.model.rawAttributes[targetKey].field;
|
|
76
76
|
const queryInterface = db.sequelize.getQueryInterface();
|
|
77
77
|
const q = queryInterface.quoteIdentifier.bind(queryInterface);
|
|
78
|
-
|
|
78
|
+
const placeholders = nodeIds.map((_, index) => `$${index + 1}`).join(", ");
|
|
79
|
+
return {
|
|
80
|
+
sql: `WITH RECURSIVE cte AS (
|
|
79
81
|
SELECT ${q(targetKeyField)}, ${q(foreignKeyField)}
|
|
80
82
|
FROM ${tableName}
|
|
81
|
-
WHERE ${q(targetKeyField)} IN (
|
|
83
|
+
WHERE ${q(targetKeyField)} IN (${placeholders})
|
|
82
84
|
UNION ALL
|
|
83
85
|
SELECT t.${q(targetKeyField)}, t.${q(foreignKeyField)}
|
|
84
86
|
FROM ${tableName} AS t
|
|
85
87
|
INNER JOIN cte ON t.${q(targetKeyField)} = cte.${q(foreignKeyField)}
|
|
86
88
|
)
|
|
87
|
-
SELECT ${q(targetKeyField)} AS ${q(targetKey)}, ${q(foreignKeyField)} AS ${q(foreignKey)} FROM cte
|
|
89
|
+
SELECT ${q(targetKeyField)} AS ${q(targetKey)}, ${q(foreignKeyField)} AS ${q(foreignKey)} FROM cte`,
|
|
90
|
+
bind: nodeIds
|
|
91
|
+
};
|
|
88
92
|
}, "queryParentSQL");
|
|
89
93
|
const _EagerLoadingTree = class _EagerLoadingTree {
|
|
90
94
|
root;
|
|
@@ -305,7 +309,7 @@ const _EagerLoadingTree = class _EagerLoadingTree {
|
|
|
305
309
|
});
|
|
306
310
|
if (node.includeOption.recursively && instances.length > 0) {
|
|
307
311
|
const targetKey = association.targetKey;
|
|
308
|
-
const sql = queryParentSQL({
|
|
312
|
+
const { sql, bind } = queryParentSQL({
|
|
309
313
|
db: this.db,
|
|
310
314
|
collection: collection2,
|
|
311
315
|
foreignKey,
|
|
@@ -313,6 +317,7 @@ const _EagerLoadingTree = class _EagerLoadingTree {
|
|
|
313
317
|
nodeIds: instances.map((instance) => instance.get(targetKey))
|
|
314
318
|
});
|
|
315
319
|
const results = await this.db.sequelize.query(sql, {
|
|
320
|
+
bind,
|
|
316
321
|
type: "SELECT",
|
|
317
322
|
transaction
|
|
318
323
|
});
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/database",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.19",
|
|
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.0-alpha.
|
|
10
|
-
"@nocobase/utils": "2.1.0-alpha.
|
|
9
|
+
"@nocobase/logger": "2.1.0-alpha.19",
|
|
10
|
+
"@nocobase/utils": "2.1.0-alpha.19",
|
|
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": "3d13700360eac1c0f9dbf6a5f167ed396a294a3c"
|
|
42
42
|
}
|