Changes between Initial Version and Version 1 of Ticket #33435


Ignore:
Timestamp:
Jan 13, 2022, 12:59:52 AM (3 years ago)
Author:
M1ha Shvn
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #33435 – Description

    initial v1  
    1 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:
    2 
     1Since [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. Adding `Subquery().query.subquery = True` attribute fixes the problem. From my point of view, it should be set in `Subquery` constructor.
    32
    43{{{
     
    1716# Outptut SQL is invalid (no S letter at the beggining and " symbol at the end):
    1817# ('(ELECT "apps_app"."id", "apps_app"."name" FROM "apps_app)', ())
     18
     19q.query.subquery = True
     20print(q.as_sql(q.query.get_compiler('default'), connection))
     21
     22# Outputs correct result
     23('(SELECT "apps_app"."id", "apps_app"."name" FROM "apps_app")', ())
    1924}}}
    2025
Back to Top