I've been stuck on this for a good hour, and unfortunately can't find anything relevant in the docs.
I'm unable to set values on fields that use types like enum or uuid. For instance:
export enum PhotoStatus {
WORKING = 'WORKING',
DONE = 'DONE'
}
export class Photo {
@PrimaryGeneratedColumn()
id: number:
@Column()
size: string;
@Column({
type: 'enum',
enum: PhotoStatus,
default: PhotoStatus.WORKING,
})
status: PhotoStatus;
}
But when I try to create a new record, like so:
const photo = new Photo();
photo.size = 'huge';
photo.status = PhotoStatus.DONE;
await connection.manager.save(photo);
It throws an error:
BadRequestException: ERROR: column "status" is of type content_status_enum but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
This happens for uuid columns too.
intand using the IsEnum decorator?intif possible, as values like7or3in the database don't really indicate what the value means. This is why I'd prefer to use anenumtype.