@nocobase/database 0.21.0-alpha.11 → 0.21.0-alpha.13
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.
|
@@ -213,6 +213,15 @@ const _EagerLoadingTree = class _EagerLoadingTree {
|
|
|
213
213
|
} else if (ids.length > 0) {
|
|
214
214
|
const association = node.association;
|
|
215
215
|
const associationType = association.associationType;
|
|
216
|
+
let params = {};
|
|
217
|
+
const otherFindOptions = import_lodash.default.pick(node.includeOption, ["sort"]) || {};
|
|
218
|
+
const collection = this.db.modelCollection.get(node.model);
|
|
219
|
+
if (collection && !import_lodash.default.isEmpty(otherFindOptions)) {
|
|
220
|
+
const parser = new import_options_parser.OptionsParser(otherFindOptions, {
|
|
221
|
+
collection
|
|
222
|
+
});
|
|
223
|
+
params = parser.toSequelizeParams();
|
|
224
|
+
}
|
|
216
225
|
if (associationType == "HasOne" || associationType == "HasMany") {
|
|
217
226
|
const foreignKey = association.foreignKey;
|
|
218
227
|
const foreignKeyValues = node.parent.instances.map((instance) => instance.get(association.sourceKey));
|
|
@@ -225,7 +234,7 @@ const _EagerLoadingTree = class _EagerLoadingTree {
|
|
|
225
234
|
const findOptions = {
|
|
226
235
|
where,
|
|
227
236
|
attributes: node.attributes,
|
|
228
|
-
order: orderOption(association),
|
|
237
|
+
order: params.order || orderOption(association),
|
|
229
238
|
transaction
|
|
230
239
|
};
|
|
231
240
|
instances = await node.model.findAll(findOptions);
|
|
@@ -233,7 +242,7 @@ const _EagerLoadingTree = class _EagerLoadingTree {
|
|
|
233
242
|
if (associationType == "BelongsTo") {
|
|
234
243
|
const foreignKey = association.foreignKey;
|
|
235
244
|
const parentInstancesForeignKeyValues = node.parent.instances.map((instance) => instance.get(foreignKey));
|
|
236
|
-
const
|
|
245
|
+
const collection2 = this.db.modelCollection.get(node.model);
|
|
237
246
|
instances = await node.model.findAll({
|
|
238
247
|
transaction,
|
|
239
248
|
where: {
|
|
@@ -245,7 +254,7 @@ const _EagerLoadingTree = class _EagerLoadingTree {
|
|
|
245
254
|
const targetKey = association.targetKey;
|
|
246
255
|
const sql = import_adjacency_list_repository.AdjacencyListRepository.queryParentSQL({
|
|
247
256
|
db: this.db,
|
|
248
|
-
collection,
|
|
257
|
+
collection: collection2,
|
|
249
258
|
foreignKey,
|
|
250
259
|
targetKey,
|
|
251
260
|
nodeIds: instances.map((instance) => instance.get(targetKey))
|
|
@@ -298,7 +307,7 @@ const _EagerLoadingTree = class _EagerLoadingTree {
|
|
|
298
307
|
}
|
|
299
308
|
}
|
|
300
309
|
],
|
|
301
|
-
order: orderOption(association)
|
|
310
|
+
order: params.order || orderOption(association)
|
|
302
311
|
});
|
|
303
312
|
}
|
|
304
313
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { DataTypes } from 'sequelize';
|
|
2
2
|
import { BaseColumnFieldOptions, Field } from './field';
|
|
3
3
|
export declare class TextField extends Field {
|
|
4
|
-
get dataType(): DataTypes.TextDataTypeConstructor;
|
|
4
|
+
get dataType(): DataTypes.TextDataTypeConstructor | DataTypes.TextDataType;
|
|
5
|
+
init(): void;
|
|
5
6
|
}
|
|
6
7
|
export interface TextFieldOptions extends BaseColumnFieldOptions {
|
|
7
8
|
type: 'text';
|
|
9
|
+
length?: 'tiny' | 'medium' | 'long';
|
|
8
10
|
}
|
package/lib/fields/text-field.js
CHANGED
|
@@ -25,8 +25,16 @@ var import_sequelize = require("sequelize");
|
|
|
25
25
|
var import_field = require("./field");
|
|
26
26
|
const _TextField = class _TextField extends import_field.Field {
|
|
27
27
|
get dataType() {
|
|
28
|
+
if (this.database.inDialect("mysql", "mariadb") && this.options.length) {
|
|
29
|
+
return import_sequelize.DataTypes.TEXT(this.options.length);
|
|
30
|
+
}
|
|
28
31
|
return import_sequelize.DataTypes.TEXT;
|
|
29
32
|
}
|
|
33
|
+
init() {
|
|
34
|
+
if (this.database.inDialect("mysql", "mariadb")) {
|
|
35
|
+
this.options.defaultValue = null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
30
38
|
};
|
|
31
39
|
__name(_TextField, "TextField");
|
|
32
40
|
let TextField = _TextField;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/database",
|
|
3
|
-
"version": "0.21.0-alpha.
|
|
3
|
+
"version": "0.21.0-alpha.13",
|
|
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": "0.21.0-alpha.
|
|
10
|
-
"@nocobase/utils": "0.21.0-alpha.
|
|
9
|
+
"@nocobase/logger": "0.21.0-alpha.13",
|
|
10
|
+
"@nocobase/utils": "0.21.0-alpha.13",
|
|
11
11
|
"async-mutex": "^0.3.2",
|
|
12
12
|
"chalk": "^4.1.1",
|
|
13
13
|
"cron-parser": "4.4.0",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
37
37
|
"directory": "packages/database"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "27fced984ff80c7673ad49b6a7365578ca309fe7"
|
|
40
40
|
}
|