Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query bug on child models #93

Closed
ozziest opened this issue Oct 17, 2021 · 0 comments
Closed

Query bug on child models #93

ozziest opened this issue Oct 17, 2021 · 0 comments
Assignees
Labels
bug Something isn't working
Projects

Comments

@ozziest
Copy link
Member

ozziest commented Oct 17, 2021

Let's assume that we have a model like this;

class StudentLesson extends Model {
  lesson() {
    return this.belongsTo("Lesson", "lesson_id", "id");
  }

  teacher() {
    return this.belongsTo("Teacher", "teacher_id", "id");
  }
}

When we request the following example, we don't use parentheses to group query features;

/api/students/1/lessons?q=[{ "$or.lesson.name.$like":"*a*"},{ "$or.teacher.name.$like":"*a*"}]

When we execute this request, it executes the following query;

where `student_id` = 1 and `lessons`.`name` like "%a%" or `teachers`.`name` like "%a%"

But, it should be like the following one;

where `student_id` = 1 and (`lessons`.`name` like "%a%" or `teachers`.`name` like "%a%")
@ozziest ozziest created this issue from a note in v1.0.0 (To do) Oct 17, 2021
@ozziest ozziest self-assigned this Oct 17, 2021
@ozziest ozziest added the bug Something isn't working label Oct 17, 2021
@ozziest ozziest moved this from To do to In progress in v1.0.0 Oct 17, 2021
ozziest added a commit that referenced this issue Oct 17, 2021
@ozziest ozziest mentioned this issue Oct 17, 2021
v1.0.0 automation moved this from In progress to Done! Oct 17, 2021
ozziest added a commit that referenced this issue Dec 24, 2022
ozziest added a commit that referenced this issue Dec 24, 2022
ozziest added a commit that referenced this issue Dec 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
v1.0.0
Done!
Development

No branches or pull requests

1 participant