#33435: Since django 3.0 Subquery.as_sql() generates invalid SQL
-------------------------------------+-------------------------------------
               Reporter:  M1ha Shvn  |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  dev
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:  subquery, as_sql
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Since
 
[https://github.com/django/django/commit/3a505c70e7b228bf1212c067a8f38271ca86ce09
 this commit] `Subquery.as_sql(...)` method returns incorrect SQL removing
 first and last symbols instead of absent breakets:


 {{{
 from django.db import connection
 from apps.models import App

 q = Subquery(App.objects.all())

 print(str(q.query))

 # Output SQL is valid:
 #  'SELECT "apps_app"."id", "apps_app"."name" FROM "apps_app"'

 print(q.as_sql(q.query.get_compiler('default'), connection))

 # Outptut SQL is invalid (no S letter at the beggining and " symbol at the
 end):
 # ('(ELECT "apps_app"."id", "apps_app"."name" FROM "apps_app)', ())
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33435>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.b687d6fecefcfe7470f97520a8d1ab1a%40djangoproject.com.

Reply via email to