On Tue, Mar 24, 2009 at 2:39 PM, Michael Glassford <glassfo...@gmail.com>wrote:

>
> I haven't been able to debug why this is happening yet (I spent most of
> today narrowing down the problem to a simple test case), but if I create
> a new Django project, add a new app to it, change settings.py to have
> the appropriate db information (I'm using MySQL), and INSTALLED_APPS
> setting, then define these two files:
>
>
> myapp/models.py
> ---------------
> from django.db import models
>
> class ModelA(models.Model):
>     pass
>
>
>
> myapp/tests.py
> --------------
> from django.test import TestCase
>
> from myapp.models import ModelA
>
> class MyTestCase(TestCase):
>     def testBug(self):
>         ModelA.objects.create()
>         b = ModelA.objects.get(pk=None) #pk=None shouldn't match anything
>         self.assert_(b is None, 'Unexpectedly found ModelA with id %s'
> % (b.id))
>
>
>
> When I run the tests under Django 0.96.3, I get the expected exception:
> "DoesNotExist: ModelA matching query does not exist."
>
> However, under Django 1.0, 1.0.1, 1.0.2, and the current trunk (revision
> 10162 at the time when I tested this), the "ModelA.objects.get(pk=None)"
> statement unexpectedly returns the object created by the
> "ModelA.objects.create()" on the previous line.
>
>
> Mike
>
>
> >
>
Under MySQL doing a query of the form WHERE primary_key IS NULL returns the
last created row.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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

Reply via email to