#26061: Queryset raises EmptyResultSet  (instead of print SQL query)
----------------------------------------------+----------------------------
     Reporter:  ad-m                          |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.8
     Severity:  Normal                        |   Keywords:  EmptyResultSet
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+----------------------------
 {{{
 In [19]: import django

 In [20]: django.VERSION
 Out[20]: (1, 8, 7, 'final', 0)

 In [21]: print Record.objects.filter(pk__in=[])
 []
 In [22]: print Record.objects.filter(pk__in=[]).query
 ---------------------------------------------------------------------------
 EmptyResultSet                            Traceback (most recent call
 last)
 <ipython-input-22-e81ae73ee15f> in <module>()
 ----> 1 print Record.objects.filter(pk__in=[]).query

 /home/adas/.virtualenvs/poradnia/local/lib/python2.7/site-
 packages/django/db/models/sql/query.pyc in __str__(self)
     213         done by the database interface at execution time.
     214         """
 --> 215         sql, params = self.sql_with_params()
     216         return sql % params
     217

 /home/adas/.virtualenvs/poradnia/local/lib/python2.7/site-
 packages/django/db/models/sql/query.pyc in sql_with_params(self)
     221         substituted into the query.
     222         """
 --> 223         return self.get_compiler(DEFAULT_DB_ALIAS).as_sql()
     224
     225     def __deepcopy__(self, memo):

 /home/adas/.virtualenvs/poradnia/local/lib/python2.7/site-
 packages/django/db/models/sql/compiler.pyc in as_sql(self, with_limits,
 with_col_aliases, subquery)
     385             from_, f_params = self.get_from_clause()
     386
 --> 387             where, w_params = self.compile(self.query.where)
     388             having, h_params = self.compile(self.query.having)
     389             params = []

 /home/adas/.virtualenvs/poradnia/local/lib/python2.7/site-
 packages/django/db/models/sql/compiler.pyc in compile(self, node,
 select_format)
     355             sql, params = vendor_impl(self, self.connection)
     356         else:
 --> 357             sql, params = node.as_sql(self, self.connection)
     358         if select_format and not self.subquery:
     359             return node.output_field.select_format(self, sql,
 params)

 /home/adas/.virtualenvs/poradnia/local/lib/python2.7/site-
 packages/django/db/models/sql/where.pyc in as_sql(self, compiler,
 connection)
     131                     return '', []
     132                 else:
 --> 133                     raise EmptyResultSet
     134             if full_needed - everything_childs <= 0:
     135                 if self.negated:

 EmptyResultSet:

 }}}

 I expect to achieve SQL query not exception.

 There is #10181, but it was about query execution. My issues is about
 query printing.

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

Reply via email to