hydra icon indicating copy to clipboard operation
hydra copied to clipboard

An entity field must be set to null in order to be unset, yet model definitions don't allow it

Open Lezek123 opened this issue 3 years ago • 1 comments

It looks like the neither setting a field to undefined nor using delete entity.field actually unsets the value in the database. See: https://github.com/typeorm/typeorm/issues/2934

This conflicts with the TypeScript definitions of models generated by Hydra (warthog?), since they don't allow null as value even for optional fields.

For example:

export declare class MemberMetadata extends BaseModel {
    name?: string;
    avatar?: DataObject;
    about?: string;
}

Lezek123 avatar Jun 25 '21 15:06 Lezek123

Turns out this may be tricky to fix: https://github.com/typeorm/typeorm/issues/5454

Lezek123 avatar Jun 25 '21 16:06 Lezek123