fix(storefront): get_products_by_category IN子句sqlor占位符被f-string吞掉花括号
f-string里${key}$被求值成$cid_0$(缺花括号),占位符原样进SQL报
Unknown column '$cid_0$'。${{org_id}}$/${{status}}$同理。
改为字符串拼接+双花括号转义,确保输出${cid_0}$格式。
This commit is contained in:
parent
d2162db306
commit
9e411bc9cd
@ -89,11 +89,12 @@ class ProductManager:
|
||||
return {'success': True, 'products': [], 'total': 0}
|
||||
|
||||
# Use IN clause with proper parameterization
|
||||
# sqlor 占位符格式为 ${name}$;f-string 里花括号需转义,否则 ${key} 会被求值
|
||||
param_keys = []
|
||||
params = {'org_id': org_id}
|
||||
for i, cid in enumerate(all_ids):
|
||||
key = f'cid_{i}'
|
||||
param_keys.append(f'${key}$')
|
||||
param_keys.append('${' + key + '}$')
|
||||
params[key] = cid
|
||||
|
||||
placeholders = ','.join(param_keys)
|
||||
@ -101,8 +102,8 @@ class ProductManager:
|
||||
FROM product p
|
||||
LEFT JOIN product_category pc ON p.category_id = pc.id AND p.org_id = pc.org_id
|
||||
WHERE p.category_id IN ({placeholders})
|
||||
AND p.org_id = ${org_id}$
|
||||
AND p.status = ${status}$
|
||||
AND p.org_id = ${{org_id}}$
|
||||
AND p.status = ${{status}}$
|
||||
ORDER BY p.sort_order ASC, p.created_at DESC"""
|
||||
params['status'] = status
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user