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