mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-09 23:49:27 +08:00
fix: viewName set
This commit is contained in:
parent
9f16eae936
commit
7cf96eefb6
@ -65,6 +65,8 @@ describe('view collection', function () {
|
|||||||
|
|
||||||
const otherSchemaView = db.getCollection(`${randomSchema}_${viewName}`);
|
const otherSchemaView = db.getCollection(`${randomSchema}_${viewName}`);
|
||||||
expect(otherSchemaView).toBeInstanceOf(ViewCollection);
|
expect(otherSchemaView).toBeInstanceOf(ViewCollection);
|
||||||
|
expect(otherSchemaView.options.viewName).toBe(viewName);
|
||||||
|
expect(otherSchemaView.options.schema).toBe(randomSchema);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support view with dot field', async () => {
|
it('should support view with dot field', async () => {
|
||||||
|
@ -15,6 +15,13 @@ export function beforeCreateForViewCollection(db: Database) {
|
|||||||
if (exists) {
|
if (exists) {
|
||||||
const prefix = model.get('schema') || 'public';
|
const prefix = model.get('schema') || 'public';
|
||||||
const viewName = `${prefix}_${name}`;
|
const viewName = `${prefix}_${name}`;
|
||||||
|
|
||||||
|
// set collection viewName
|
||||||
|
if (!model.get('viewName')) {
|
||||||
|
model.set('viewName', name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set collection name
|
||||||
model.set('name', viewName);
|
model.set('name', viewName);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user