Django

Code

Changeset 1834

Show
Ignore:
Timestamp:
01/06/06 14:43:14 (3 years ago)
Author:
adrian
Message:

Fixed #1181 -- get_in_bulk no longer fails on empty input. Also added unit tests. Thanks, akaihola

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/AUTHORS

    r1581 r1834  
    3232answer newbie questions, and generally made Django that much better: 
    3333 
     34    akaihola 
    3435    Andreas 
    3536    David Ascher <http://ascher.ca/> 
  • django/trunk/django/core/meta/__init__.py

    r1717 r1834  
    16501650 
    16511651def function_get_in_bulk(opts, klass, *args, **kwargs): 
    1652     id_list = args and args[0] or kwargs['id_list'] 
     1652    id_list = args and args[0] or kwargs.get('id_list', []) 
    16531653    assert id_list != [], "get_in_bulk() cannot be passed an empty list." 
    16541654    kwargs['where'] = ["%s.%s IN (%s)" % (db.db.quote_name(opts.db_table), db.db.quote_name(opts.pk.column), ",".join(['%s'] * len(id_list)))] 
  • django/trunk/tests/testapp/models/lookup.py

    r1324 r1834  
    6666>>> articles.get_in_bulk([1000]) 
    6767{} 
     68>>> articles.get_in_bulk([]) 
     69Traceback (most recent call last): 
     70    ... 
     71AssertionError: get_in_bulk() cannot be passed an empty list. 
    6872 
    6973# get_values() is just like get_list(), except it returns a list of