@nocobase/database 1.4.0-alpha.20240919174335 → 1.4.0-alpha.20240928155737

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/database.js CHANGED
@@ -64,6 +64,7 @@ var import_database_utils = __toESM(require("./database-utils"));
64
64
  var import_references_map = __toESM(require("./features/references-map"));
65
65
  var import_referential_integrity_check = require("./features/referential-integrity-check");
66
66
  var FieldTypes = __toESM(require("./fields"));
67
+ var import_helpers = require("./helpers");
67
68
  var import_inherited_collection = require("./inherited-collection");
68
69
  var import_inherited_map = __toESM(require("./inherited-map"));
69
70
  var import_interface_manager = require("./interface-manager");
@@ -360,9 +361,6 @@ const _Database = class _Database extends import_events.EventEmitter {
360
361
  options.underscored = true;
361
362
  }
362
363
  if (options.underscored) {
363
- if (import_lodash.default.get(options, "sortable.scopeKey")) {
364
- options.sortable.scopeKey = (0, import_utils3.snakeCase)(options.sortable.scopeKey);
365
- }
366
364
  if (import_lodash.default.get(options, "indexes")) {
367
365
  options.indexes = options.indexes.map((index) => {
368
366
  if (index.fields) {
@@ -661,7 +659,7 @@ const _Database = class _Database extends import_events.EventEmitter {
661
659
  * @internal
662
660
  */
663
661
  async checkVersion() {
664
- return true;
662
+ return process.env.DB_SKIP_VERSION_CHECK === "on" || await (0, import_helpers.checkDatabaseVersion)(this);
665
663
  }
666
664
  /**
667
665
  * @internal
@@ -41,8 +41,14 @@ export interface RealFieldOptions extends BaseColumnFieldOptions {
41
41
  type: 'real';
42
42
  }
43
43
  export declare class DecimalField extends NumberField {
44
- get dataType(): DataTypes.DecimalDataTypeConstructor;
44
+ get dataType(): DataTypes.DecimalDataType;
45
+ static optionsFromRawType(rawType: string): {
46
+ precision: number;
47
+ scale: number;
48
+ };
45
49
  }
46
50
  export interface DecimalFieldOptions extends BaseColumnFieldOptions {
47
51
  type: 'decimal';
52
+ precision: number;
53
+ scale: number;
48
54
  }
@@ -79,7 +79,16 @@ __name(_RealField, "RealField");
79
79
  let RealField = _RealField;
80
80
  const _DecimalField = class _DecimalField extends NumberField {
81
81
  get dataType() {
82
- return import_sequelize.DataTypes.DECIMAL;
82
+ return import_sequelize.DataTypes.DECIMAL(this.options.precision, this.options.scale);
83
+ }
84
+ static optionsFromRawType(rawType) {
85
+ const matches = rawType.match(/DECIMAL\((\d+),\s*(\d+)\)/);
86
+ if (matches) {
87
+ return {
88
+ precision: parseInt(matches[1]),
89
+ scale: parseInt(matches[2])
90
+ };
91
+ }
83
92
  }
84
93
  };
85
94
  __name(_DecimalField, "DecimalField");
@@ -157,9 +157,9 @@ const _SortField = class _SortField extends import_field.Field {
157
157
  }, "doInit");
158
158
  const scopeKey = this.options.scopeKey;
159
159
  if (scopeKey) {
160
- const groups = await this.collection.repository.find({
161
- attributes: [scopeKey],
162
- group: [scopeKey],
160
+ const scopeKeyColumn = this.collection.model.rawAttributes[scopeKey].field;
161
+ const groups = await this.collection.model.findAll({
162
+ attributes: [[import_sequelize.Sequelize.fn("DISTINCT", import_sequelize.Sequelize.col(scopeKeyColumn)), scopeKey]],
163
163
  raw: true,
164
164
  transaction
165
165
  });
@@ -123,7 +123,7 @@ const _RelationRepository = class _RelationRepository {
123
123
  }
124
124
  convertTk(options) {
125
125
  let tk = options;
126
- if (typeof options === "object" && options["tk"]) {
126
+ if (typeof options === "object" && "tk" in options) {
127
127
  tk = options["tk"];
128
128
  }
129
129
  return tk;
@@ -133,7 +133,10 @@ const _RelationRepository = class _RelationRepository {
133
133
  if (typeof tk === "string") {
134
134
  tk = tk.split(",");
135
135
  }
136
- return import_lodash.default.castArray(tk);
136
+ if (tk) {
137
+ return import_lodash.default.castArray(tk);
138
+ }
139
+ return [];
137
140
  }
138
141
  targetKey() {
139
142
  return this.associationField.targetKey;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/database",
3
- "version": "1.4.0-alpha.20240919174335",
3
+ "version": "1.4.0-alpha.20240928155737",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
7
7
  "license": "AGPL-3.0",
8
8
  "dependencies": {
9
- "@nocobase/logger": "1.4.0-alpha.20240919174335",
10
- "@nocobase/utils": "1.4.0-alpha.20240919174335",
9
+ "@nocobase/logger": "1.4.0-alpha.20240928155737",
10
+ "@nocobase/utils": "1.4.0-alpha.20240928155737",
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": "57b1697b219b5c8e6a0444ee19bd66cd598bd07f"
41
+ "gitHead": "f2765665126f5e9b5ae01f9ca6e8a151916554b4"
42
42
  }