-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathds-5.4.2-cutis-support.patch
32 lines (32 loc) · 1.67 KB
/
ds-5.4.2-cutis-support.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
--- /var/www/onlyoffice/documentserver/server/DocService/sources/postgreSqlBaseConnector.js
+++ /var/www/onlyoffice/documentserver/server/DocService/sources/postgreSqlBaseConnector.js
@@ -110,9 +110,11 @@
if (isSupportOnConflict) {
//http://stackoverflow.com/questions/34762732/how-to-find-out-if-an-upsert-was-an-update-with-postgresql-9-5-upsert
return "INSERT INTO task_result (id, status, status_info, last_open_date, user_index, change_id, callback," +
- " baseurl) VALUES (" + commandArgEsc.join(', ') + ") " +
- "ON CONFLICT (id) DO UPDATE SET last_open_date = " + sqlBase.baseConnector.sqlEscape(dateNow) +
- ", user_index = task_result.user_index + 1 RETURNING user_index as userindex;";
+ " baseurl) SELECT " + commandArgEsc.join(', ') + " WHERE 'false' = set_config('myapp.isupdate', 'false', true) " +
+ "ON CONFLICT (id) DO UPDATE SET last_open_date = " +
+ sqlBase.baseConnector.sqlEscape(dateNow) +
+ ", user_index = task_result.user_index + 1 WHERE 'true' = set_config('myapp.isupdate', 'true', true) RETURNING" +
+ " current_setting('myapp.isupdate') as isupdate, user_index as userindex;";
} else {
return "SELECT * FROM merge_db(" + commandArgEsc.join(', ') + ");";
}
@@ -134,11 +136,11 @@
if (result && result.rows.length > 0) {
var first = result.rows[0];
result = {affectedRows: 0, insertId: 0};
- result.affectedRows = task.userIndex !== first.userindex ? 2 : 1;
+ result.affectedRows = 'true' == first.isupdate ? 2 : 1;
result.insertId = first.userindex;
}
resolve(result);
}
}, true);
});
-};
+};
\ No newline at end of file