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

bookshelf generating wrong query in strapi v3.2.0 #8225

Closed
marefati110 opened this issue Oct 7, 2020 · 2 comments · Fixed by #8228
Closed

bookshelf generating wrong query in strapi v3.2.0 #8225

marefati110 opened this issue Oct 7, 2020 · 2 comments · Fixed by #8228
Assignees
Labels
issue: bug Issue reporting a bug severity: high If it breaks the basic use of the product source: core:database Source is core/database package status: confirmed Confirmed by a Strapi Team member or multiple community members

Comments

@marefati110
Copy link

Describe the bug

i update strapi from 3.1.7 to 3.2.0 and have a problem with bookshelf
bookshelf generate wrong query

query = await strapi
      .query('doctor')
      .model.query((qb) => {
        qb.where('doctors.id', '=', doctor);
      })
      .fetch({
        withRelated: [
          {
            'offices.healthcenter': (qb) => {
              qb.debug();
              qb.columns([
                'healthcenters.id',
                'healthcenters.name',
                'healthcenters.about',
                'healthcenters.adress',
                'healthcenters.location',
                'healthcenters.type',
              ]);
            },
          },
        ],
      });

in strapi v3.1.7 generate this query

select `healthcenters`.`id`, `healthcenters`.`name`, `healthcenters`.`about`, `healthcenters`.`adress`, `healthcenters`.`location`, `healthcenters`.`type` from `healthcenters` where `healthcenters`.`id` in (?)

and its right
but in strapi v3.2.0 generate this query

select `healthcenters`.`id`, `healthcenters`.`name`, `healthcenters`.`about`, `healthcenters`.`adress`, `healthcenters`.`location`, `healthcenters`.`type` from `offices` where `offices`.`doctor` in (?)

so make error

error Error: select `healthcenters`.`id`, `healthcenters`.`name`, `healthcenters`.`about`, `healthcenters`.`adress`, `healthcenters`.`location`, `healthcenters`.`type` from `offices` where `offices`.`doctor` in (308519) - ER_BAD_FIELD_ERROR: Unknown column 'healthcenters.id' in 'field list'

when i change strapi to 3.1.7 there is no problem

Expected behavior
Expected that generate same sql query

System

  • Node.js version: v12
  • NPM version: v6
  • Strapi version: v3.2.0
  • Database: mysql
  • Operating system: centos7
@alexandrebodin
Copy link
Member

Hello, thanks for the report, can you share your Model.settings.json for thos three models so we can reproduce it ?

@marefati110
Copy link
Author

@alexandrebodin i build a repo that have models
https://github.com/marefati110/models

@Convly Convly added source: core:database Source is core/database package status: confirmed Confirmed by a Strapi Team member or multiple community members issue: bug Issue reporting a bug severity: high If it breaks the basic use of the product labels Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Issue reporting a bug severity: high If it breaks the basic use of the product source: core:database Source is core/database package status: confirmed Confirmed by a Strapi Team member or multiple community members
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants