Giter Site home page Giter Site logo

Comments (6)

millerdev avatar millerdev commented on June 23, 2024

@pwfff With.join() has been reimplemented to use real joins now, and there is a secret parameter that you can pass to specify a LEFT OUTER JOIN. Example usage:

from django.db.models.sql.constants import LOUTER

query = cte.join(Region, name=cte.col.name, _join_type=LOUTER)

approximate SQL:

SELECT ...
FROM region
LEFT OUTER JOIN cte ON region.name = cte.name

Fair warning: this is an undocumented feature, and may change in the future. Also be careful: the join may be automatically changed to an INNER JOIN if you subsequently (after calling cte.join(...)) do other things like add filters involving joins to the queryset.

If you're satisfied with this I think we can close #1. Let me know what you think.

from django-cte.

pwfff avatar pwfff commented on June 23, 2024

It works as well as the version I had, but I'm still running into this issue:

django.db.utils.ProgrammingError: invalid reference to FROM-clause entry for table "share"
LINE 1: ...LEFT OUTER JOIN "my_table" V8 ON V0."foo_id" = ("my_table"."j...
                                                             ^
HINT:  Perhaps you meant to reference the table alias "v8".

I'll see if I can get a simple reproduction for you.

from django-cte.

pwfff avatar pwfff commented on June 23, 2024

Seems to happen when doing something like Foo.objects.filter(id__in=my_joined_queryset_with_ctes). Everything in the subquery gets an extra alias, but it doesn't resolve.

from django-cte.

pwfff avatar pwfff commented on June 23, 2024

I have an attempt at a fix in #4.

from django-cte.

millerdev avatar millerdev commented on June 23, 2024

@pwfff Is this issue resolved now?

from django-cte.

pwfff avatar pwfff commented on June 23, 2024

Yes, with #4. Thank you!

from django-cte.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.