rohitjain-rj / django-tagging

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

get_intersection_by_model ignores tags that do not exist in the db. #192

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Calling get_intersection_by_model(MyObject,"Tag1, Tag2") only returns the
intersection among the tags it recognizes. 

For example, say Tag1 is has a Tag instance in the db, but Tag2 does not. I
would expect get_intersection_by_model(MyObject,"Tag1, Tag2") to return no
object, because there cannot be a MyObject with both Tag1 and Tag2 (if
there was, there would be a Tag2 object!) 

However, the current behavior is that get_intersection_by_model ignores
Tag2 completely, and just returns all MyObject instances that are tagged
with Tag1. 

The culprit seems to be in tagging.utils.get_tag_list, line 167: 

elif isinstance(tags, types.StringTypes):
        return Tag.objects.filter(name__in=parse_tag_input(tags))

Obviously this will only return existing tags... which is generally a good
thing, but not the functionality I would expect in this situation. 

Original issue reported on code.google.com by Carme...@gmail.com on 30 Mar 2009 at 10:52

GoogleCodeExporter commented 9 years ago
I was caught by this, and wondered what I was doing wrong.  And I think there's 
a
related issue.  The method (see here)
        if not tag_count:
            return model._default_manager.none()
returns an empty query set if the tags argument is empty.  I think of each tag 
as a
filter, and if there are no filters I expect to get the original query set back.

Consider factorial.  3! = 1*2*3 = 6.  So what is 0!.  It is 1.

Original comment by Jonathan.Fine1@googlemail.com on 25 May 2009 at 4:11

GoogleCodeExporter commented 9 years ago
I just thought of something else.  Suppose I call get_intersection_by_model and 
get
some objects.  Now I add something to the database, and call
get_intersection_by_model.  I'd expect to get all the items I previously had, 
and
possibly another.

This property can be called monotonicity.

Original comment by Jonathan.Fine1@googlemail.com on 25 May 2009 at 4:15