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

Duplicated LEFT OUTER JOIN with two related lookups on translated fields #37

Open
jieter opened this issue Mar 14, 2018 · 0 comments
Open

Comments

@jieter
Copy link
Member

jieter commented Mar 14, 2018

@pjburon This clearly is a different issue, so created a new one.
originally reported in #34

This Queryset

Blog.objects.filter(
       Q(category__slug_i18n=slug) | Q(category__parent__slug_i18n=slug),
       is_active=active
)

Results for language = en in:

result: <MultilingualQuerySet [<Blog: Duck>, <Blog: Falcon>]>
SELECT ...
FROM "app_blog"
INNER JOIN "app_category" ON ("app_blog"."category_id" = "app_category"."id")
LEFT OUTER JOIN "app_category" T3 ON ("app_category"."parent_id" = T3."id")
WHERE (("app_category"."slug" = 'birds'
        OR T3."slug" = 'birds')
       AND "app_blog"."is_active" = true)

and for language = en in:

result: <MultilingualQuerySet []>
SELECT ..., "app_blog"."i18n", COALESCE((T3."i18n" ->> 'slug_nl'), T3."slug") AS "slug_i18n_annotation"
FROM "app_blog"
LEFT OUTER JOIN "app_category" ON ("app_blog"."category_id" = "app_category"."id")
LEFT OUTER JOIN "app_category" T3 ON ("app_category"."parent_id" = T3."id")
WHERE ((COALESCE((T3."i18n" ->> 'slug_nl'), T3."slug") = 'birds'
        OR COALESCE((T3."i18n" ->> 'slug_nl'), T3."slug") = 'birds')
       AND "app_blog"."is_active" = true)

So the problem is the duplicated LEFT OUTER JOIN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant