[Err Handling] ORM 잘못된 Type 입력
ORM 함수 사용시, 잘못된 record type을 입력한 뒤 server start를 하면 app crashed 발생
에러 메시지
Truncated incorrect INTEGER value:
에러 핸들링 방법
잘못된 record type이 입력됐을 때 발생하는 오류로 판단했다. ORM의 create(), update() 등을 사용할 때, integer로 설정된 password 필드에 string을 넣는 등의 잘못된 type을 넣으려고 시도할 때 발생한다. 입력하려는 내용의 type과 필드의 type이 일치하는지 확인 한 후 재시도한다.
await User.update({ image: newImage }, {
where: { image: curImage, id: userInfo.email }
})
/* 예를 들어, User의 id와 userInfo.id가 일치하는 레코드를 where로 뽑아낼때,
type이 integer인 id에 type이 string인 userInfo.email을 넣어버리면 오류가 발생한다. */