mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 08:26:21 +00:00
fix: sequelize primary key field with multi filter target keys (#5556)
This commit is contained in:
parent
a985bc46a8
commit
eec0f30d40
@ -189,10 +189,6 @@ export class Collection<
|
||||
return this.model.primaryKeyAttribute;
|
||||
}
|
||||
|
||||
isMultiFilterTargetKey() {
|
||||
return Array.isArray(this.filterTargetKey) && this.filterTargetKey.length > 1;
|
||||
}
|
||||
|
||||
get name() {
|
||||
return this.options.name;
|
||||
}
|
||||
@ -225,6 +221,10 @@ export class Collection<
|
||||
}
|
||||
}
|
||||
|
||||
isMultiFilterTargetKey() {
|
||||
return Array.isArray(this.filterTargetKey) && this.filterTargetKey.length > 1;
|
||||
}
|
||||
|
||||
tableName() {
|
||||
const { name, tableName } = this.options;
|
||||
const tName = tableName || name;
|
||||
@ -313,6 +313,20 @@ export class Collection<
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperty(this.model, 'primaryKeyField', {
|
||||
get: function () {
|
||||
if (this.primaryKeyAttribute) {
|
||||
return this.rawAttributes[this.primaryKeyAttribute].field || this.primaryKeyAttribute;
|
||||
}
|
||||
|
||||
return null;
|
||||
}.bind(this.model),
|
||||
|
||||
set(val) {
|
||||
this._primaryKeyField = val;
|
||||
},
|
||||
});
|
||||
|
||||
this.model.init(null, this.sequelizeModelOptions());
|
||||
|
||||
this.model.options.modelName = this.options.name;
|
||||
|
Loading…
Reference in New Issue
Block a user