Skip to content

Commit 98fe8a6

Browse files
ensure consistent pagination ordering as row order not guaranteed
1 parent 367c145 commit 98fe8a6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/routes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,9 @@ def get_subcategory_products(sc_id):
247247

248248
try:
249249
page = request.args.get("page", default=1, type=int)
250+
products = subcategory.products.order_by(Product.id.asc()).paginate(page=page, per_page=2, error_out=False)
250251
return {
251-
"products": [p.id for p in subcategory.products.paginate(page=page, per_page=2, error_out=False)]
252+
"products": [p.id for p in products]
252253
}, 200
253254
except:
254255
return "Error occured", 500
@@ -269,6 +270,7 @@ def get_category_products(c_id):
269270
.join(category_subcategory, onclause=subcategory_product.c.subcategory_id == category_subcategory.c.subcategory_id)
270271
.filter(category_subcategory.c.category_id == c_id)
271272
.distinct()
273+
.order_by(Product.id.asc())
272274
.paginate(page=page, per_page=2, error_out=False)
273275
)
274276

0 commit comments

Comments
 (0)