ojengwa / django-tagging

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

TaggedItemManager methods get_union_by_model and get_intersection_by_model fail on MySQL if no matching tags #114

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
TaggedItemManager methods get_union_by_model and get_intersection_by_model
fail on MySQL if there are no matching tags. Sqlite doesn't exhibit the
behavior, but in any case the db query can be avoided using the same logic
applied in get_by_model (diff attached).

e.g. (where tag 'foo' does not exist):

>>> TaggedItem.objects.get_intersection_by_model(models.Image, 'foo')

ProgrammingError: (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          AND `main_image`.`id` =
`tagging_taggeditem`.object_id\n        GROUP' at line 4")

>>> TaggedItem.objects.get_union_by_model(models.Image, 'foo')

ProgrammingError: (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          AND `main_image`.`id` =
`tagging_taggeditem`.object_id\n        GROUP' at line 4")

Attached diff checks tag_count as in get_by_model and returns empty set.

Original issue reported on code.google.com by simi...@gmail.com on 11 Apr 2008 at 3:41

Attachments:

GoogleCodeExporter commented 9 years ago
Fixed in revision 135 - thanks!

Original comment by jonathan.buchanan on 30 Apr 2008 at 10:54