프로그래밍 숲

QueryFailedError 본문

Error Handling/node.js

QueryFailedError

jjscript 2023. 5. 20. 17:03
728x90
반응형

Error Message

QueryFailedError: Cannot add or update a child row: a foreign key constraint fails (`pumpkin`.`posts`, CONSTRAINT `posts_category_id_fk` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`))

상황

createPost 통신을 시도했는데 다음과 같은 에러메시지 출력. 우선 dao단의 쿼리문 문제일 것이라고 추측.

mysql에 hard coding으로 insert Into 하니 잘 들어감. raw 쿼리문에는 문제 없음

해결

service단과 controller단의 인자 값의 순서가 dao단의 인자 값의 순서와 달라서 생겼던 문제.

728x90
반응형
Comments