|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
[Django] #11916: Extra params + aggregation creates incorrect SQL.
by Django-3
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message #11916: Extra params + aggregation creates incorrect SQL.
------------------------------------------+--------------------------------- Reporter: jaklaassen@... | Owner: nobody Status: new | Milestone: Component: Database layer (models, ORM) | Version: 1.1 Keywords: | Stage: Unreviewed Has_patch: 0 | ------------------------------------------+--------------------------------- A query that has an annotation/aggregation (and thus a GROUP BY), extra (where) parameters and extra select parameters generates incorrect SQL because it puts the extra parameters at the end of the params list, although get_grouping() will generate parameters due to the extra select parameters. I have attached a diff for django.db.models.sql.query.py that should I believe addresses this problem. -- Ticket URL: <http://code.djangoproject.com/ticket/11916> Django <http://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 post to this group, send email to django-updates@... To unsubscribe from this group, send email to django-updates+unsubscribe@... For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: [Django] #11916: Extra params + aggregation creates incorrect SQL.
by Django-3
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message #11916: Extra params + aggregation creates incorrect SQL.
---------------------------------------------------+------------------------ Reporter: jaklaassen@... | Owner: nobody Status: closed | Milestone: Component: Database layer (models, ORM) | Version: 1.1 Resolution: duplicate | Keywords: Stage: Unreviewed | Has_patch: 0 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | ---------------------------------------------------+------------------------ Changes (by Alex): * status: new => closed * needs_better_patch: => 0 * resolution: => duplicate * needs_tests: => 0 * needs_docs: => 0 Comment: This is a duplicate of #11104. -- Ticket URL: <http://code.djangoproject.com/ticket/11916#comment:1> Django <http://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 post to this group, send email to django-updates@... To unsubscribe from this group, send email to django-updates+unsubscribe@... For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: [Django] #11916: Extra params + aggregation creates incorrect SQL.
by Django-3
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message #11916: Extra params + aggregation creates incorrect SQL.
---------------------------------------------------+------------------------ Reporter: jaklaassen@... | Owner: nobody Status: reopened | Milestone: Component: Database layer (models, ORM) | Version: 1.1 Resolution: | Keywords: Stage: Unreviewed | Has_patch: 0 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | ---------------------------------------------------+------------------------ Changes (by paluh): * status: closed => reopened * resolution: duplicate => Comment: I think it's that this ticket is not duplicate of #11104, and it's related to bug in grouping columns list generation: statements of extra selects are taken to column list instead of keys. my patch (which I've attached): {{{ --- django/db/models/sql/query.py (revision 11729) +++ django/db/models/sql/query.py (working copy) @@ -885,9 +885,9 @@ group_by = self.group_by or [] extra_selects = [] - for extra_select, extra_params in self.extra_select.itervalues(): - extra_selects.append(extra_select) - params.extend(extra_params) + for extra_select_key in self.extra_select.iterkeys(): + extra_selects.append(extra_select_key) + for col in group_by + self.related_select_cols + extra_selects: if isinstance(col, (list, tuple)): result.append('%s.%s' % (qn(col[0]), qn(col[1]))) }}} -- Ticket URL: <http://code.djangoproject.com/ticket/11916#comment:2> Django <http://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 post to this group, send email to django-updates@... To unsubscribe from this group, send email to django-updates+unsubscribe@... For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: [Django] #11916: Extra params + aggregation creates incorrect SQL.
by Django-3
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message #11916: Extra params + aggregation creates incorrect SQL.
---------------------------------------------------+------------------------ Reporter: jaklaassen@... | Owner: nobody Status: reopened | Milestone: Component: Database layer (models, ORM) | Version: 1.1 Resolution: | Keywords: Stage: Unreviewed | Has_patch: 1 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | ---------------------------------------------------+------------------------ Changes (by patrys): * has_patch: 0 => 1 Comment: Agreed, these bugs are unrelated. #11104 is about the order of parameters while this one is about using correct aliases instead of incorrectly repeating subqueries in the GROUP BY part. -- Ticket URL: <http://code.djangoproject.com/ticket/11916#comment:3> Django <http://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 post to this group, send email to django-updates@... To unsubscribe from this group, send email to django-updates+unsubscribe@... For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |