Grid sorting bug when default orderby column type is date

21 views
Skip to first unread message

João Matos

unread,
Apr 7, 2019, 6:49:35 PM4/7/19
to web2py-developers
I already opened an issue in Github

I think I found the source of the problem.
After following the fix_orderby function, I arrived at this code inside the linsert function (line 2779)  in file gluon\sqlhtml.py.

                exception = sort_field.type in ('date', 'datetime', 'time')
               
if exception:
                    desc_icon
, asc_icon = sorter_icons
                   
orderby = (order[:1] == '~' and sort_field) or ~sort_field
               
else:
                   
orderby = (order[:1] == '~' and ~sort_field) or sort_field

If I change it to

                exception = sort_field.type in ('date', 'datetime', 'time')
               
# if exception:
               
#    desc_icon, asc_icon = sorter_icons
               
#    orderby = (order[:1] == '~' and sort_field) or ~sort_field
               
#else:
               
orderby = (order[:1] == '~' and ~sort_field) or sort_field

Now the date sorting works fine.

There is also another code segment in line 2641 with the same purpose that may need the same change, but that segment isn't run with my application, only the segment at line 2779.


My env:
Windows 7 Pro x64 SP1+all upd
Python 3.7.1 x86
web2py 2.18.4
Firefox 66.0.2 x64

João Matos

unread,
Apr 7, 2019, 7:56:27 PM4/7/19
to web2py-developers
Massimo has just corrected this on Github.
Reply all
Reply to author
Forward
0 new messages