Open Eraldo opened 2 weeks ago
Hi @Eraldo
I think coincidentally we also ran into the same issue a few days ago in #650. Our understanding is that the duplicate results are caused by the extra LEFT OUTER JOIN
added by Strawberry Django's window pagination approach when prefetching related m2m types.
For reference, we don't think that using DISTINCT
will be enough to solve the issue, as it will only remove the duplicates from the final result set, but the calculated total_count
will still be incorrect.
At the moment, we think the two options are to either:
See #650 for a more in depth explanation.
Thank you @SupImDos for making me aware of the related issue detailing the challenge and possible solution paths. š I will keep an eye on it.
Bug Description
Observation in my app: I have a contacts page where contacts can have tags and the same tag is shown shown multiple times.
I checked the dev api and saw that it only happens when using the "related type" (TagListConnection via contact tags field.)
Using a tags query directly works. (not via related type) Using no filter yields duplicate nodes. Using the related one while a filter is active does work. Using the DISTINCT filter does not work. (also shows the duplicates)
Example:
This is the SQL for the following query:
The result shoes 8 duplicate tags.
Using the django debug toolbar while running the query shows the following SQL information:
System Information
Additional Context
According to @bellini666 the general underlying issue of duplicates due to SQL is known.
Conversation snipet for context:
Upvote & Fund