Re: [Django] #13261: SQL Update VS extra() or filter()

2010-04-03 Thread Django
#13261: SQL Update VS extra() or filter()
---+
  Reporter:  Stephane  | Owner:  nobody 

Status:  closed| Milestone:  1.2

 Component:  Database layer (models, ORM)  |   Version:  SVN

Resolution:  worksforme|  Keywords:  sql update 
extra filter
 Stage:  Accepted  | Has_patch:  0  

Needs_docs:  0 |   Needs_tests:  0  

Needs_better_patch:  0 |  
---+
Changes (by russellm):

  * status:  new => closed
  * resolution:  => worksforme

Comment:

 Ok, now that I've tried to replicate, I can't make sense of this either.
 @Stéphane -- if you can provide a test case (i.e., an example of actual
 models and queries where this problem occurs), please reopen.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #13270: Fixed Typo In Documentation

2010-04-03 Thread Django
#13270: Fixed Typo In Documentation
+---
  Reporter:  cmbeelby   | Owner:  nobody
Status:  new| Milestone:  1.2   
 Component:  Documentation  |   Version:  SVN   
Resolution: |  Keywords:  typo, contributing
 Stage:  Ready for checkin  | Has_patch:  1 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Changes (by russellm):

  * milestone:  => 1.2

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #13269: "Overriding the default widgets" docs missing import statement

2010-04-03 Thread Django
#13269: "Overriding the default widgets" docs missing import statement
+---
  Reporter:  mattrowbum | Owner:  gabrielhurley
Status:  assigned   | Milestone:  1.2  
 Component:  Documentation  |   Version:  1.2-beta 
Resolution: |  Keywords:  widgets, form field types
 Stage:  Accepted   | Has_patch:  1
Needs_docs:  0  |   Needs_tests:  0
Needs_better_patch:  0  |  
+---
Changes (by gabrielhurley):

  * has_patch:  0 => 1

Comment:

 Clarified example text (fixing a typo in the process), and added proper
 import statement to example.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #13270: Fixed Typo In Documentation

2010-04-03 Thread Django
#13270: Fixed Typo In Documentation
+---
  Reporter:  cmbeelby   | Owner:  nobody
Status:  new| Milestone:
 Component:  Documentation  |   Version:  SVN   
Resolution: |  Keywords:  typo, contributing
 Stage:  Ready for checkin  | Has_patch:  1 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Changes (by timo):

  * stage:  Unreviewed => Ready for checkin

Comment:

 Thanks, in the future, please generate patches from the svn root, i.e.
 docs/internals/contributing.txt.  That makes it easy for the core
 developers to apply patches.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #13270: Fixed Typo In Documentation

2010-04-03 Thread Django
#13270: Fixed Typo In Documentation
+---
  Reporter:  cmbeelby   | Owner:  nobody
Status:  new| Milestone:
 Component:  Documentation  |   Version:  SVN   
Resolution: |  Keywords:  typo, contributing
 Stage:  Unreviewed | Has_patch:  1 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Changes (by cmbeelby):

  * stage:  Ready for checkin => Unreviewed

Comment:

 After further reading in the file I also found an unbalanced pair of
 quoting marks. I have updated the patch to include both fixes. I'll set
 the stage back to unreviewed so that it doesn't look like I'm trying to
 sneak in a change after the status was set to ready for checkin.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #6735: Class-based generic views

2010-04-03 Thread Django
#6735: Class-based generic views
+---
  Reporter:  jkocherhans| Owner:  telenieko
Status:  assigned   | Milestone:   
 Component:  Generic views  |   Version:   
Resolution: |  Keywords:   
 Stage:  Accepted   | Has_patch:  1
Needs_docs:  1  |   Needs_tests:  0
Needs_better_patch:  0  |  
+---
Changes (by ssteiner):

 * cc: sstein...@gmail.com (added)

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #11058: list_display_links doesn't allow callables not defined in the model

2010-04-03 Thread Django
#11058: list_display_links doesn't allow callables not defined in the model
---+
  Reporter:  dvine | Owner:  cmbeelby  
Status:  assigned  | Milestone:
 Component:  django.contrib.admin  |   Version:  1.0   
Resolution:|  Keywords:  list_display_links
 Stage:  Accepted  | Has_patch:  1 
Needs_docs:  0 |   Needs_tests:  1 
Needs_better_patch:  0 |  
---+
Changes (by cmbeelby):

  * needs_docs:  1 => 0

Comment:

 Not sure what you mean by needs docs. This is not a new feature and the
 existing documentation is correct. This fixes a bug in the source which
 makes the admin site produce an error when following the guidelines given
 in the documentation. Specifically the documentation at
 
http://docs.djangoproject.com/en/1.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display_links
 says that list_display_links can be anything that is in list_display.

 As far as needing test's that is certainly something I can look into, but
 will probably take a few more days to get something setup. I can see a
 simple test would be to create four items in the list_display of the four
 types that are allowed based on the documentation and then verify that the
 list_display_links can also refer to them all.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #13261: SQL Update VS extra() or filter()

2010-04-03 Thread Django
#13261: SQL Update VS extra() or filter()
---+
  Reporter:  Stephane  | Owner:  nobody 

Status:  new   | Milestone:  1.2

 Component:  Database layer (models, ORM)  |   Version:  SVN

Resolution:|  Keywords:  sql update 
extra filter
 Stage:  Accepted  | Has_patch:  0  

Needs_docs:  0 |   Needs_tests:  0  

Needs_better_patch:  0 |  
---+
Comment (by Alex):

 I don't see how this is possible.  extra where clause items are placed in
 self.where on teh query, like every filter.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #13261: SQL Update VS extra() or filter()

2010-04-03 Thread Django
#13261: SQL Update VS extra() or filter()
---+
  Reporter:  Stephane  | Owner:  nobody 

Status:  new   | Milestone:  1.2

 Component:  Database layer (models, ORM)  |   Version:  SVN

Resolution:|  Keywords:  sql update 
extra filter
 Stage:  Accepted  | Has_patch:  0  

Needs_docs:  0 |   Needs_tests:  0  

Needs_better_patch:  0 |  
---+
Comment (by anonymous):

 Stephane, I've tried adding a test for this but I can't seem to hit this
 bug. Can you please confirm whether the bug is only triggered when using
 ModelForms?

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #13269: "Overriding the default widgets" docs missing import statement

2010-04-03 Thread Django
#13269: "Overriding the default widgets" docs missing import statement
+---
  Reporter:  mattrowbum | Owner:  gabrielhurley
Status:  assigned   | Milestone:  1.2  
 Component:  Documentation  |   Version:  1.2-beta 
Resolution: |  Keywords:  widgets, form field types
 Stage:  Accepted   | Has_patch:  0
Needs_docs:  0  |   Needs_tests:  0
Needs_better_patch:  0  |  
+---
Changes (by gabrielhurley):

  * status:  new => assigned
  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * summary:  Possible docs error - Overriding the default field types or
  widgets => "Overriding the default widgets"
  docs missing import statement
  * milestone:  => 1.2
  * owner:  nobody => gabrielhurley
  * needs_docs:  => 0
  * stage:  Unreviewed => Accepted

Comment:

 Yeah, there is a problem there. At no point on the page does it actually
 import TextArea. Your solution is one way to fix it, or simply changing it
 to ``from django.forms import ModelForm, TextArea`` would also work.

 Trivial docs ticket to add to 1.2. I'll write up a patch a little later
 today.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #13270: Fixed Typo In Documentation

2010-04-03 Thread Django
#13270: Fixed Typo In Documentation
+---
  Reporter:  cmbeelby   | Owner:  nobody
Status:  new| Milestone:
 Component:  Documentation  |   Version:  SVN   
Resolution: |  Keywords:  typo, contributing
 Stage:  Ready for checkin  | Has_patch:  1 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Changes (by timo):

  * needs_better_patch:  => 0
  * stage:  Unreviewed => Ready for checkin
  * needs_tests:  => 0
  * needs_docs:  => 0

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #13263: code example typo in the documentation

2010-04-03 Thread Django
#13263: code example typo in the documentation
+---
  Reporter:  RicherPots | Owner:  gabrielhurley
Status:  assigned   | Milestone:  1.2  
 Component:  Documentation  |   Version:  1.1  
Resolution: |  Keywords:   
 Stage:  Ready for checkin  | Has_patch:  1
Needs_docs:  0  |   Needs_tests:  0
Needs_better_patch:  0  |  
+---
Changes (by anonymous):

  * stage:  Accepted => Ready for checkin

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



[Django] #13270: Fixed Typo In Documentation

2010-04-03 Thread Django
#13270: Fixed Typo In Documentation
+---
 Reporter:  cmbeelby|   Owner:  nobody
   Status:  new |   Milestone:
Component:  Documentation   | Version:  SVN   
 Keywords:  typo, contributing  |   Stage:  Unreviewed
Has_patch:  1   |  
+---
 In the document located at docs/internals/contributing.txt there was a
 typo. The word settings in one instance had three t's. See attached patch.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



[Django] #13269: Possible docs error - Overriding the default field types or widgets

2010-04-03 Thread Django
#13269: Possible docs error - Overriding the default field types or widgets
---+
 Reporter:  mattrowbum |   Owner:  nobody
   Status:  new|   Milestone:
Component:  Documentation  | Version:  1.2-beta  
 Keywords:  widgets, form field types  |   Stage:  Unreviewed
Has_patch:  0  |  
---+
 Hi.

 I'm new to django and am using the development version from SVN v1.2.0
 beta.1 (rev 12909)

 I am unsure of whether there is a problem in the code, docs or my own app.
 I'm providing this as a solution to a problem I faced, based on
 information found in the docs.

 The first example given in the following section of the docs would not
 work for me...
 http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#overriding-
 the-default-field-types-or-widgets

 {{{
 class AuthorForm(ModelForm):
 class Meta:
 model = Author
 fields = ['name', 'title', 'birth_date']
 widgets = {
 'name': Textarea(attrs={'cols': 80, 'rows': 20}),
 }
 }}}

 From reading through the docs, I presume that the only import required is:

 {{{
 from django.forms import ModelForm
 }}}

 When I attempted to run the development server, I receive the following
 error message:
 {{{
 NameError: name 'Textarea' is not defined
 }}}

 My solution was the following:

 {{{
 from django import forms

 class AuthorForm(forms.ModelForm):
 class Meta:
 model = Author
 fields = ['name', 'title', 'birth_date']
 widgets = {
 'name': forms.Textarea(attrs={'cols': 80, 'rows': 20}),
 }
 }}}

 In summary, I made the following changes:

 {{{
 Line 1 - from django import forms
 Line 3 - class AuthorForm(forms.ModelForm):
 Line 8 - 'name': forms.Textarea(...),
 }}}

 I hope this is of some help.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



[Changeset] r12911 - in django/branches/releases/1.1.X: django/db/models/sql tests/modeltests/update

2010-04-03 Thread noreply
Author: russellm
Date: 2010-04-03 06:47:46 -0500 (Sat, 03 Apr 2010)
New Revision: 12911

Added:
   django/branches/releases/1.1.X/tests/modeltests/update/tests.py
Modified:
   django/branches/releases/1.1.X/django/db/models/sql/subqueries.py
   django/branches/releases/1.1.X/tests/modeltests/update/models.py
Log:
[1.1.X] Fixed #12247 -- Corrected the way update queries are processed when the 
update only refers to attributes on a base class. Thanks to jsmullyan for the 
report, and matiasb for the fix.

Backport of r12910 from trunk.

Modified: django/branches/releases/1.1.X/django/db/models/sql/subqueries.py
===
--- django/branches/releases/1.1.X/django/db/models/sql/subqueries.py   
2010-04-03 11:45:31 UTC (rev 12910)
+++ django/branches/releases/1.1.X/django/db/models/sql/subqueries.py   
2010-04-03 11:47:46 UTC (rev 12911)
@@ -284,7 +284,7 @@
 for model, values in self.related_updates.iteritems():
 query = UpdateQuery(model, self.connection)
 query.values = values
-if self.related_ids:
+if self.related_ids is not None:
 query.add_filter(('pk__in', self.related_ids))
 result.append(query)
 return result

Modified: django/branches/releases/1.1.X/tests/modeltests/update/models.py
===
--- django/branches/releases/1.1.X/tests/modeltests/update/models.py
2010-04-03 11:45:31 UTC (rev 12910)
+++ django/branches/releases/1.1.X/tests/modeltests/update/models.py
2010-04-03 11:47:46 UTC (rev 12911)
@@ -21,6 +21,19 @@
 return unicode(self.name)
 
 
+class A(models.Model):
+x = models.IntegerField(default=10)
+
+class B(models.Model):
+a = models.ForeignKey(A)
+y = models.IntegerField(default=10)
+
+class C(models.Model):
+y = models.IntegerField(default=10)
+
+class D(C):
+a = models.ForeignKey(A)
+
 __test__ = {'API_TESTS': """
 >>> DataPoint(name="d0", value="apple").save()
 >>> DataPoint(name="d2", value="banana").save()

Added: django/branches/releases/1.1.X/tests/modeltests/update/tests.py
===
--- django/branches/releases/1.1.X/tests/modeltests/update/tests.py 
(rev 0)
+++ django/branches/releases/1.1.X/tests/modeltests/update/tests.py 
2010-04-03 11:47:46 UTC (rev 12911)
@@ -0,0 +1,49 @@
+from django.test import TestCase
+
+from models import A, B, D
+
+class SimpleTest(TestCase):
+def setUp(self):
+self.a1 = A.objects.create()
+self.a2 = A.objects.create()
+for x in range(20):
+B.objects.create(a=self.a1)
+D.objects.create(a=self.a1)
+
+def test_nonempty_update(self):
+"""
+Test that update changes the right number of rows for a nonempty 
queryset
+"""
+num_updated = self.a1.b_set.update(y=100)
+self.failUnlessEqual(num_updated, 20)
+cnt = B.objects.filter(y=100).count()
+self.failUnlessEqual(cnt, 20)
+
+def test_empty_update(self):
+"""
+Test that update changes the right number of rows for an empty queryset
+"""
+num_updated = self.a2.b_set.update(y=100)
+self.failUnlessEqual(num_updated, 0)
+cnt = B.objects.filter(y=100).count()
+self.failUnlessEqual(cnt, 0)
+
+def test_nonempty_update_with_inheritance(self):
+"""
+Test that update changes the right number of rows for an empty queryset
+when the update affects only a base table
+"""
+num_updated = self.a1.d_set.update(y=100)
+self.failUnlessEqual(num_updated, 20)
+cnt = D.objects.filter(y=100).count()
+self.failUnlessEqual(cnt, 20)
+
+def test_empty_update_with_inheritance(self):
+"""
+Test that update changes the right number of rows for an empty queryset
+when the update affects only a base table
+"""
+num_updated = self.a2.d_set.update(y=100)
+self.failUnlessEqual(num_updated, 0)
+cnt = D.objects.filter(y=100).count()
+self.failUnlessEqual(cnt, 0)

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



[Changeset] r12910 - in django/trunk: django/db/models/sql tests/modeltests/update

2010-04-03 Thread noreply
Author: russellm
Date: 2010-04-03 06:45:31 -0500 (Sat, 03 Apr 2010)
New Revision: 12910

Added:
   django/trunk/tests/modeltests/update/tests.py
Modified:
   django/trunk/django/db/models/sql/subqueries.py
   django/trunk/tests/modeltests/update/models.py
Log:
Fixed #12247 -- Corrected the way update queries are processed when the update 
only refers to attributes on a base class. Thanks to jsmullyan for the report, 
and matiasb for the fix.

Modified: django/trunk/django/db/models/sql/subqueries.py
===
--- django/trunk/django/db/models/sql/subqueries.py 2010-04-02 15:52:58 UTC 
(rev 12909)
+++ django/trunk/django/db/models/sql/subqueries.py 2010-04-03 11:45:31 UTC 
(rev 12910)
@@ -131,7 +131,7 @@
 for model, values in self.related_updates.iteritems():
 query = UpdateQuery(model)
 query.values = values
-if self.related_ids:
+if self.related_ids is not None:
 query.add_filter(('pk__in', self.related_ids))
 result.append(query)
 return result

Modified: django/trunk/tests/modeltests/update/models.py
===
--- django/trunk/tests/modeltests/update/models.py  2010-04-02 15:52:58 UTC 
(rev 12909)
+++ django/trunk/tests/modeltests/update/models.py  2010-04-03 11:45:31 UTC 
(rev 12910)
@@ -21,6 +21,19 @@
 return unicode(self.name)
 
 
+class A(models.Model):
+x = models.IntegerField(default=10)
+
+class B(models.Model):
+a = models.ForeignKey(A)
+y = models.IntegerField(default=10)
+
+class C(models.Model):
+y = models.IntegerField(default=10)
+
+class D(C):
+a = models.ForeignKey(A)
+
 __test__ = {'API_TESTS': """
 >>> DataPoint(name="d0", value="apple").save()
 >>> DataPoint(name="d2", value="banana").save()

Added: django/trunk/tests/modeltests/update/tests.py
===
--- django/trunk/tests/modeltests/update/tests.py   
(rev 0)
+++ django/trunk/tests/modeltests/update/tests.py   2010-04-03 11:45:31 UTC 
(rev 12910)
@@ -0,0 +1,49 @@
+from django.test import TestCase
+
+from models import A, B, D
+
+class SimpleTest(TestCase):
+def setUp(self):
+self.a1 = A.objects.create()
+self.a2 = A.objects.create()
+for x in range(20):
+B.objects.create(a=self.a1)
+D.objects.create(a=self.a1)
+
+def test_nonempty_update(self):
+"""
+Test that update changes the right number of rows for a nonempty 
queryset
+"""
+num_updated = self.a1.b_set.update(y=100)
+self.failUnlessEqual(num_updated, 20)
+cnt = B.objects.filter(y=100).count()
+self.failUnlessEqual(cnt, 20)
+
+def test_empty_update(self):
+"""
+Test that update changes the right number of rows for an empty queryset
+"""
+num_updated = self.a2.b_set.update(y=100)
+self.failUnlessEqual(num_updated, 0)
+cnt = B.objects.filter(y=100).count()
+self.failUnlessEqual(cnt, 0)
+
+def test_nonempty_update_with_inheritance(self):
+"""
+Test that update changes the right number of rows for an empty queryset
+when the update affects only a base table
+"""
+num_updated = self.a1.d_set.update(y=100)
+self.failUnlessEqual(num_updated, 20)
+cnt = D.objects.filter(y=100).count()
+self.failUnlessEqual(cnt, 20)
+
+def test_empty_update_with_inheritance(self):
+"""
+Test that update changes the right number of rows for an empty queryset
+when the update affects only a base table
+"""
+num_updated = self.a2.d_set.update(y=100)
+self.failUnlessEqual(num_updated, 0)
+cnt = D.objects.filter(y=100).count()
+self.failUnlessEqual(cnt, 0)

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #12247: update on empty queryset in which the update kwargs refer to inherited columns update all rows of base table

2010-04-03 Thread Django
#12247: update on empty queryset in which the update kwargs refer to inherited
columns update all rows of base table
---+
  Reporter:  jsmullyan | Owner:  matiasb
Status:  assigned  | Milestone:  1.2
 Component:  Database layer (models, ORM)  |   Version:  1.1
Resolution:|  Keywords: 
 Stage:  Accepted  | Has_patch:  1  
Needs_docs:  0 |   Needs_tests:  0  
Needs_better_patch:  0 |  
---+
Comment (by russellm):

 @jkocherhans - add_filter(pk__in=[]) *is* a no-op (or rather, it raises
 EmptyResultSet). The issue here is that the "if self.related_ids"
 condition means that you *aren't* adding the [] filter, which means that
 you are left with a default "update everything" filter. Changing the
 condition to "if self.related_ids is None" means that the [] filter will
 be added, and thereby shortcut the update into a no-op.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.