You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context:
I have a many to many relation between subjects and assessments through a mapping table class_subjects_assessments. The class_subjects_assessments table has a bunch of extra fields and I would like to update a specific relation specified by one of the extra fields csa_id using $relatedQuery():
update "class_subjects_assessments" set "state" = ?, "completed_questions" = ?
where
"class_subjects_assessments"."assessment_id" in
(
select "assessments"."id"
from "assessments" inner join "class_subjects_assessments"
on "assessments"."id" = "class_subjects_assessments"."assessment_id"
where "class_subjects_assessments"."subject_id" in (?)
and "csa_id" = ?
)
and "class_subjects_assessments"."subject_id" in (?)
However, what I required was this:
update "class_subjects_assessments" set "state" = ?, "completed_questions" = ?
where
"class_subjects_assessments"."assessment_id" in
(
select "assessments"."id"
from "assessments" inner join "class_subjects_assessments"
on "assessments"."id" = "class_subjects_assessments"."assessment_id"
where "class_subjects_assessments"."subject_id" in (?)
and "csa_id" = ?
)
and "class_subjects_assessments"."subject_id" in (?)
and "csa_id" = ? ---- <- NOTE
The first query ends up updating all the records where assessment_id and subject_id match, which is not what I required.
For now, I created a model for class_subjects_assessments as a workaround. Is there any way to use $relatedQuery for my requirement without creating this model?
Refer: #413
Context:
I have a many to many relation between
subjects
andassessments
through a mapping tableclass_subjects_assessments
. Theclass_subjects_assessments
table has a bunch of extra fields and I would like to update a specific relation specified by one of the extra fieldscsa_id
using$relatedQuery()
:The above generates the sql:
However, what I required was this:
The first query ends up updating all the records where
assessment_id
andsubject_id
match, which is not what I required.For now, I created a model for
class_subjects_assessments
as a workaround. Is there any way to use$relatedQuery
for my requirement without creating this model?Packages:
"graphql": "16.8.1",
"graphql-yoga": "4.0.3",
"knex": "2.5.1",
"objection": "3.1.2",
"pg": "8.11.3",
The text was updated successfully, but these errors were encountered: