Sequelize .create function includes eager loaded values #17047
Replies: 2 comments 2 replies
-
We'll need to see what the other model that are associated with this one look like to be able to help |
Beta Was this translation helpful? Give feedback.
-
I fixed the issue in the end. Regarding the error: After this, the error changed to "sql": "INSERT INTO \"testAttemptDate\" (\"id\",\"testAttemptHistoryId\",\"createdAt\",\"updatedAt\") VALUES (DEFAULT,$1,$2,$3) RETURNING \"id\",\"testAttemptHistoryId\",\"createdAt\",\"updatedAt\",\"activityId\",\"itemId\";", The However, it is still unclear to me why when trying to create a database entry of the |
Beta Was this translation helpful? Give feedback.
-
I am working on a project using:
v20.10.0
v10.2.3
v6.25.3
v2.1.6
I have defined the models using
sequelize-typescript
library. One of the models is:It has a foreign key while the rest of its fields should be automatically created during
.create
function.Followingly, this is the function that should create a
TestAttemptDate
entry:However, this function fails with the following error message:
Based on the
sql
query mentioned in the above error message in theRETURNING
part it tries to returnactivityId
anditemId
which are not fields ofTestAttemptDate
but fields of the model associated with theTestAttemptDate
.What can cause this error?
PS: this is part of an API call and the error returned by the server is
{"message":"column \"activityId\" does not exist"}
.UPDATE:
The associated models:
Beta Was this translation helpful? Give feedback.
All reactions