jinjie2088 / django-tagging

Automatically exported from code.google.com/p/django-tagging
Other
0 stars 0 forks source link

related_for_model fails if the tag does not exist #107

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When I switched from sqlite to mysql, I started getting a database error when I 
tried to look at a 
page for a non-existent tag. Because the tag did not exist, the code built a 
query with an empty 
IN() condition. It seems that sqlite is more lenient about that than MySQL.

I attached a patch to add a line to related_for_model to return an empty list 
if tag_count is 0. If 
there are no tags, there's no point in running the SQL query at all.

Original issue reported on code.google.com by jdwadswo...@gmail.com on 20 Mar 2008 at 3:08

Attachments:

GoogleCodeExporter commented 9 years ago
+1 

I've hit this too. The attached patch fixes it for me.

For other looking for this issue, the error you get (or at least the one that I 
get
for the same issue) looks like this:

    (1064, "You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near ')\n GROUP BY
`tagging_taggeditem`.object_id\n HAVING COU' at line 10")

Original comment by tre...@gmail.com on 24 Jul 2008 at 12:30