[FIX] website_sale: fix order for the pager in front end.
In psql, use LIMIT and OFFSET together without a fully specified and uniq sort order
will generate unexpected behaviour.
Eg:
> id id_dept name
> -------------------
> 1 1 Tom
> 2 1 Mike
> 3 2 Meggie
> 4 2 Marge
> 5 3 Bart
> 6 3 Lisa
> using LIMITed selects like:
> SELECT * FROM employee ORDER BY id_dept LIMIT 3
> SELECT * FROM employee ORDER BY id_dept LIMIT 3 OFFSET 3
> SELECT * FROM employee ORDER BY id_dept LIMIT 3 OFFSET 6
> You can have some result missings from the 3 requests, and others duplicated.
> Because id_dept is not a uniq order.
opw-686639
note: backport of saas-12 4dce8616
This commit is contained in:
committed by
Nicolas Lempereur
parent
671fa0c7d4
commit
f1a331850d
@@ -145,7 +145,8 @@ class website_sale(http.Controller):
|
||||
|
||||
def _get_search_order(self, post):
|
||||
# OrderBy will be parsed in orm and so no direct sql injection
|
||||
return 'website_published desc,%s' % post.get('order', 'website_sequence desc')
|
||||
# id is added to be sure that order is a unique sort key
|
||||
return 'website_published desc,%s , id desc' % post.get('order', 'website_sequence desc')
|
||||
|
||||
def _get_search_domain(self, search, category, attrib_values):
|
||||
domain = request.website.sale_product_domain()
|
||||
|
||||
Reference in New Issue
Block a user