On Tue, Mar 24, 2009 at 2:51 PM, Michael Glassford <glassfo...@gmail.com>wrote:
> > Alex Gaynor wrote: > > > > > > On Tue, Mar 24, 2009 at 2:39 PM, Michael Glassford <glassfo...@gmail.com > > <mailto:glassfo...@gmail.com>> wrote: > > [snip model definition, etc.] > > > 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 > > > > Not here: > > mysql> show create table myapp_modela; > > +--------------+----------------------------------------------------------------------------------------------------------------------------------+ > | Table | Create Table > | > > +--------------+----------------------------------------------------------------------------------------------------------------------------------+ > | myapp_modela | CREATE TABLE `myapp_modela` ( > `id` int(11) NOT NULL auto_increment, > PRIMARY KEY (`id`) > ) ENGINE=InnoDB DEFAULT CHARSET=utf8 | > > +--------------+----------------------------------------------------------------------------------------------------------------------------------+ > 1 row in set (0.00 sec) > > mysql> insert into myapp_modela values (1); > Query OK, 1 row affected (0.00 sec) > > mysql> select * from myapp_modela where id is NULL; > Empty set (0.00 sec) > > > > > > Also, that doesn't explain why Django 0.96 does what I expected. > > > > > Mike > > > > I'm almost positive the MySQL CLI operates differently for the purposes of this query. The reason the queries do different things in .96 is that in .96 that query becomes id = NULL rather than id IS NULL, which MySQL handles differently. -- "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 -~----------~----~----~----~------~----~------~--~---