debug: product_category_create.dspy 加追踪日志定位 WHERE None 错误

添加4处 debug:
- START: 记录完整 params_kw
- fields组装后: 记录 keys + id
- sor.C 前后: 定位崩溃在 INSERT 还是后续 SELECT
- EXCEPTION: 记录完整堆栈
This commit is contained in:
yumoqing 2026-06-29 16:05:18 +08:00
parent 5d77e6e20a
commit d33072ab21
2 changed files with 6 additions and 0 deletions

Binary file not shown.

View File

@ -1,6 +1,7 @@
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
try:
debug(f'product_category_create.dspy: START params_kw={dict(params_kw)}')
user_id = await get_user()
org_id = (await get_userorgid()) or '0'
@ -43,14 +44,19 @@ try:
else:
fields[k] = ''
debug(f'product_category_create.dspy: fields keys={list(fields.keys())}, id={data.get("id")}')
async with DBPools().sqlorContext(dbname) as sor:
debug(f'product_category_create.dspy: BEFORE sor.C, fields={ {k:v for k,v in fields.items() if v} }')
await sor.C('product_category', fields)
debug(f'product_category_create.dspy: AFTER sor.C OK, querying id={data["id"]}')
_new_rows = await sor.sqlExe("SELECT * FROM product_category WHERE id = ${id}$", {'id': data['id']})
_user_data = _new_rows[0] if _new_rows else data
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '类别创建成功', 'type': 'success', 'user_data': _user_data}}
except Exception as e:
debug(f'product_category_create.dspy: EXCEPTION {format_exc()}')
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
return result