mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
fix(infra): orm create override optional (#8627)
This commit is contained in:
@@ -125,6 +125,6 @@ describe('ORM hook mixin', () => {
|
||||
// @ts-expect-error private
|
||||
const rawTag = client.tags.adapter.data.get(tag.id);
|
||||
expect(rawTag.color).toBe('red');
|
||||
expect(rawTag.colors).toBe(null);
|
||||
expect(rawTag.colors).toBe(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -368,7 +368,7 @@ describe('ORM entity CRUD', () => {
|
||||
name: 'test',
|
||||
});
|
||||
|
||||
expect(user.email).toBe(null);
|
||||
expect(user.email).toBe(undefined);
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -64,6 +64,10 @@ export class YjsTableAdapter implements TableAdapter {
|
||||
|
||||
this.doc.transact(() => {
|
||||
for (const key in data) {
|
||||
if (data[key] === undefined) {
|
||||
// skip undefined fields, avoid unexpected override
|
||||
continue;
|
||||
}
|
||||
record.set(key, data[key]);
|
||||
}
|
||||
|
||||
|
||||
@@ -160,11 +160,11 @@ export class Table<T extends TableSchemaBuilder> {
|
||||
|
||||
if (inputVal === undefined) {
|
||||
if (schema.optional) {
|
||||
acc[key] = null;
|
||||
acc[key] = undefined;
|
||||
}
|
||||
|
||||
if (schema.default) {
|
||||
acc[key] = schema.default() ?? null;
|
||||
acc[key] = schema.default() ?? undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user