@nocobase/database 2.1.0-alpha.6 → 2.1.0-alpha.8

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/lib/collection.js CHANGED
@@ -188,7 +188,7 @@ const _Collection = class _Collection extends import_events.EventEmitter {
188
188
  label: `${this.name}.${field.name}`,
189
189
  value: val
190
190
  });
191
- const { error } = joiSchema.validate(val);
191
+ const { error } = joiSchema.validate(val, { convert: false });
192
192
  if (error) {
193
193
  throw error;
194
194
  }
@@ -149,6 +149,11 @@ const _EagerLoadingTree = class _EagerLoadingTree {
149
149
  const { sourceKey } = association;
150
150
  pushAttribute(eagerLoadingTreeParent, sourceKey);
151
151
  }
152
+ if (associationType == "BelongsToArray") {
153
+ const { foreignKey, targetKey } = association;
154
+ pushAttribute(eagerLoadingTreeParent, foreignKey);
155
+ pushAttribute(child, targetKey);
156
+ }
152
157
  eagerLoadingTreeParent.children.push(child);
153
158
  if (include.include) {
154
159
  traverseIncludeOption(include.include, child);
@@ -58,16 +58,17 @@ function buildJoiSchema(validation, options) {
58
58
  }
59
59
  if (rules) {
60
60
  rules.forEach((rule) => {
61
- if (!import_lodash.default.isEmpty(rule.args)) {
62
- if (rule.name === "pattern" && !import_lodash.default.isRegExp(rule.args.regex)) {
63
- const lastSlash = rule.args.regex.lastIndexOf("/");
64
- const isRegExpStr = rule.args.regex.startsWith("/") && lastSlash > 0;
61
+ const args = import_lodash.default.cloneDeep(rule.args);
62
+ if (!import_lodash.default.isEmpty(args)) {
63
+ if (rule.name === "pattern" && !import_lodash.default.isRegExp(args.regex)) {
64
+ const lastSlash = args.regex.lastIndexOf("/");
65
+ const isRegExpStr = args.regex.startsWith("/") && lastSlash > 0;
65
66
  if (isRegExpStr) {
66
- rule.args.regex = rule.args.regex.slice(1, lastSlash);
67
+ args.regex = args.regex.slice(1, lastSlash);
67
68
  }
68
- rule.args.regex = new RegExp(rule.args.regex);
69
+ args.regex = new RegExp(args.regex);
69
70
  }
70
- schema = rule.paramsType === "object" ? schema[rule.name](rule.args) : schema[rule.name](...Object.values(rule.args));
71
+ schema = rule.paramsType === "object" ? schema[rule.name](args) : schema[rule.name](...Object.values(args));
71
72
  } else {
72
73
  schema = schema[rule.name]();
73
74
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/database",
3
- "version": "2.1.0-alpha.6",
3
+ "version": "2.1.0-alpha.8",
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.6",
10
- "@nocobase/utils": "2.1.0-alpha.6",
9
+ "@nocobase/logger": "2.1.0-alpha.8",
10
+ "@nocobase/utils": "2.1.0-alpha.8",
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": "189dc0eb7683a8330db1e4c5fd46ee871b8b4e1f"
41
+ "gitHead": "eda3bfb9df40d4394905e178f1c5331adbec4e76"
42
42
  }