I think I found the problem (I don't have the solution). In gluon\sqlhtml.py there is this function
def fix_orderby(orderby): if not auto_pagination: return orderby # enforce always an ORDER clause to avoid # pagination errors. field_id is needed anyhow, # is unique and usually indexed. See issue #679 if not orderby: orderby = field_id elif isinstance(orderby, list): orderby = reduce(lambda a,b: a|b, orderby) elif isinstance(orderby, Field) and orderby is not field_id: print('inside2') # here we're with an ASC order on a field stored as orderby orderby = orderby | field_id elif (isinstance(orderby, Expression) and orderby.first and orderby.first is not field_id): print('inside3') # here we're with a DESC order on a field stored as orderby.first orderby = orderby | field_id return orderby where I added the 2 prints. A field that works correct shows inside2 on the first run and inside3 on the second. The date field always shows inside2. Any ideas? Do you use Telegram? There is an online web2py international group. It would be great if you and others web2py core devs joined. domingo, 7 de Abril de 2019 às 19:22:34 UTC+1, Anthony escreveu: > > On Saturday, April 6, 2019 at 3:41:50 PM UTC-4, João Matos wrote: >> >> Thanks Anthony. I will open an issue (I still haven't enough know how to >> make a PR). I hope some time in the future. >> >> I don't want to abuse your help, but I have another issue that is >> viewable with the minimal app I sent you. >> If you create 2 records with different dates, and try to change the >> grid's sort order you will notice that the URL changes, the page reloads >> but the grid doesn't change. >> I checked the db stats SQL statements and they stay the same (they don't >> change the ORDER). >> I think there is a bug with the sorting of date columns when they are the >> predefined orderby. Can you try it and give me your input. >> > > Definitely a bug -- feel free to report on Github. May have to do with the > fact that when clicking to sort, the grid code inverts the order for > date/time fields, but does not appear to do so when a date/time field is > specified in the orderby argument. > > Anthony > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.