Changeset 3846

Show
Ignore:
Timestamp:
12/24/07 10:00:49 (7 months ago)
Author:
roger
Message:

Fix #1641.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/CHANGELOG.txt

    r3825 r3846  
    4343* Paginate does a better handling of zeroed limit, avoiding ZeroDivisionError 
    4444  exception (#1629). 
    45  
    46 Contributors 
    47 ~~~~~~~~~~~~ 
    48  
    49 Toshio Kuratomi. 
     45* Fixed pagination of empty data when a SQL with "group by" is issued (#1641). 
     46 
     47Contributors 
     48~~~~~~~~~~~~ 
     49 
     50Toshio Kuratomi, ondrejj. 
    5051 
    5152 
  • branches/1.1/turbogears/paginate.py

    r3825 r3846  
    161161                else: 
    162162                    df = default_order 
    163                          
     163 
    164164                ordering = dict([(v.lstrip('-'), [k, not v.startswith('-')]) 
    165165                                 for k,v in enumerate(df)]) 
     
    172172               (SASelectResults and isinstance(var_data, SASelectResults)) or \ 
    173173               (Query and isinstance(var_data, Query)): 
    174                 row_count = var_data.count() 
     174                row_count = var_data.count() or 0 
    175175                if ordering: 
    176176                    # Build order_by list. 
  • branches/1.1/turbogears/tests/test_paginate.py

    r3825 r3846  
    619619        zero_limit = expose("turbogears.tests.paginate")(zero_limit) 
    620620 
     621        def empty_with_groupby(self): 
     622            data = session.query(Address).filter(Address.c.id<0).group_by(Address.c.user_id) 
     623 
     624            spy = Spy(var_name='data', pages=[], limit=10, page_count=0, 
     625                      order=None, row_count=0) 
     626            return dict(data=data, spy=spy) 
     627 
     628        empty_with_groupby = paginate("data", default_order="id")(empty_with_groupby) 
     629        empty_with_groupby = expose("turbogears.tests.paginate")(empty_with_groupby) 
     630 
    621631    # end of MyRoot ------------------------------------------------------------ 
    622632 
     
    895905            self.request("/zero_limit/?method=%s" % method) 
    896906            self.assert_order(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 
     907 
     908    def test_ticket_1641(self): 
     909        self.request("/empty_with_groupby") 
     910        self.assert_order() 
    897911 
    898912