try to fix sql query

This commit is contained in:
shoopea 2020-04-18 21:00:37 +08:00
parent 5640dbe81d
commit 78d6567e0a

2
obj.go
View File

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