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

Fix duplicate sort results #13387

Closed
wants to merge 1 commit into from
Closed

Fix duplicate sort results #13387

wants to merge 1 commit into from

Conversation

Bassel17
Copy link
Member

@Bassel17 Bassel17 commented May 24, 2022

What does it do?

In query builder when we query for data and we have joins, we run qb.distinct which should remove duplicate data from the query but after some testing it doesn't seem to affect queries with multiple joins and duplicate data was queried when trying nested sorting. So I opted to use qb.groupBy instead when we have multiple joins and sorting

Why is it needed?

When doing nested sorting, duplicate data is being returned

How to test it?

run a strapi application and create content types with a relation, try to sort the parent content type based on a relation field there should be no duplicates, you can follow the same method in the issue I will reference below.

Related issue(s)/PR(s)

fixes #11892

@Bassel17 Bassel17 added source: core:database Source is core/database package pr: fix This PR is fixing a bug labels May 24, 2022
@codecov
Copy link

codecov bot commented May 24, 2022

Codecov Report

Merging #13387 (5b796e1) into master (2ef3556) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

❗ Current head 5b796e1 differs from pull request most recent head 86fe91e. Consider uploading reports for the commit 86fe91e to get more accurate results

@@            Coverage Diff             @@
##           master   #13387      +/-   ##
==========================================
- Coverage   48.22%   48.20%   -0.02%     
==========================================
  Files         239      239              
  Lines        8834     8837       +3     
  Branches     1992     1993       +1     
==========================================
  Hits         4260     4260              
- Misses       3766     3768       +2     
- Partials      808      809       +1     
Flag Coverage Δ
front ?
unit 48.20% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/core/database/lib/query/query-builder.js 2.08% <0.00%> (-0.04%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2ef3556...86fe91e. Read the comment docs.

Copy link
Member

@Convly Convly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's breaking some e2e tests in packages/core/content-manager/server/tests/api/basic-relations.test.e2e.js

@Convly Convly modified the milestones: 4.2.0, 4.2.1 Jun 15, 2022
@Convly Convly modified the milestones: 4.2.1, 4.2.2, 4.2.3 Jun 29, 2022
@alexandrebodin alexandrebodin modified the milestones: 4.2.3, 4.2.4 Jul 13, 2022
@gu-stav gu-stav modified the milestones: 4.2.4, 4.3.0 Jul 20, 2022
@Convly Convly modified the milestones: 4.3.0, 4.3.1 Jul 27, 2022
@petersg83 petersg83 modified the milestones: 4.3.1, 4.3.2 Aug 1, 2022
@alexandrebodin alexandrebodin modified the milestones: 4.3.2, 4.3.3 Aug 1, 2022
@Bassel17 Bassel17 marked this pull request as draft August 2, 2022 13:31
@alexandrebodin alexandrebodin removed this from the 4.3.3 milestone Aug 10, 2022
@alexandrebodin
Copy link
Member

Hey based on our lastest discussion on the topic this isn't solving the problem at hand :) I'll close for now :)

@alexandrebodin alexandrebodin deleted the fix/duplicate-sort-results branch November 23, 2022 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: fix This PR is fixing a bug source: core:database Source is core/database package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v4] sort by graphql duplicating rows
6 participants