bug with addname

This commit is contained in:
shoopea 2020-04-18 16:11:16 +08:00
parent 3a7d947480
commit 9f61d483ae

2
obj.go
View File

@ -266,7 +266,7 @@ func setObjSubTypeId(objId int64, objSubTypeID64 int64) error {
func objAddName(objID64 int64, name string) error {
stmt, err := db.Prepare(`INSERT INTO obj_name (obj_id, name, priority)
SELECT ? obj_id, ? name, (SELECT MAX(priority) + 1 FROM obj_name WHERE obj_id = ?) priority FROM DUAL;`)
SELECT ? obj_id, ? name, COALESCE(SELECT MAX(priority) + 1 FROM obj_name WHERE obj_id = ?), 0) priority FROM DUAL;`)
_, err = stmt.Exec(objID64, name, objID64)