fix(ui-schema-storage): duplicate of empty schema

This commit is contained in:
chenos 2024-01-02 14:44:54 +08:00
parent 29b47c1d40
commit 5de28cd4c4
2 changed files with 8 additions and 0 deletions

View File

@ -225,6 +225,11 @@ describe('ui_schema repository', () => {
expect(s2['x-uid']).not.toEqual(s['x-uid']);
});
it('should be null', async () => {
const s2 = await repository.duplicate('test-null');
expect(s2).toBeNull();
});
describe('schema', () => {
let schema;
beforeEach(() => {

View File

@ -445,6 +445,9 @@ export class UiSchemaRepository extends Repository {
@transaction()
async duplicate(uid: string, options?: Transactionable) {
const s = await this.getJsonSchema(uid, { ...options, includeAsyncNode: true });
if (!s?.['x-uid']) {
return null;
}
this.regenerateUid(s);
return this.insert(s, options);
}