Re: [Django] #28731: Passing an empty Q() to a When inside a Case causes an OperationError

2017-12-26 Thread Django
#28731: Passing an empty Q() to a When inside a Case causes an OperationError
-+-
 Reporter:  Tom van Bussel   |Owner:  Tim
 |  Martin
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Tim Graham ):

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


Comment:

 In [changeset:"5778b5701d6a0feb3053b70891cd8ce80b6e8601" 5778b57]:
 {{{
 #!CommitTicketReference repository=""
 revision="5778b5701d6a0feb3053b70891cd8ce80b6e8601"
 Fixed #28731 -- Added an error message when using an empty Q() in a When
 expression.

 Otherwise it generates invalid SQL.
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.af702f93cf977705bfbac5f1e949ccec%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28731: Passing an empty Q() to a When inside a Case causes an OperationError

2017-12-16 Thread Django
#28731: Passing an empty Q() to a When inside a Case causes an OperationError
-+-
 Reporter:  Tom van Bussel   |Owner:  Tim
 |  Martin
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Simon Charette):

 * stage:  Accepted => Ready for checkin


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.15f4cc7b41ab64ca3e086ebd4bda7d1d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28731: Passing an empty Q() to a When inside a Case causes an OperationError

2017-12-16 Thread Django
#28731: Passing an empty Q() to a When inside a Case causes an OperationError
-+-
 Reporter:  Tom van Bussel   |Owner:  Tim
 |  Martin
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Tim Martin):

 FWIW, this should be ready to re-review.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.acaa8871cddd4f4f7f8e28ccbff59b51%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28731: Passing an empty Q() to a When inside a Case causes an OperationError

2017-11-21 Thread Django
#28731: Passing an empty Q() to a When inside a Case causes an OperationError
-+-
 Reporter:  Tom van Bussel   |Owner:  Tim
 |  Martin
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Tim Martin):

 * has_patch:  0 => 1


Comment:

 I've added a [https://github.com/django/django/pull/9373 pull request]
 that makes this raise an exception.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.32cdc341385fc4fdb9b4a5cb0e4ea540%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28731: Passing an empty Q() to a When inside a Case causes an OperationError

2017-11-18 Thread Django
#28731: Passing an empty Q() to a When inside a Case causes an OperationError
-+-
 Reporter:  Tom van Bussel   |Owner:  Tim
 |  Martin
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Tim Martin):

 After a bit of digging, I found the rationale for this behaviour in
 #28211. The argument seems to be that it's common to do something like:

 {{{
 filters = Q()
 if condition:
filters |= Q(x=1)
 if other_condition:
filters |= Q(y=2)
 }}}

 I'm not sure I agree that this is the right design but there is at least a
 rationale here, and it's been like this for many years now so I don't
 think changing it is viable. This rationale supports the idea that empty
 Q() objects are legitimate steps in building up a query, but shouldn't be
 used directly. I'll make this report an explicit error rather than invalid
 SQL.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.92ceb57eb1da90be0174852212454b40%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28731: Passing an empty Q() to a When inside a Case causes an OperationError

2017-11-07 Thread Django
#28731: Passing an empty Q() to a When inside a Case causes an OperationError
-+-
 Reporter:  Tom van Bussel   |Owner:  Tim
 |  Martin
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Tim Martin):

 I don't think it's explicitly deprecated, we'd need to have a discussion
 on the mailing list to get consensus on that.

 However, I think reporting an explicit "empty `Q()` object not supported"
 error is much better than sending invalid SQL to the database and getting
 it rejected.  I don't think the DB layer should ever send invalid SQL.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.0a37bbd07efad8e1d57dacffd564e171%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28731: Passing an empty Q() to a When inside a Case causes an OperationError

2017-11-07 Thread Django
#28731: Passing an empty Q() to a When inside a Case causes an OperationError
-+-
 Reporter:  Tom van Bussel   |Owner:  Tim
 |  Martin
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Tomer Chachamu):

 If the usage of `Q()` is deprecated and will be removed then there's no
 need for it to create valid SQL (in more situations than it does
 currently). We could add tests for the existing behaviour of `Q() &
 Q(value=1)` and of `Q() | Q(value=1)`.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.266151ee24915d7a644fc0bf48e843ad%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28731: Passing an empty Q() to a When inside a Case causes an OperationError

2017-11-06 Thread Django
#28731: Passing an empty Q() to a When inside a Case causes an OperationError
-+-
 Reporter:  Tom van Bussel   |Owner:  Tim
 |  Martin
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Adam (Chainz) Johnson):

 Those are some good points Tim/Tomer. I agree that making When() raise an
 error when passed an empty Q would make sense.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.530c3189a2e7478af4fa9db5ea61e146%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28731: Passing an empty Q() to a When inside a Case causes an OperationError

2017-11-06 Thread Django
#28731: Passing an empty Q() to a When inside a Case causes an OperationError
-+-
 Reporter:  Tom van Bussel   |Owner:  Tim
 |  Martin
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Tim Martin):

 Worse, you get the same result for `Q() & Q(value=1)` as you do for `Q() |
 Q(value=1)`, because empty `Q()` expressions are ignored when combining
 (`query_utils.py:68`). I don't think there's an easy way to make this
 consistent.

 I'm guessing it should be possible to make the originally reported case
 not trigger invalid SQL, which is a step forward. Maybe it should report
 this as an invalid expression?

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.d7f486f085438d83f18ca2275d2a7384%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28731: Passing an empty Q() to a When inside a Case causes an OperationError

2017-11-06 Thread Django
#28731: Passing an empty Q() to a When inside a Case causes an OperationError
-+-
 Reporter:  Tom van Bussel   |Owner:  Tim
 |  Martin
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Tomer Chachamu):

 Currently `Q() | Q(value=1)` outputs the same SQL as `Q(value=1)` which
 will not be the case if `Q()` is effectively always `true`.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.ccf64665e4642ed6f63fcdd100b1d1be%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28731: Passing an empty Q() to a When inside a Case causes an OperationError

2017-11-05 Thread Django
#28731: Passing an empty Q() to a When inside a Case causes an OperationError
-+-
 Reporter:  Tom van Bussel   |Owner:  Tim
 |  Martin
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Tim Martin):

 * owner:  nobody => Tim Martin
 * status:  new => assigned


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.dec4f8547cf91de8d28303bbd179588b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28731: Passing an empty Q() to a When inside a Case causes an OperationError

2017-10-29 Thread Django
#28731: Passing an empty Q() to a When inside a Case causes an OperationError
-+-
 Reporter:  Tom van Bussel   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Adam (Chainz) Johnson):

 * cc: Adam (Chainz) Johnson (added)


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.335425eb35807ae20b36fc997b959832%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28731: Passing an empty Q() to a When inside a Case causes an OperationError

2017-10-29 Thread Django
#28731: Passing an empty Q() to a When inside a Case causes an OperationError
-+-
 Reporter:  Tom van Bussel   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Adam (Chainz) Johnson):

 > it would be nice if that behavior is matched everywhere.

 I agree, probably `Q()` should result in SQL something like `1=1`.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.f71d38a50c751a2e53eb996563f89e5a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28731: Passing an empty Q() to a When inside a Case causes an OperationError

2017-10-23 Thread Django
#28731: Passing an empty Q() to a When inside a Case causes an OperationError
-+-
 Reporter:  Tom van Bussel   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Tim Graham):

 * stage:  Unreviewed => Accepted


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.39ec0e22f51b88cff80a5763097523e1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28731: Passing an empty Q() to a When inside a Case causes an OperationError

2017-10-22 Thread Django
#28731: Passing an empty Q() to a When inside a Case causes an OperationError
-+-
 Reporter:  Tom van Bussel   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  1.11
  (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 Tom van Bussel):

 Replying to [comment:2 Tomer Chachamu]:
 > What did you expect to be the value of `x[0].test_name`?

 I expected `x[0].test_name == True` to hold.

 > We don't have any documentation on how a `Q(**kwargs)` object behaves
 when `len(kwargs) == 0`, and we have no tests for it. Perhaps it should be
 raising an exception (or initially a deprecation warning).

 Currently `TestModel.objects.filter(Q()).all() ==
 TestModel.objects.all()`, so it would be nice if that behavior is matched
 everywhere.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.7710073cc90cf16890ad89cec6e079b4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28731: Passing an empty Q() to a When inside a Case causes an OperationError

2017-10-21 Thread Django
#28731: Passing an empty Q() to a When inside a Case causes an OperationError
-+-
 Reporter:  Tom van Bussel   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  1.11
  (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 Tomer Chachamu):

 Thanks for the bug report.

 What did you expect to be the value of `x[0].test_name`?

 We don't have any documentation on how a `Q(**kwargs)` object behaves when
 `len(kwargs) == 0`, and we have no tests for it. Perhaps it should be
 raising an exception (or initially a deprecation warning).

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.e32432acb627c2f3134ec0f7e91164ba%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28731: Passing an empty Q() to a When inside a Case causes an OperationError

2017-10-21 Thread Django
#28731: Passing an empty Q() to a When inside a Case causes an OperationError
-+-
 Reporter:  Tom van Bussel   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  1.11
  (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
-+-
Description changed by Tom van Bussel:

Old description:

> The following code causes an OperationError:
> {{{
> q = Q() # Dynamically constructed, possibly empty
> x = TestModel.objects.annotate(test_name=When(q, then=Value(True)),
> default=Value(False), output_field=BooleanField())).all()
> print(x)
> }}}
> The code above results in a SQL query which contains {{{CASE WHEN
> THEN}}}, with nothing between the WHEN and THEN.

New description:

 The following code causes an OperationError:
 {{{
 q = Q() # Dynamically constructed, possibly empty
 x = TestModel.objects.annotate(test_name=Case(When(q, then=Value(True)),
 default=Value(False), output_field=BooleanField())).all()
 print(x)
 }}}
 The code above results in a SQL query which contains {{{CASE WHEN
 THEN}}}, with nothing between the WHEN and THEN.

--

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.b21597472c169fee699515297a4dd7f5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #28731: Passing an empty Q() to a When inside a Case causes an OperationError

2017-10-21 Thread Django
#28731: Passing an empty Q() to a When inside a Case causes an OperationError
-+-
   Reporter:  Tom van|  Owner:  nobody
  Bussel |
   Type:  Bug| Status:  new
  Component:  Database   |Version:  1.11
  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  |
-+-
 The following code causes an OperationError:
 {{{
 q = Q() # Dynamically constructed, possibly empty
 x = TestModel.objects.annotate(test_name=When(q, then=Value(True)),
 default=Value(False), output_field=BooleanField())).all()
 print(x)
 }}}
 The code above results in a SQL query which contains {{{CASE WHEN
 THEN}}}, with nothing between the WHEN and THEN.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.1e18a012840e69b94fa4b8b506f9cdb6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.