Ok,

found the answer. By adding 'id' as an orderby field, the order of the rows 
if never changed, even if the original orderby field is not unique :
 
rows = db().select(
            mytable.ALL,
            orderby=mytablename+'.'+myfield+' '+myorder+','+mytablename+
'.id',
            limitby=(page*ITEMSPERPAGE-ITEMSPERPAGE,page*ITEMSPERPAGE)
            )

On Sunday, October 21, 2012 6:19:16 PM UTC+1, apinho wrote:
>
> Hi, 
>
> I'm using this query :
> rows = db().select(
>             mytable.ALL,
>             orderby=mytablename+'.'+myfield+' '+myorder,
>             limitby=(page*ITEMSPERPAGE-ITEMSPERPAGE,page*ITEMSPERPAGE)
>             )
> 'myorder' is either 'asc' or 'desc. 'mytable', 'myorderby' and 'myorder' 
> ar all string, that I get through request.vars...
>
> The DB is Postgresql.
>
> This works well when 'myfield' is unique within the DB. But when 'myfield' 
> has repeated values, running this same query, with the same parameters 
> doesn't always return the same set of rows.
>
> So the question is : When the orderby field is not enough to fully order 
> tables, cause the field has repeated values, what order does Web2py apply ?
> Or, maybe, it's Postgre related, and not web2py ?
>
> thx
>
>
>
>  
>

-- 



Reply via email to