Changeset 3845

Show
Ignore:
Timestamp:
12/24/07 10:00:12 (1 year ago)
Author:
roger
Message:

Fix #1641.

Files:

Legend:

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

    r3830 r3845  
    2020  exception (#1629). 
    2121* Added missing logger configuration to quickstarted projects (#1630). 
     22* Fixed pagination of empty data when a SQL with "group by" is issued (#1641). 
    2223 
    2324Contributors 
    2425~~~~~~~~~~~~ 
    2526 
    26 Toshio Kuratomi, Christoph Zwerschke
     27Toshio Kuratomi, Christoph Zwerschke, ondrejj
    2728 
    2829 
  • branches/1.0/turbogears/paginate.py

    r3824 r3845  
    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.0/turbogears/tests/test_paginate.py

    r3824 r3845  
    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