Loading AUTHORS +1 −0 Original line number Diff line number Diff line Loading @@ -314,6 +314,7 @@ answer newbie questions, and generally made Django that much better: Jason Yan <tailofthesun@gmail.com> Javier Mansilla <javimansilla@gmail.com> Jay Parlar <parlar@gmail.com> Jay Wineinger <jay.wineinger@gmail.com> J. Clifford Dyer <jcd@sdf.lonestar.org> jcrasta@gmail.com jdetaeye Loading django/db/models/sql/compiler.py +4 −1 Original line number Diff line number Diff line Loading @@ -1012,7 +1012,10 @@ class SQLUpdateCompiler(SQLCompiler): raise FieldError("Aggregate functions are not allowed in this query") elif hasattr(val, 'prepare_database_save'): if field.remote_field: val = val.prepare_database_save(field) val = field.get_db_prep_save( val.prepare_database_save(field), connection=self.connection, ) else: raise TypeError("Database is trying to update a relational field " "of type %s with a value of type %s. Make sure " Loading docs/releases/1.8.1.txt +3 −0 Original line number Diff line number Diff line Loading @@ -38,3 +38,6 @@ Bugfixes * Prevented arbitrary file inclusions in :mod:`~django.contrib.admindocs` (:ticket:`24625`). * Fixed a crash with ``QuerySet.update()`` on foreign keys to instances with ``uuid`` primary keys (:ticket:`24611`). tests/model_fields/test_uuid.py +17 −0 Original line number Diff line number Diff line Loading @@ -129,3 +129,20 @@ class TestAsPrimaryKey(TestCase): RelatedToUUIDModel.objects.create(uuid_fk=pk_model) related = RelatedToUUIDModel.objects.get() self.assertEqual(related.uuid_fk.pk, related.uuid_fk_id) def test_update_with_related_model_instance(self): # regression for #24611 u1 = PrimaryKeyUUIDModel.objects.create() u2 = PrimaryKeyUUIDModel.objects.create() r = RelatedToUUIDModel.objects.create(uuid_fk=u1) RelatedToUUIDModel.objects.update(uuid_fk=u2) r.refresh_from_db() self.assertEqual(r.uuid_fk, u2) def test_update_with_related_model_id(self): u1 = PrimaryKeyUUIDModel.objects.create() u2 = PrimaryKeyUUIDModel.objects.create() r = RelatedToUUIDModel.objects.create(uuid_fk=u1) RelatedToUUIDModel.objects.update(uuid_fk=u2.pk) r.refresh_from_db() self.assertEqual(r.uuid_fk, u2) Loading
AUTHORS +1 −0 Original line number Diff line number Diff line Loading @@ -314,6 +314,7 @@ answer newbie questions, and generally made Django that much better: Jason Yan <tailofthesun@gmail.com> Javier Mansilla <javimansilla@gmail.com> Jay Parlar <parlar@gmail.com> Jay Wineinger <jay.wineinger@gmail.com> J. Clifford Dyer <jcd@sdf.lonestar.org> jcrasta@gmail.com jdetaeye Loading
django/db/models/sql/compiler.py +4 −1 Original line number Diff line number Diff line Loading @@ -1012,7 +1012,10 @@ class SQLUpdateCompiler(SQLCompiler): raise FieldError("Aggregate functions are not allowed in this query") elif hasattr(val, 'prepare_database_save'): if field.remote_field: val = val.prepare_database_save(field) val = field.get_db_prep_save( val.prepare_database_save(field), connection=self.connection, ) else: raise TypeError("Database is trying to update a relational field " "of type %s with a value of type %s. Make sure " Loading
docs/releases/1.8.1.txt +3 −0 Original line number Diff line number Diff line Loading @@ -38,3 +38,6 @@ Bugfixes * Prevented arbitrary file inclusions in :mod:`~django.contrib.admindocs` (:ticket:`24625`). * Fixed a crash with ``QuerySet.update()`` on foreign keys to instances with ``uuid`` primary keys (:ticket:`24611`).
tests/model_fields/test_uuid.py +17 −0 Original line number Diff line number Diff line Loading @@ -129,3 +129,20 @@ class TestAsPrimaryKey(TestCase): RelatedToUUIDModel.objects.create(uuid_fk=pk_model) related = RelatedToUUIDModel.objects.get() self.assertEqual(related.uuid_fk.pk, related.uuid_fk_id) def test_update_with_related_model_instance(self): # regression for #24611 u1 = PrimaryKeyUUIDModel.objects.create() u2 = PrimaryKeyUUIDModel.objects.create() r = RelatedToUUIDModel.objects.create(uuid_fk=u1) RelatedToUUIDModel.objects.update(uuid_fk=u2) r.refresh_from_db() self.assertEqual(r.uuid_fk, u2) def test_update_with_related_model_id(self): u1 = PrimaryKeyUUIDModel.objects.create() u2 = PrimaryKeyUUIDModel.objects.create() r = RelatedToUUIDModel.objects.create(uuid_fk=u1) RelatedToUUIDModel.objects.update(uuid_fk=u2.pk) r.refresh_from_db() self.assertEqual(r.uuid_fk, u2)