Django

Code

Changeset 2663

Show
Ignore:
Timestamp:
04/10/06 22:15:22 (2 years ago)
Author:
adrian
Message:

magic-removal: Fixed #1565 -- in_bulk() now returns empty dictionary if passed an empty list of IDs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/magic-removal/django/db/models/query.py

    r2613 r2663  
    214214        assert isinstance(id_list, (tuple,  list)), "in_bulk() must be provided with a list of IDs." 
    215215        id_list = list(id_list) 
    216         assert id_list != [], "in_bulk() cannot be passed an empty ID list." 
     216        if id_list == []: 
     217            return {} 
    217218        qs = self._clone() 
    218219        qs._where.append("%s.%s IN (%s)" % (backend.quote_name(self.model._meta.db_table), backend.quote_name(self.model._meta.pk.column), ",".join(['%s'] * len(id_list)))) 
  • django/branches/magic-removal/tests/modeltests/lookup/models.py

    r2430 r2663  
    6868{} 
    6969>>> Article.objects.in_bulk([]) 
    70 Traceback (most recent call last): 
    71     ... 
    72 AssertionError: in_bulk() cannot be passed an empty ID list. 
     70{} 
    7371>>> Article.objects.in_bulk('foo') 
    7472Traceback (most recent call last):