#24690: ArrayField data bleeds between instances when using field.append(item) ----------------------------------+--------------------------------- Reporter: redbeard0x0a | Owner: Type: Bug | Status: new Component: contrib.postgres | Version: 1.8 Severity: Normal | Keywords: ArrayField postgres Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 ----------------------------------+--------------------------------- I found an issue when upgrading to Django 1.8 and using the new ArrayField and a model's instance methods.
This code will cause Model#array_field's data to bleed between different instances. {{{ def add_to_array(self, item): if item not in self.array_field: self.array_field.append(item) }}} However, this code does the correct thing: {{{ def add_to_array(self, item): existing = self.array_field if item not in self.array_field: self.array_field = existing + [item] }}} I put together a django project/app with the code and tests that show the problems with self.array_field.append(). It also has a Vagrant file setup that should also exhibit the problems. https://github.com/redbeard0x0a/django18bug -- Ticket URL: <https://code.djangoproject.com/ticket/24690> 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/055.ff198e721af5c641b11f89d5afe0d8e6%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.