Changes between Initial Version and Version 1 of Ticket #33435
- Timestamp:
- Jan 13, 2022, 12:59:52 AM (3 years ago)
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 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. Adding `Subquery().query.subquery = True` attribute fixes the problem. From my point of view, it should be set in `Subquery` constructor. 3 2 4 3 {{{ … … 17 16 # Outptut SQL is invalid (no S letter at the beggining and " symbol at the end): 18 17 # ('(ELECT "apps_app"."id", "apps_app"."name" FROM "apps_app)', ()) 18 19 q.query.subquery = True 20 print(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")', ()) 19 24 }}} 20 25