#24709: ArrayField doesn't support .update() and F() objects -------------------------------------+------------------------------------- Reporter: ris | Owner: nobody Type: New feature | Status: new Component: contrib.postgres | Version: 1.8 Severity: Normal | Resolution: Keywords: postgresql contrib | Triage Stage: Accepted arrayfield update | Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by mjtamlyn): The silent coercion to string is normal behaviour for Django actually in many cases - we actually would like `ModelA.objects.update(name_array=[1, 2])` to work (as it would if it were a `CharField`. Supporting F objects like that is a very nice idea, but I'm not sure how possible it is. If we do implement it, it should work for Hstore and Json as well. In these cases there are more complex options - for example you can update just a single key of the Hstore without affecting the rest, which would be a very useful addition. A simpler option could be to have a distinct API for it - something like `ModelA.objects.update(name_array=FArray(0, F(name))` which would generate an update statement like `UPDATE app_modela SET name_array[0]=F(name)`. This API could also be a bit clever, and also support `ModelA.objects.update(name_array=FArray([F('name')]))`. We would then have similar FJSON and FHstore objects. I'm pretty sure these could be supported without changes to the core ORM by making them look sufficiently like F objects. -- Ticket URL: <https://code.djangoproject.com/ticket/24709#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 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/061.95b69e7deaa560406853bf744b3bf516%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.