Re: Update returning

2023-09-25 Thread Aivars Kalvāns
Hi!

I want to implement these changes and I have a PR in the 
ticket https://code.djangoproject.com/ticket/32406
At the moment I have a new `update_returning` method but I can easily 
replace it with ` (updates=None, *, returning:bool=None, **kwargs)` if you 
decide to add functionality to the existing method instead. I did a search 
on github and found only a single project with `returning` as model field.
However the returned value in my implementation is a `QuerySet` and I can 
do `.get()`, `.only()`, `.defer()` and `.values()` or `.values_list()` on 
that. Mainly because my use case is updating and refreshing the model in a 
single database operation. The ticket has more examples. What do you think, 
do you see any issues with this approach?

trešdiena, 2021. gada 12. maijs 15:18:50 UTC+3 Tom Carrick rakstīja:

> Apologies, I had totally forgotten about this, but I'm still interested in 
> working on it, but still not sure about a few things.
>
> I've been thinking about the return value a bit. I can foresee cases where 
> you wouldn't want the id returned.  You might want the user to update 
> something by slug, username, or some other identifier without revealing the 
> IDs. Of course the user could reformat the return value however they like, 
> but I don't see a reason to ask for something that isn't necessary.
>
> So I think a list of some kind of object (namedtuple or dict probably) 
> makes the most sense to me. As for also adding the count, I am not sure. 
> The return value would then be e.g. (1, []). I'm guessing this count 
> would remain as the number of matched rows, rather than the updated ones - 
> I am not sure if returning only gives back rows that were modified or not, 
> the Postgres docs are at least unclear on this. If they're always going to 
> be the same, I'm not sure there is much reason for returning the count when 
> len(return_value) will do.
>
> I'm also not really sure on the data structure though. Namedtuples make 
> the most sense to me but a dict might be useful for those wanting to shove 
> this directly into JsonResponse, without needing _asdict(), for example.
>
> Cheers,
> Tom
>
> On Wed, 27 Jan 2021 at 10:45, Florian Apolloner  
> wrote:
>
>> Hi Simon,
>>
>> On Wednesday, January 27, 2021 at 5:54:42 AM UTC+1 charettes wrote:
>>
>>> I think that's the best option here if we want to elegantly add support 
>>> for this feature while maintaining backward compability. Something along 
>>> the lines of ...
>>>
>>
>> That is certainly an interesting approach. It kinda breaks the "there 
>> should be one way of doing things" rule, but…
>>
>> The usage of `returning` bring another set of questions though. Since 
>>> UPDATE are not ordered RETURNING data has little value without the primary 
>>> key associated with the updated rows. Maybe the return value of 
>>> `returning=[f1, ..., fn]` should be a dict mapping the primary key to list 
>>> of returning values.
>>>
>>
>> I am not sure I like that. For things where you update just one row and 
>> want to know the new values the primary key doesn't make much sense. 
>> Granted for multiple rows it would maybe easier to have it automatically 
>> keyed by the pk, but returning something always (the pk) without having an 
>> option to disable  it seems kinda wrong to me. Not sure what the best 
>> option would be.
>>
>> Cheers,
>> Florian
>>
>> -- 
>>
> You received this message because you are subscribed to the Google Groups 
>> "Django developers (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-develop...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-developers/4eea605a-57d7-4ce3-b233-3eb88c91e110n%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/ee284d47-6181-426d-98fd-3a0e50e0d9abn%40googlegroups.com.


Fellow Reports - September 2023

2023-09-25 Thread Mariusz Felisiak

Week ending September 10, 2023


Released Django 4.2.5, 4.1.11, and 3.2.21.

Prepared https://code.djangoproject.com/wiki/Version5.1Roadmap.

*Triaged:*
https://code.djangoproject.com/ticket/10808 - Multiple inheritance 
(model-based) broken for __init__ of common fields in diamond 
inheritance (invalid)
https://code.djangoproject.com/ticket/34814 - Confirm support for 
PostGIS 3.4 (accepted)
https://code.djangoproject.com/ticket/34810 - Calculate coverage on 
subprocesses such as django-admin commands (accepted)
https://code.djangoproject.com/ticket/34815 - urls file in startapp 
command (duplicate)
https://code.djangoproject.com/ticket/34816 - GenericForeignKey crashes 
if content_type_id is changed and object_id is type incompatible with 
old object (accepted)
https://code.djangoproject.com/ticket/26836 - Allow applications to 
register links in the admin interface (wontfix)
https://code.djangoproject.com/ticket/34819 - 
GenericForeignKey.get_prefetch_queryset() (accepted)
https://code.djangoproject.com/ticket/34820 - Migrations crashes when 
changing ForeignObject properties. (accepted)
https://code.djangoproject.com/ticket/34821 - Syncing 
DEFAULT_FILE_STORAGE/STATICFILES_STORAGE settings with STORAGES can 
mutate user settings. (created)
https://code.djangoproject.com/ticket/34823 - assertTemplateUsed() 
context manager crashes for templates without names. (accepted)


*Reviewed/committed:*
https://github.com/django/django/pull/17223 - Refs #31262 -- Renamed 
ChoiceIterator to BaseChoiceIterator.
https://github.com/django/django/pull/17224 - Fixed #34814 -- Confirmed 
support for PostGIS 3.4.
https://github.com/django/django/pull/17225 - Refs #34233 -- Bumped 
minimum supported version of docutils to 0.19.
https://github.com/django/django/pull/17101 - Fixed #34730 -- Added 
contrib.messages.test.MessagesTestMixin.assertMessages().
https://github.com/django/django/pull/16860 - Fixed #31300 -- Added 
GeneratedField model field.
https://github.com/django/django/pull/17207 - Fixed #34791 -- Fixed 
incorrect Prefetch()'s cache for singly related objects.
https://github.com/django/django/pull/17234 - Fixed #34816 -- Fixed 
GenericForeignKey crash when checking cache for primary keys with 
different types.
https://github.com/django/django/pull/17240 - Fixed #34820 -- Fixed 
migrations crash when changing a ForeignObject field.

*
**Authored:*
https://github.com/django/django/pull/17236 - Fixed #34821 -- Prevented 
DEFAULT_FILE_STORAGE/STATICFILES_STORAGE settings from mutating the main 
STORAGES.
https://github.com/django/django/pull/17239 - Bumped versions in 
pre-commit and npm configurations.



Week ending September 17, 2023


*Triaged:*
https://code.djangoproject.com/ticket/34824 - Migrations generates two 
records when ForeignObject.to_fields/from_fields is not a tuple. (accepted)
https://code.djangoproject.com/ticket/34829 - Django reports the 
“mutually exclusive” error for settings that do not contain 
STATICFILES_STORAGE. (worksforme)
https://code.djangoproject.com/ticket/34822 - Provide migration 
serializer for `_lru_cache_wrapper` (accepted)
https://code.djangoproject.com/ticket/34832 - Use `banner` landmark or 
`` element for the admin header area (accepted)
https://code.djangoproject.com/ticket/34833 - Use a `main` landmark in 
the admin interface (accepted)
https://code.djangoproject.com/ticket/34834 - Use `search` role for the 
admin changelist search form (accepted)
https://code.djangoproject.com/ticket/34835 - Use a `nav` element or 
`navigation` landmark for changelist filters (accepted)
https://code.djangoproject.com/ticket/34836 - Add an optional argument 
to MultipleChoiceField to ignore invalid choices. (wontfix)
https://code.djangoproject.com/ticket/34838 - GeoDjango database 
functions incompatible with GeneratedField (accepted)
https://code.djangoproject.com/ticket/34839 - OperationalError from 
Psycopg when using Connection Pool (Digital Ocean)  Django 4.2.3  
psycopg 3.1.9 (duplicate)
https://code.djangoproject.com/ticket/34842 - Unmanaged read-only 
generated fields in admin (accepted)
https://code.djangoproject.com/ticket/34844 - Missing dependency 
backports with install of 4.1.11 (invalid)


*Reviewed/committed:*
https://github.com/django/django/pull/17173 - Fixed #34642 -- Added 
File.open() support for *args and **kwargs.
https://github.com/django/django/pull/17238 - Fixed #34824 -- Prevented 
unnecessary AlterField when ForeignObject.from_fields/to_fields is not a 
tuple.
https://github.com/django/django/pull/17147 - Fixed #34752 -- Fixed 
handling ASGI http.disconnect for streaming responses.
https://github.com/django/django/pull/17248 - Removed 
ChoicesMeta.__contains__() for Python 3.12+.
https://github.com/django/django/pull/17249 - Renamed ChoicesMeta to 
ChoicesType.
https://github.com/django/django/pull/17186 - Modernized enumeration 
helpers on Python 3.11+.
https://github.com/django/django/pull/17252 - Added more tests for 
decorators.
https://github.com/django/