Re: MySQL test failure

2009-04-03 Thread Malcolm Tredinnick

On Sat, 2009-04-04 at 01:21 -0400, Daniel Tang wrote:
[...]
> Not sure if this is an end-all solution, but you can pass a
> client_flag kwarg that makes MySQLdb return the number of matched rows
> instead of affected rows. In MySQLdb.constants.CLIENT there is a
> FOUND_ROWS constant. Passing it to connect resolves this problem.
> Patch attached just to show what I did.

Hmm ... didn't know about that one. Interesting and might well be worth
it.

The usual argument against that kind of thing is that we try to proxy
the cursor returned from MySQLdb.connect() fairly transparently, so that
people can use django.db.connection.cursor() as a fairly normal PEP 249
cursor. Your idea changes that behaviour, as now the database returns
something different from what it "normally" would.

However, it's a fairly minor change and given the relative ugliness of
the alternatives (in fact, it introduces a very small race condition),
it's worth thinking about.

Thanks for pointing it out.

Regards,
Malcolm



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



Re: MySQL test failure

2009-04-03 Thread Malcolm Tredinnick

On Fri, 2009-04-03 at 21:56 -0500, Jacob Kaplan-Moss wrote:
[...]
> 
> File 
> "/var/buildbot/slave/parts/ubuntu-8.04-python2.4-mysql5.0/django-trunk_ubuntu-8.04-python2.4-mysql5.0/build/tests/regressiontests/model_inheritance_regress/models.py",
> line ?, in regressiontests.model_inheritance_regress.models.__test__.API_TESTS
> Failed example:
> ArticleWithAuthor.objects.filter(pk=article.pk).update(headline="Oh, no!")
> Expected:
> 1
> Got:
> 0
> """
> 
> Can someone with more MySQL-fu take a look and help me figure out
> what's going on?

Known problem. Russ brought it up a while back in a discussion about
what update() shoudl return and we haven't resolved it yet.

The issue is that MySQL only returns the number of rows *changed* when
executing an update command and that particular result will affect one
row, but changes no data in it. So it returns 0, not 1.

It's ticket #10438.

Regards,
Malcolm


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