[Django] #29491: Query.get_count produces SQL that is invalid for DB2

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #29491: Query.get_count produces SQL that is invalid for DB2

Django
#29491: Query.get_count produces SQL that is invalid for DB2
-------------------------------------+-------------------------------------
               Reporter:  Paul       |          Owner:  nobody
  Wujek                              |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  2.0
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 This bug occurs in db/models/sql/query.py

 In function get_count lines 5 and 6 are:

 {{{
         obj.add_annotation(Count('*'), alias='__count', is_summary=True)
         number = obj.get_aggregation(using, ['__count'])['__count']
 }}}

 Code produced looks like:

 {{{
 SELECT COUNT(*) AS __count FROM MYTABLE
 }}}

 Error Returned:

 {{{
 [SQL0104] Token _ was not valid. Valid tokens: <IDENTIFIER>. [SQL
 State=42601, DB Errorcode=-104]
 }}}

 Cause:
 Underscore is not valid as a beginning character for a token in DB2.

 Suggested Solution:

 {{{
 Do not use '__count' as a token in the 5th and 6th lines of get_count.
 Instead use a token name that does not begin with '_' (Underscore).
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29491>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/049.9ec12ee7e0fbf5e7eb4680b185754d80%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29491: Query.get_count produces SQL that is invalid for DB2

Django
#29491: Query.get_count produces SQL that is invalid for DB2
-------------------------------------+-------------------------------------
     Reporter:  Paul Wujek           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 Is there anyway for the DB2 adapter to quote such identifiers? Would that
 make them valid?

 For example, the MySQL backend's `quote_name` wraps names in backtips `
 resulting the in the following query

 {{{#!python
 SELECT COUNT(*) AS `__count` FROM `table`
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29491#comment:1>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.516d88486d85950635ee23c5df931ac0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29491: Query.get_count produces SQL that is invalid for DB2

Django
In reply to this post by Django
#29491: Query.get_count produces SQL that is invalid for DB2
-------------------------------------+-------------------------------------
     Reporter:  Paul Wujek           |                    Owner:  Jeff
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Jeff):

 * owner:  nobody => Jeff
 * status:  new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/29491#comment:2>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.094246c6d8d7d0c33c81ea36e940676a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29491: Query.get_count produces SQL that is invalid for DB2

Django
In reply to this post by Django
#29491: Query.get_count produces SQL that is invalid for DB2
-------------------------------------+-------------------------------------
     Reporter:  Paul Wujek           |                    Owner:  Jeff
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * status:  assigned => closed
 * resolution:   => wontfix


Comment:

 Closing as wontifx absent justification that the problem can't be fixed in
 the DB2 backend.

--
Ticket URL: <https://code.djangoproject.com/ticket/29491#comment:3>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.3fc7768e1e74fbfda14d562549b2bf3e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.