mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-02-10 18:05:07 +08:00
[mysql] Unify upsert result
This commit is contained in:
committed by
Georgii Petrov
parent
2b29006efc
commit
84c3f26993
@ -2495,8 +2495,8 @@ exports.install = function(server, callbackFunction) {
|
||||
}
|
||||
let format = data.openCmd && data.openCmd.format;
|
||||
upsertRes = yield canvasService.commandOpenStartPromise(ctx, docId, utils.getBaseUrlByConnection(ctx, conn), true, data.documentCallbackUrl, format);
|
||||
let isInserted = upsertRes.affectedRows == 1;
|
||||
curIndexUser = isInserted ? 1 : upsertRes.insertId;
|
||||
let isInserted = upsertRes.affectedRows === 1;
|
||||
curIndexUser = upsertRes.insertId;
|
||||
if (isInserted && undefined !== data.timezoneOffset) {
|
||||
//todo insert in commandOpenStartPromise. insert here for database compatibility
|
||||
if (false === canvasService.hasAdditionalCol) {
|
||||
|
||||
@ -148,6 +148,8 @@ function upsert(ctx, task, opt_updateUserIndex) {
|
||||
}
|
||||
if (opt_updateUserIndex) {
|
||||
sqlCommand += ', user_index = LAST_INSERT_ID(user_index + 1)';
|
||||
} else {
|
||||
sqlCommand += ', user_index = LAST_INSERT_ID(user_index)';
|
||||
}
|
||||
sqlCommand += ';';
|
||||
|
||||
@ -155,7 +157,8 @@ function upsert(ctx, task, opt_updateUserIndex) {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve({ affectedRows: result.affectedRows, insertId: result.insertId });
|
||||
const insertId = result.affectedRows === 1 ? task.userIndex : result.insertId;
|
||||
resolve({ affectedRows: result.affectedRows, insertId });
|
||||
}
|
||||
}, true, false, values);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user