mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #10362 -- An update() that only affects a parent model no longer crashes.
This includes a fairly large refactor of the update() query path (and the initial portions of constructing the SQL for any query). The previous code appears to have been only working more or less by accident and was very fragile. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9967 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -222,7 +222,7 @@ True
|
||||
>>> obj = SelfRefChild.objects.create(child_data=37, parent_data=42)
|
||||
>>> obj.delete()
|
||||
|
||||
# Regression tests for #8076 - get_(next/previous)_by_date should
|
||||
# Regression tests for #8076 - get_(next/previous)_by_date should work.
|
||||
>>> c1 = ArticleWithAuthor(headline='ArticleWithAuthor 1', author="Person 1", pub_date=datetime.datetime(2005, 8, 1, 3, 0))
|
||||
>>> c1.save()
|
||||
>>> c2 = ArticleWithAuthor(headline='ArticleWithAuthor 2', author="Person 2", pub_date=datetime.datetime(2005, 8, 1, 10, 0))
|
||||
@@ -267,4 +267,12 @@ DoesNotExist: ArticleWithAuthor matching query does not exist.
|
||||
>>> fragment.find('pub_date', pos + 1) == -1
|
||||
True
|
||||
|
||||
# It is possible to call update() and only change a field in an ancestor model
|
||||
# (regression test for #10362).
|
||||
>>> article = ArticleWithAuthor.objects.create(author="fred", headline="Hey there!", pub_date = datetime.datetime(2009, 3, 1, 8, 0, 0))
|
||||
>>> ArticleWithAuthor.objects.filter(author="fred").update(headline="Oh, no!")
|
||||
1
|
||||
>>> ArticleWithAuthor.objects.filter(pk=article.pk).update(headline="Oh, no!")
|
||||
1
|
||||
|
||||
"""}
|
||||
|
||||
Reference in New Issue
Block a user