Re: Weird get_or_create error

2007-05-09 Thread Andy Dustman
On 5/8/07, Brandon Low <[EMAIL PROTECTED]> wrote: > > Still not sure what's going on myself -- I've had one more occurence of > the error, and have now confirmed that autocommit is on in the > production application (by printing the result of select @@autocommit). > > It sounds quite possible that

Re: Weird get_or_create error

2007-05-08 Thread Brandon Low
Still not sure what's going on myself -- I've had one more occurence of the error, and have now confirmed that autocommit is on in the production application (by printing the result of select @@autocommit). It sounds quite possible that it's the immediate foreign key constraint check that's causi

Re: Weird get_or_create error

2007-05-08 Thread Andy Dustman
Not sure what is happening there. Django is not setting autocommit, and MySQLdb disables autocommit by default. Have you actually verified that autocommit is on when running your application? It may also be due to the fact that MySQL (5.0 and earlier at least) does not defer foreign key checks in

Re: Weird get_or_create error

2007-05-01 Thread Brandon Low
Ugh, why would autocommit be set to 1 in the site but 0 in the shell??? --Brandon On 2007-05-01 (Tue) at 18:13:55 -0500, Brandon Low wrote: > > So initially, when you said that, I thought to myself, "Of course, how > could I be so dumb" but then I did: > > >>> from django.db import connection;

Re: Weird get_or_create error

2007-05-01 Thread Brandon Low
So initially, when you said that, I thought to myself, "Of course, how could I be so dumb" but then I did: >>> from django.db import connection; >>> cursor = connection.cursor() >>> cursor.execute("select @@autocommit;") 1L >>> row=cursor.fetchone() >>> row (0L,) at the shell and it looks like a

Re: Weird get_or_create error

2007-05-01 Thread Andy Dustman
On 5/1/07, Brandon Low <[EMAIL PROTECTED]> wrote: > > my model is very simple: > > class Referrer(models.Model): > url = models.CharField(maxlength=255, unique=True) > > here is the relevent view code: > > referrer = request.META.get('HTTP_REFERER','-') > r, r_new = Referrer.objects.ge

Re: Weird get_or_create error

2007-05-01 Thread Brandon Low
my model is very simple: class Referrer(models.Model): url = models.CharField(maxlength=255, unique=True) here is the relevent view code: referrer = request.META.get('HTTP_REFERER','-') r, r_new = Referrer.objects.get_or_create(url=referrer) thanks for your replies! --Brandon On

Re: Weird get_or_create error

2007-05-01 Thread Andy Dustman
On 5/1/07, Brandon Low <[EMAIL PROTECTED]> wrote: > > How can a get_or_create cause an integrity constraint error? Also... It's hard to see exactly what's going on because the code in the traceback is using **kwargs. If you use get() or get_or_create(), it's looking for a match on all the paramet

Re: Weird get_or_create error

2007-05-01 Thread Andy Dustman
On 5/1/07, Brandon Low <[EMAIL PROTECTED]> wrote: > > How can a get_or_create cause an integrity constraint error? The error is on key 2, which is an additional unique index you presumably have in your model. get_or_create should not cause integrity errors on the primary key, but that's not what'