On Tuesday, December 13, 2016 at 11:57:48 AM UTC-5, Anthony wrote: > > On Tuesday, December 13, 2016 at 3:11:42 AM UTC-5, Scott Hunter wrote: >> >> The first 20 records appear in the same order in each case (using >> DBBrowser). How does that help? >> > > The first and third SQL queries (that I listed, not from your original > list) presumably are those from your print statements, and the second > should be from the grid after you have clicked the f_Dog_ID column to sort > on it. You claim in web2py your second print query and the grid query are > the same as each other but different from the first print query, but in > DBBrowser all three are the same. Is that correct? >
Correct. > > Note, in general, we should not expect your two print queries to yield the > same order as each other or the grid query. The reason is that in the print > queries, your "order by" clause does not specify a unique ordering of the > records (since many records have the same value of f_Dog_ID). Only the grid > query guarantees a consistent ordering of records, as it breaks any ties on > f_Dog_ID by also including the "id" column in the "order by" clause. > > In web2py, if you add the "id" field to the orderby (i.e., > orderby=db.t_dog.f_Dog_ID|db.t_dog.id) in your print statements, do you > then get the same order as the grid? If not, perhaps you can post a minimal > app that reproduces the problem. > I'm a bit confused: I get the same result when I use limitby whether or not I include id in the sort key, which is the same as what appears in the grid. What is different (and correct) is when I do NOT use limitby. While including id may make a difference in general, it should (and did) not in this case: the reason for the long belongs list is that queries are made to insure that no 2 records with the same Dog_ID appear in that list. So in this case, since, by design, every record to appear DOES have a unique value for the sort (orderby) key, so there are no ties to be broken, and there is a unique correct ordering to the records being displayed. > >> >> I *am* using the args (in code that appears before this), and do not use >> any links generated by grid. >> > > OK, but careful, if you ever do use any of the links in the grid, your > current code won't work. > > 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

