@nocobase/database 1.9.2 → 1.9.4
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.d.ts +1 -0
- package/lib/collection.js +19 -3
- package/lib/dialects/mariadb-dialect.js +6 -1
- package/package.json +4 -4
package/lib/collection.d.ts
CHANGED
|
@@ -124,6 +124,7 @@ export declare class Collection<TModelAttributes extends {} = any, TCreationAttr
|
|
|
124
124
|
updateOptions(options: CollectionOptions, mergeOptions?: any): this;
|
|
125
125
|
setSortable(sortable: any): void;
|
|
126
126
|
updateField(name: string, options: FieldOptions): void;
|
|
127
|
+
private normalizeFieldName;
|
|
127
128
|
addIndex(index: string | string[] | {
|
|
128
129
|
fields: string[];
|
|
129
130
|
unique?: boolean;
|
package/lib/collection.js
CHANGED
|
@@ -591,6 +591,12 @@ const _Collection = class _Collection extends import_events.EventEmitter {
|
|
|
591
591
|
}
|
|
592
592
|
this.setField(options.name || name, options);
|
|
593
593
|
}
|
|
594
|
+
normalizeFieldName(val) {
|
|
595
|
+
if (!this.options.underscored) {
|
|
596
|
+
return val;
|
|
597
|
+
}
|
|
598
|
+
return Array.isArray(val) ? val.map((v) => (0, import_utils.snakeCase)(v)) : (0, import_utils.snakeCase)(val);
|
|
599
|
+
}
|
|
594
600
|
addIndex(index) {
|
|
595
601
|
if (!index) {
|
|
596
602
|
return;
|
|
@@ -620,7 +626,7 @@ const _Collection = class _Collection extends import_events.EventEmitter {
|
|
|
620
626
|
return;
|
|
621
627
|
}
|
|
622
628
|
for (const item of indexes) {
|
|
623
|
-
if (import_lodash.default.isEqual(item.fields, indexName)) {
|
|
629
|
+
if (import_lodash.default.isEqual(this.normalizeFieldName(item.fields), this.normalizeFieldName(indexName))) {
|
|
624
630
|
return;
|
|
625
631
|
}
|
|
626
632
|
const name2 = item.fields.join(",");
|
|
@@ -656,11 +662,21 @@ const _Collection = class _Collection extends import_events.EventEmitter {
|
|
|
656
662
|
*/
|
|
657
663
|
refreshIndexes() {
|
|
658
664
|
const indexes = this.model._indexes;
|
|
665
|
+
const attributes = {};
|
|
666
|
+
for (const [name, field] of Object.entries(this.model.getAttributes())) {
|
|
667
|
+
attributes[this.normalizeFieldName(name)] = field;
|
|
668
|
+
}
|
|
659
669
|
this.model._indexes = import_lodash.default.uniqBy(
|
|
660
670
|
indexes.filter((item) => {
|
|
661
|
-
return item.fields.every((field) =>
|
|
671
|
+
return item.fields.every((field) => {
|
|
672
|
+
const name = this.normalizeFieldName(field);
|
|
673
|
+
return attributes[name];
|
|
674
|
+
});
|
|
662
675
|
}).map((item) => {
|
|
663
|
-
item.fields = item.fields.map((field) =>
|
|
676
|
+
item.fields = item.fields.map((field) => {
|
|
677
|
+
const name = this.normalizeFieldName(field);
|
|
678
|
+
return attributes[name].field;
|
|
679
|
+
});
|
|
664
680
|
return item;
|
|
665
681
|
}),
|
|
666
682
|
"name"
|
|
@@ -35,7 +35,12 @@ module.exports = __toCommonJS(mariadb_dialect_exports);
|
|
|
35
35
|
var import_base_dialect = require("./base-dialect");
|
|
36
36
|
const _MariadbDialect = class _MariadbDialect extends import_base_dialect.BaseDialect {
|
|
37
37
|
getSequelizeOptions(options) {
|
|
38
|
-
options.dialectOptions = {
|
|
38
|
+
options.dialectOptions = {
|
|
39
|
+
...options.dialectOptions || {},
|
|
40
|
+
multipleStatements: true,
|
|
41
|
+
supportBigNumbers: true,
|
|
42
|
+
bigNumberStrings: true
|
|
43
|
+
};
|
|
39
44
|
return options;
|
|
40
45
|
}
|
|
41
46
|
getVersionGuard() {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/database",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.4",
|
|
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.9.
|
|
10
|
-
"@nocobase/utils": "1.9.
|
|
9
|
+
"@nocobase/logger": "1.9.4",
|
|
10
|
+
"@nocobase/utils": "1.9.4",
|
|
11
11
|
"async-mutex": "^0.3.2",
|
|
12
12
|
"chalk": "^4.1.1",
|
|
13
13
|
"cron-parser": "4.4.0",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
40
40
|
"directory": "packages/database"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "7431e8b3b3b9e06c21b05dc0af68349f7cfbe04f"
|
|
43
43
|
}
|