fix: remove parent_id default '0' from product_category model - Root nodes should have parent_id=NULL, not '0' - Tree query already checks 'parent_id IS NULL' - Revert direct edits to generated dspy files

This commit is contained in:
Hermes Agent 2026-06-22 14:03:41 +08:00
parent f13651e830
commit f05eea19e5
3 changed files with 11 additions and 16 deletions

View File

@ -21,8 +21,7 @@
"name": "parent_id",
"title": "父类别ID",
"type": "str",
"length": 32,
"default": "0"
"length": 32
},
{
"name": "name",

View File

@ -2,15 +2,15 @@
ns = params_kw.copy()
sql = '''select * from product_category where 1 = 1'''
id = ns.get('id')
if id and id != '0' and id != 'null' and id != 'undefined':
if id:
sql += " and parent_id = ${id}$"
else:
sql += " and (parent_id is null or parent_id = '' or parent_id = '0')"
sql += " and parent_id is null"
sql += " order by sort_order, name "
sql += " order by name "
db = DBPools()
dbname = get_module_dbname('product_management')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlExe(sql, ns)
return r
return []
return []

View File

@ -1,19 +1,15 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null' or v == 'undefined' or v == '':
if v == 'NaN' or v == 'null':
ns[k] = None
# Normalize parent_id: empty/0/None all mean root node (NULL)
pid = ns.get('parent_id')
if not pid or pid == '0':
ns['parent_id'] = None
id = params_kw.get('id')
if not id or len(str(id)) > 32:
id = params_kw.id
if not id or len(id) > 32:
id = uuid()
ns['id'] = id
userorgid = await get_userorgid()
if not userorgid:
return {
@ -58,4 +54,4 @@ return {
"timeout":3,
"message":"failed"
}
}
}