From 9645d397b6787695d5f17cbb3d2fcf0d19248a11 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 4 Jul 2026 19:56:56 +0800 Subject: [PATCH] fix: remove ns['sort'] to avoid sqlPaging outer ORDER BY conflict --- wwwroot/discount_setting/get_products_with_discount.dspy | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/wwwroot/discount_setting/get_products_with_discount.dspy b/wwwroot/discount_setting/get_products_with_discount.dspy index d08206f..e3f72e3 100644 --- a/wwwroot/discount_setting/get_products_with_discount.dspy +++ b/wwwroot/discount_setting/get_products_with_discount.dspy @@ -13,8 +13,6 @@ if not user_orgid: ns = params_kw.copy() if not ns.get('page'): ns['page'] = 1 -if not ns.get('sort'): - ns['sort'] = 'pc_name, product_name' ns['org_id'] = user_orgid @@ -30,9 +28,8 @@ async with db.sqlorContext(dbname) as sor: sql = ''' SELECT p.id as productid, - pc.name as pc_name, - p.product_name, p.product_code, + p.product_name, p.category_id, pc.name as category_name, dd.id as detail_id, @@ -46,10 +43,11 @@ LEFT JOIN discount_detail dd ON dd.productid = p.id LEFT JOIN discount_detail base_dd ON base_dd.productid = p.id AND base_dd.discountid = ${base_discountid}$ WHERE p.org_id = ${org_id}$ AND p.status = '1' +ORDER BY pc.name, p.product_name ''' debug(f'get_products_with_discount: org_id={user_orgid}, discountid={discountid}, dbname={dbname}, base_discountid={ns["base_discountid"]}') async with db.sqlorContext(dbname) as sor: r = await sor.sqlPaging(sql, ns.copy()) - debug(f'{sql=}, {ns=},get_products_with_discount: returned {len(r.get("rows", []))} products') + debug(f'{ns=},get_products_with_discount: returned {len(r.get("rows", []))} products') return r