NarHakobyan / awesome-nest-boilerplate

Awesome NestJS Boilerplate 😍, Typescript 💪, Postgres 🎉, TypeORM 🥳
https://narhakobyan.github.io/awesome-nest-boilerplate
MIT License
2.39k stars 452 forks source link

Exception Inserting a new Post #296

Closed Be-P closed 2 years ago

Be-P commented 2 years ago

Trying to create a new Post through Swagger I get the following exception:

query: START TRANSACTION
query: INSERT INTO "posts"("id", "created_at", "updated_at", "user_id") VALUES (DEFAULT, DEFAULT, DEFAULT, $1) RETURNING "id", "created_at", "updated_at" -- PARAMETERS: ["fecd4a62-56ae-45da-94b4-97004e39abc3"]
query: INSERT INTO "posts"("id", "created_at", "updated_at", "user_id") VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT) RETURNING "id", "created_at", "updated_at"
query failed: INSERT INTO "posts"("id", "created_at", "updated_at", "user_id") VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT) RETURNING "id", "created_at", "updated_at"
error: error: null value in column "user_id" of relation "posts" violates not-null constraint

It seems that the line await this.postTranslationRepository.save(translations); tries to cascade insert the update to the postEntity without setting the userId. the second INSERT in the log gets executed by the postTranslationRepository

Steps to reproduce:

alexdeia commented 2 years ago

the same.

NarHakobyan commented 2 years ago

Fixed by @nhutcorp, closes #296