#26355: Postgres ArrayField append
----------------------------------+-----------------
Reporter: graup | Owner:
Type: New feature | Status: new
Component: contrib.postgres | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+-----------------
I am using an ArrayField to store a list of dates. I would like to use
`update()` to add a value to the list, only if the list doesn't contain it
already.
The `contains` part is already supported by Django, but not the
`array_append`.
http://www.postgresql.org/docs/9.1/static/arrays.html#ARRAYS-MODIFYING
Eventually I'd like to be able to do something like this:
`User.objects.exclude(active_in__contains=[current_month]).update(active_in=F('active_in')
+ [current_month])`
which should result in this SQL:
`UPDATE user_user SET active_in = array_append(active_in, [%s]) WHERE
NOT(active_in @> ARRAY[%s]::varchar[]) ['2012-01']`
PS: I want to use `update` instead of `get()` and `save()` for performance
reasons.
--
Ticket URL: <https://code.djangoproject.com/ticket/26355>
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/048.b69be9e756cd978f5a3a6cef43720519%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.