Re: [Django] #35235: ArrayAgg() doesn't return default when filter contains __in=[].

2024-04-12 Thread Django
#35235: ArrayAgg() doesn't return default when filter contains __in=[].
--+--
 Reporter:  Per Carlsen   |Owner:  Sharon Woo
 Type:  Bug   |   Status:  assigned
Component:  contrib.postgres  |  Version:  5.0
 Severity:  Normal|   Resolution:
 Keywords:  ArrayAgg  | Triage Stage:  Accepted
Has patch:  1 |  Needs documentation:  0
  Needs tests:  1 |  Patch needs improvement:  1
Easy pickings:  0 |UI/UX:  0
--+--
Changes (by Natalia Bidart):

 * has_patch:  0 => 1
 * needs_better_patch:  0 => 1
 * needs_tests:  0 => 1

Comment:

 [https://github.com/django/django/pull/17890 PR]
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018ed36d70d0-1ab2a922-1d21-44cc-b9dd-14f106545f05-00%40eu-central-1.amazonses.com.


Re: [Django] #35235: ArrayAgg() doesn't return default when filter contains __in=[].

2024-04-12 Thread Django
#35235: ArrayAgg() doesn't return default when filter contains __in=[].
--+--
 Reporter:  Per Carlsen   |Owner:  Sharon Woo
 Type:  Bug   |   Status:  assigned
Component:  contrib.postgres  |  Version:  5.0
 Severity:  Normal|   Resolution:
 Keywords:  ArrayAgg  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Comment (by Natalia Bidart):

 Hi Per, the current status of the ticket is reflected in the ticket
 history, where all conversations are documented openly.

 We greatly rely on the community for contributing both fixes and new
 features. If you have the time and desire to help, there is an ongoing
 effort from Sharon Woo in this PR:

 https://github.com/django/django/pull/17890

 One option would be to reach out to Sharon Woo and confirm whether they
 have time to continue working in the PR and see if/where you could be of
 help. If they don't, perhaps pick up where they left of? From a quick
 read, it seems that the bulk of the work was done, only some extra tests
 are needed.

 Thank you!
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018ed36d0c21-c2d877ed-c5b7-4f3b-afe6-5a5e46da01c5-00%40eu-central-1.amazonses.com.


Re: [Django] #35235: ArrayAgg() doesn't return default when filter contains __in=[].

2024-04-11 Thread Django
#35235: ArrayAgg() doesn't return default when filter contains __in=[].
--+--
 Reporter:  Per Carlsen   |Owner:  Sharon Woo
 Type:  Bug   |   Status:  assigned
Component:  contrib.postgres  |  Version:  5.0
 Severity:  Normal|   Resolution:
 Keywords:  ArrayAgg  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Comment (by Per Carlsen):

 Hi! Just wondering what the status of this ticket is and when you expect
 to have a fix ready? :-)
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018ecd66240d-55d56155-0749-4bde-8c73-4b22845e2442-00%40eu-central-1.amazonses.com.


Re: [Django] #35235: ArrayAgg() doesn't return default when filter contains __in=[].

2024-02-27 Thread Django
#35235: ArrayAgg() doesn't return default when filter contains __in=[].
--+--
 Reporter:  Per Carlsen   |Owner:  Sharon Woo
 Type:  Bug   |   Status:  assigned
Component:  contrib.postgres  |  Version:  5.0
 Severity:  Normal|   Resolution:
 Keywords:  ArrayAgg  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Comment (by Sharon Woo):

 Linking to a related ticket: https://code.djangoproject.com/ticket/35257
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018deb0861bb-d0ea4975-cde1-485a-bceb-ff2a59c288b1-00%40eu-central-1.amazonses.com.


Re: [Django] #35235: ArrayAgg() doesn't return default when filter contains __in=[].

2024-02-23 Thread Django
#35235: ArrayAgg() doesn't return default when filter contains __in=[].
--+--
 Reporter:  Per Carlsen   |Owner:  Sharon Woo
 Type:  Bug   |   Status:  assigned
Component:  contrib.postgres  |  Version:  5.0
 Severity:  Normal|   Resolution:
 Keywords:  ArrayAgg  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Comment (by David Sanders):

 @Mariusz, I noticed you didn't categorise this as a release blocker but
 just wanted to check whether it should be since next month is approaching
 - technically it's not a regression from 5.0 but it was "uncovered" by the
 change in default behaviour 
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018dd56227b2-8d888f12-e6b6-465a-bd9e-fe2b4282e1b6-00%40eu-central-1.amazonses.com.


Re: [Django] #35235: ArrayAgg() doesn't return default when filter contains __in=[].

2024-02-21 Thread Django
#35235: ArrayAgg() doesn't return default when filter contains __in=[].
--+--
 Reporter:  Per Carlsen   |Owner:  Sharon Woo
 Type:  Bug   |   Status:  assigned
Component:  contrib.postgres  |  Version:  5.0
 Severity:  Normal|   Resolution:
 Keywords:  ArrayAgg  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Comment (by Sharon Woo):

 Test app validates


 {{{
 @property
 def _output_field_or_none(self):
 }}}

 fixes the issue. Now to write a test and commit to remote.
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018dcf085ba4-d4e716d0-2598-48de-8dbf-0563755dd57c-00%40eu-central-1.amazonses.com.


Re: [Django] #35235: ArrayAgg() doesn't return default when filter contains __in=[].

2024-02-21 Thread Django
#35235: ArrayAgg() doesn't return default when filter contains __in=[].
--+--
 Reporter:  Per Carlsen   |Owner:  Sharon Woo
 Type:  Bug   |   Status:  assigned
Component:  contrib.postgres  |  Version:  5.0
 Severity:  Normal|   Resolution:
 Keywords:  ArrayAgg  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Comment (by Sharon Woo):

 Hi David and Simon, thank you! This is extremely helpful. I've posted on
 Discord and contributed a cat pic in the pets channel for good measure.

 I'm now able to reproduce exactly Felix's result locally, the little test
 app for reference (again definitely not best practice):
 https://github.com/sharonwoo/django/tree/test-app-for-pairing

 Now that I have this up, to make changes and push to remote with slightly
 more confidence.
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018dced4bcae-78180acf-6ce2-46b4-acbf-db3d27500220-00%40eu-central-1.amazonses.com.


Re: [Django] #35235: ArrayAgg() doesn't return default when filter contains __in=[].

2024-02-21 Thread Django
#35235: ArrayAgg() doesn't return default when filter contains __in=[].
--+--
 Reporter:  Per Carlsen   |Owner:  Sharon Woo
 Type:  Bug   |   Status:  assigned
Component:  contrib.postgres  |  Version:  5.0
 Severity:  Normal|   Resolution:
 Keywords:  ArrayAgg  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Comment (by David Sanders):

 ❤️ awesome

 @Sharon so that seems to be the solution if you'd like to prepare a patch
 

 ps: Many folks on Discord will happily answer your test setup q's if you
 still had them.
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018dcc760de9-30907ce5-452f-4585-b022-10e0016e62b1-00%40eu-central-1.amazonses.com.


Re: [Django] #35235: ArrayAgg() doesn't return default when filter contains __in=[].

2024-02-21 Thread Django
#35235: ArrayAgg() doesn't return default when filter contains __in=[].
--+--
 Reporter:  Per Carlsen   |Owner:  Sharon Woo
 Type:  Bug   |   Status:  assigned
Component:  contrib.postgres  |  Version:  5.0
 Severity:  Normal|   Resolution:
 Keywords:  ArrayAgg  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Comment (by Simon Charette):

 > Would there be any harm in simply changing @cached_property on
 BaseExpression._output_field_or_none to @property?

 I would definitely support that change! The cache invalidation challenges
 that the current implementation impose don't seem worth the mere caching
 benefits that caching `_output_field_or_none` over the already existing
 cached `output_field` cache provide.
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018dcc6d65d6-ff3ff4ac-46f6-48d1-aa34-474164ccc1fe-00%40eu-central-1.amazonses.com.


Re: [Django] #35235: ArrayAgg() doesn't return default when filter contains __in=[].

2024-02-21 Thread Django
#35235: ArrayAgg() doesn't return default when filter contains __in=[].
--+--
 Reporter:  Per Carlsen   |Owner:  Sharon Woo
 Type:  Bug   |   Status:  assigned
Component:  contrib.postgres  |  Version:  5.0
 Severity:  Normal|   Resolution:
 Keywords:  ArrayAgg  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Comment (by David Sanders):

 Replying to [comment:10 Simon Charette]:
 > Foot gun that we could probably disarm by making
 `BaseExpression.output_field` a `@property` that clears the
 `_output_field_or_none` cache on assignment as I wouldn't be surprised
 other well intended `.output_field` assignments are not working as
 expected.

 Would there be any harm in simply removing `@cached_property` on
 `BaseExpression._output_field_or_none`? 樂  It's body is simply:

 {{{
 @cached_property
 def _output_field_or_none(self):
 try:
 return self.output_field
 except FieldError:
 if not self._output_field_resolved_to_none:
 raise
 }}}

 and `output_field` is already `@cached_property` as you mentioned, so it
 seems redundant. These 2 methods were both introduced as cached props when
 originally added by Josh in 2013. I just wonder whether Josh was being
 extra safe around the `FieldError` handling.
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018dcc2a0ae7-1a274f78-2c85-4b00-b3d6-1c7281ec586a-00%40eu-central-1.amazonses.com.


Re: [Django] #35235: ArrayAgg() doesn't return default when filter contains __in=[].

2024-02-21 Thread Django
#35235: ArrayAgg() doesn't return default when filter contains __in=[].
--+--
 Reporter:  Per Carlsen   |Owner:  Sharon Woo
 Type:  Bug   |   Status:  assigned
Component:  contrib.postgres  |  Version:  5.0
 Severity:  Normal|   Resolution:
 Keywords:  ArrayAgg  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Comment (by Simon Charette):

 Thanks for taking a shot at fixing the issue Sharon and the mentoring
 David.

 Just dropping a message to say that I believe your solution in comment:5
 and your assessment about similarity with #35149 is right David. I guess
 an alternative could be to wrap the default in `ExpressionWrapper` instead
 to avoid the `.output_field` assignment foot gun. Foot gun that we could
 probably disarm by making `BaseExpression.output_field` a `@property` that
 clears the `_output_field_or_none` cache on assignment as I wouldn't be
 surprised other well intended `.output_field` assignments are not working
 as expected.

 We should definitely address this issue and I wonder if we should also
 adjust the documentation to denote that the `Value` wrapping is not
 necessary anymore (in other words `default=[]` should just work).
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018dcc0da3f4-a678e380-95f0-432c-b5c9-64f6fd613b50-00%40eu-central-1.amazonses.com.


Re: [Django] #35235: ArrayAgg() doesn't return default when filter contains __in=[].

2024-02-21 Thread Django
#35235: ArrayAgg() doesn't return default when filter contains __in=[].
--+--
 Reporter:  Per Carlsen   |Owner:  Sharon Woo
 Type:  Bug   |   Status:  assigned
Component:  contrib.postgres  |  Version:  5.0
 Severity:  Normal|   Resolution:
 Keywords:  ArrayAgg  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Comment (by David Sanders):

 I may have misled you there… on GH I mentioned not needing test data but
 you do actually need at least one row present in the table to get the
 wrong result.  (The reason why my simplified test worked is because
 there's data in `setupTestData()`)

 To explain:

 The source of the issue is when the aggregate filter is testing for a
 "contradiction" (ie something that's guaranteed to be false), eg:

 {{{
 ArrayAgg(…, filter=Q(whatever__in=[]))
 }}}

 here it's guaranteed that the filter will always be false. Django has a
 chance to do some optimisations when this occurs.

 Normally when you do

 {{{
 Foo.objects.filter(whatever__in=[])
 }}}

 Django will raise an `EmptyResultSet` and the catching code will skip
 calling the db altogether so as not to run an unnecessary query & save on
 time.

 However, when it's within an annotation, Django still needs to run the
 query.  The optimisation that occurs in this case is that Django will
 simplify the expression instead.

 If you observe the query (by doing `print(queryset.query)`) you'll see
 that the annotation has been optimised to:

 {{{
 SELECT …, COALESCE(NULL, '{}') …
 }}}

 where Django has deliberately replaced the input to `COALESCE` with
 `NULL`.

 This reveals the source of the problem: the expression `COALESCE(NULL,
 '{}')` is of type string.  It _should_ be something along the lines of
 `COALESCE(NULL, '{}'::integer[])` to force the expression to be of type
 integer array.

 Hope that helps?   Sorry for the long-winded explanation but it took me
 yonks to realise what was happening under the hood with Django so thought
 you could use the primer 
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018dcb1a1aca-b5631506-cda8-4695-8e06-35b1ad659756-00%40eu-central-1.amazonses.com.


Re: [Django] #35235: ArrayAgg() doesn't return default when filter contains __in=[].

2024-02-21 Thread Django
#35235: ArrayAgg() doesn't return default when filter contains __in=[].
--+--
 Reporter:  Per Carlsen   |Owner:  Sharon Woo
 Type:  Bug   |   Status:  assigned
Component:  contrib.postgres  |  Version:  5.0
 Severity:  Normal|   Resolution:
 Keywords:  ArrayAgg  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Comment (by Sharon Woo):

 Sorry for the lack of progress, before I pushed more code into remote I
 wanted to get a debugger and the postgres tests running locally... and
 neither has led to much:

 1. I spent some time this morning setting up a simple app (branching off
 main at 561e16d6a7 and an empty postgres db, if it matters) to reproduce
 Felix's example before I make any further changes. However, instead of the
 mythical '{}', I always get None for `result` instead, no matter what I
 pass into default. I am going to step through a bit more here.

 2. I also spent some time looking into how to run the postgres tests
 locally (they are always skipped now using tox / runtests.py) -- better
 yet if I can step through the tests in a debugger, but haven't had any
 luck with resources. What I've done is searched in our favourite search
 engines and Discord, but lots of posts on general postgres/testing to sift
 through. Anyone?
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018dcadf8fa2-801abd83-670e-4dbb-b7b5-e9973af7666f-00%40eu-central-1.amazonses.com.


Re: [Django] #35235: ArrayAgg() doesn't return default when filter contains __in=[].

2024-02-20 Thread Django
#35235: ArrayAgg() doesn't return default when filter contains __in=[].
--+--
 Reporter:  Per Carlsen   |Owner:  Sharon Woo
 Type:  Bug   |   Status:  assigned
Component:  contrib.postgres  |  Version:  5.0
 Severity:  Normal|   Resolution:
 Keywords:  ArrayAgg  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Comment (by David Sanders):

 Replying to [comment:6 Sharon Woo]:
 > Thanks for being patient with me. Let me get through everything and come
 back with an improved PR, I have some time this week.

 No worries, everyone is on Discord (chat) or the forum if you need help
 with anything   Details here: https://www.djangoproject.com/community/
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018dc6d99929-28856c40-5cad-4a8f-9126-48a957137bbd-00%40eu-central-1.amazonses.com.


Re: [Django] #35235: ArrayAgg() doesn't return default when filter contains __in=[].

2024-02-20 Thread Django
#35235: ArrayAgg() doesn't return default when filter contains __in=[].
--+--
 Reporter:  Per Carlsen   |Owner:  Sharon Woo
 Type:  Bug   |   Status:  assigned
Component:  contrib.postgres  |  Version:  5.0
 Severity:  Normal|   Resolution:
 Keywords:  ArrayAgg  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Comment (by Sharon Woo):

 Thanks for being patient with me. Let me get through everything and come
 back with an improved PR, I have some time this week.
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018dc6d1d089-8098a6ed-ab0f-4357-a35f-9ab23529ae26-00%40eu-central-1.amazonses.com.


Re: [Django] #35235: ArrayAgg() doesn't return default when filter contains __in=[].

2024-02-20 Thread Django
#35235: ArrayAgg() doesn't return default when filter contains __in=[].
--+--
 Reporter:  Per Carlsen   |Owner:  Sharon Woo
 Type:  Bug   |   Status:  assigned
Component:  contrib.postgres  |  Version:  5.0
 Severity:  Normal|   Resolution:
 Keywords:  ArrayAgg  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Comment (by David Sanders):

 Looks like this patch fixes the issue:

 {{{
 --- a/django/db/models/aggregates.py
 +++ b/django/db/models/aggregates.py
 @@ -92,7 +92,7 @@ class Aggregate(Func):
  return c
  if hasattr(default, "resolve_expression"):
  default = default.resolve_expression(query, allow_joins,
 reuse, summarize)
 -if default._output_field_or_none is None:
 +if default._resolve_output_field() is None:
  default.output_field = c._output_field_or_none
  else:
  default = Value(default, c._output_field_or_none)
 }}}

 The problem is `Aggregate.resolve_expression()` calls
 `default._output_field_or_none` which then caches the `None` because it's
 a `@cached_property` which makes setting the `output_field`
 essentially a no-op.
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018dc63f336f-3b7cde50-3a66-4462-8d43-0fa563e06aa7-00%40eu-central-1.amazonses.com.


Re: [Django] #35235: ArrayAgg() doesn't return default when filter contains __in=[].

2024-02-20 Thread Django
#35235: ArrayAgg() doesn't return default when filter contains __in=[].
--+--
 Reporter:  Per Carlsen   |Owner:  Sharon Woo
 Type:  Bug   |   Status:  assigned
Component:  contrib.postgres  |  Version:  5.0
 Severity:  Normal|   Resolution:
 Keywords:  ArrayAgg  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Comment (by David Sanders):

 If you change felix' example to add
 `output_field=ArrayField(IntegerField())` to the default, it works 
 seems related to #35149 where `db_default` required `output_field` set? 樂
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018dc5ead045-1991d5e6-c9d3-4b04-a6c9-db0fd22acd60-00%40eu-central-1.amazonses.com.


Re: [Django] #35235: ArrayAgg() doesn't return default when filter contains __in=[]. (was: ArrayAgg inconsistent return value when no results)

2024-02-20 Thread Django
#35235: ArrayAgg() doesn't return default when filter contains __in=[].
--+--
 Reporter:  Per Carlsen   |Owner:  Sharon Woo
 Type:  Bug   |   Status:  assigned
Component:  contrib.postgres  |  Version:  5.0
 Severity:  Normal|   Resolution:
 Keywords:  ArrayAgg  | Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Changes (by Mariusz Felisiak):

 * cc: Simon Charette, Nick Pope (added)
 * stage:  Unreviewed => Accepted
 * summary:  ArrayAgg inconsistent return value when no results =>
 ArrayAgg() doesn't return default when filter contains __in=[].

Comment:

 I was able to reproduce the issue with a small models:
 {{{#!python
 class MyModel(models.Model):
 pass


 class MyOtherModel(models.Model):
 mymodel = models.ForeignKey(MyModel, models.CASCADE)

 for filter_value in ([], [-1]):
 for default in ([], Value([])):
 result = MyModel.objects.annotate(
 annotated_ids=ArrayAgg(
 "myothermodel__id",
 filter=Q(
 myothermodel__id__in=filter_value,
 ),
 default=Value([]),
 )
 ).first().annotated_ids
 print(result, filter_value, default)

 }}}
 results
 {{{
 {} [] []
 {} [] Value([])
 [] [-1] []
 [] [-1] Value([])
 }}}
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018dc5acf92d-daa82adf-4aaf-4cd3-a253-fc61142d9a73-00%40eu-central-1.amazonses.com.