@nocobase/plugin-data-source-main 2.1.0-beta.7 → 2.1.0-beta.9

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.
@@ -8,15 +8,15 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.1.0-beta.7",
11
+ "@nocobase/client": "2.1.0-beta.9",
12
12
  "lodash": "4.17.21",
13
- "@nocobase/database": "2.1.0-beta.7",
14
- "@nocobase/plugin-error-handler": "2.1.0-beta.7",
15
- "@nocobase/server": "2.1.0-beta.7",
13
+ "@nocobase/database": "2.1.0-beta.9",
14
+ "@nocobase/plugin-error-handler": "2.1.0-beta.9",
15
+ "@nocobase/server": "2.1.0-beta.9",
16
16
  "sequelize": "6.35.2",
17
17
  "@formily/json-schema": "2.3.7",
18
- "@nocobase/test": "2.1.0-beta.7",
19
- "@nocobase/utils": "2.1.0-beta.7",
20
- "@nocobase/actions": "2.1.0-beta.7",
18
+ "@nocobase/test": "2.1.0-beta.9",
19
+ "@nocobase/utils": "2.1.0-beta.9",
20
+ "@nocobase/actions": "2.1.0-beta.9",
21
21
  "dayjs": "1.11.13"
22
22
  };
@@ -12,6 +12,7 @@ interface LoadOptions extends Transactionable {
12
12
  }
13
13
  export declare class FieldModel extends MagicAttributeModel {
14
14
  get db(): Database;
15
+ set(key: any, value?: any, options?: any): this;
15
16
  isAssociationField(): boolean;
16
17
  load(loadOptions?: LoadOptions): Promise<import("@nocobase/database").Field>;
17
18
  syncSortByField(options: Transactionable): Promise<void>;
@@ -45,6 +45,24 @@ class FieldModel extends import_database.MagicAttributeModel {
45
45
  get db() {
46
46
  return this.constructor.database;
47
47
  }
48
+ set(key, value, options) {
49
+ if (typeof key === "string") {
50
+ if (key === "defaultValue") {
51
+ return this.setV1(`${this.magicAttribute}.defaultValue`, value, options);
52
+ }
53
+ return super.set(key, value, options);
54
+ }
55
+ if (import_lodash.default.isPlainObject(key) && Object.prototype.hasOwnProperty.call(key, "defaultValue")) {
56
+ const { defaultValue, ...rest } = key;
57
+ const setOptions = value;
58
+ if (Object.keys(rest).length) {
59
+ super.set(rest, setOptions);
60
+ }
61
+ this.setV1(`${this.magicAttribute}.defaultValue`, defaultValue, setOptions);
62
+ return this;
63
+ }
64
+ return super.set(key, value, options);
65
+ }
48
66
  isAssociationField() {
49
67
  return ["belongsTo", "hasOne", "hasMany", "belongsToMany"].includes(this.get("type"));
50
68
  }
@@ -103,6 +121,9 @@ class FieldModel extends import_database.MagicAttributeModel {
103
121
  async syncUniqueIndex(options) {
104
122
  const unique = this.get("unique");
105
123
  const collection = this.getFieldCollection();
124
+ if (!collection) {
125
+ return;
126
+ }
106
127
  const field = collection.getField(this.get("name"));
107
128
  const columnName = collection.model.rawAttributes[this.get("name")].field;
108
129
  const tableName = collection.model.tableName;
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "NocoBase main database, supports relational databases such as PostgreSQL, MySQL, MariaDB and so on.",
7
7
  "description.ru-RU": "Основная база данных NocoBase: поддерживает реляционные СУБД, включая PostgreSQL, MySQL, MariaDB и другие.",
8
8
  "description.zh-CN": "NocoBase 主数据库,支持 PostgreSQL、MySQL、MariaDB 等关系型数据库。",
9
- "version": "2.1.0-beta.7",
9
+ "version": "2.1.0-beta.9",
10
10
  "main": "./dist/server/index.js",
11
11
  "homepage": "https://docs.nocobase.com/handbook/data-source-main",
12
12
  "homepage.ru-RU": "https://docs-ru.nocobase.com/handbook/data-source-main",
@@ -25,7 +25,7 @@
25
25
  "@nocobase/test": "2.x",
26
26
  "@nocobase/utils": "2.x"
27
27
  },
28
- "gitHead": "da7dfef2b6d6854988a56119463c8c38e3221e79",
28
+ "gitHead": "c3a2875e4cbbb43b1f2361e6f9f5f84a7d3f3c3c",
29
29
  "keywords": [
30
30
  "Data sources"
31
31
  ]