forked from Arteha/admin-bro-typeorm
-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
I had columns that have a type 'time' in Mariadb. For those columns, admin-bro shows NaN, which seems it tries to convert to the Date type but fail. I am using "@admin-bro/typeorm": "^1.4.0",

This is my entity.
@Entity('TEACHER')
export class Teacher extends BaseEntity {
@PrimaryGeneratedColumn('increment')
@ApiProperty()
id: number;
@Column({ name: 'FK_TEACHER_teacherID' })
@RelationId((teacher: Teacher) => teacher.teacher)
@ApiProperty()
teacherID: string;
@ManyToOne((type) => TeacherID, (TeacherID) => TeacherID.teacherID, {
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
})
@JoinColumn({ name: 'FK_TEACHER_teacherID' })
teacher: TeacherID;
@ManyToOne((type) => Branch, (Branch) => Branch.branchName, {
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
})
@JoinColumn({ name: 'FK_TEACHER_branch' })
branch: Branch;
@Column({ name: 'FK_TEACHER_branch' })
@ApiProperty()
branchName: string;
@Column({ type: 'tinyint', nullable: false })
@ApiProperty()
workDow: number;
@Column({ type: 'time', nullable: false })
@ApiProperty()
startTime: Date;
@Column({ type: 'time', nullable: false })
@ApiProperty()
endTime: Date;
setTeacher(createTeacherDto: CreateTeacherDto): void {
let br = new Branch(createTeacherDto.teacherBranch);
let tr = new TeacherID(createTeacherDto.teacherID);
this.teacher = tr;
this.branch = br;
this.workDow = createTeacherDto.workDow;
this.startTime = createTeacherDto.startTime;
this.endTime = createTeacherDto.endTime;
}
}
I checked it at the "adminjs-typeorm/src/Property.js" and it clearly shows that 'time' column is converted to Date.
Thus, I added if(this.column.type === 'time') type = 'string'; at the adminjs-typeorm/src/Property.js and it shows the time correctly.
As a result, I think the type 'time' should not be converted to 'Date'.
jschroed91 and aldvine
Metadata
Metadata
Assignees
Labels
No labels