1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Server: Fixed issue with sync not immediately returning all items in certain cases

This commit is contained in:
Laurent Cozic 2023-11-19 09:24:20 +00:00
parent 14a2d2d795
commit 87aeffa160
2 changed files with 10 additions and 4 deletions

View File

@ -178,6 +178,14 @@ describe('ChangeModel', () => {
expect(changeCount).toBe(SqliteMaxVariableNum);
});
test('should tell if there are more changes', async () => {
const { user } = await createUserAndSession(1, true);
await models().item().makeTestItems(user.id, 500);
const result = await models().change().delta(user.id, { limit: 100 });
expect(result.has_more).toBe(true);
});
test('should delete old changes', async () => {
// Create the following events:
//

View File

@ -139,8 +139,6 @@ export default class ChangeModel extends BaseModel<Change> {
// as the `changes` table grew. So it is now split into two queries
// merged by a UNION ALL.
const subQueryLimit = Math.ceil(limit / 2);
const fields = [
'id',
'item_id',
@ -169,7 +167,7 @@ export default class ChangeModel extends BaseModel<Change> {
userId,
];
if (!doCountQuery) subParams1.push(subQueryLimit);
if (!doCountQuery) subParams1.push(limit);
const subQuery2 = `
SELECT ${fieldsSql}
@ -187,7 +185,7 @@ export default class ChangeModel extends BaseModel<Change> {
userId,
];
if (!doCountQuery) subParams2.push(subQueryLimit);
if (!doCountQuery) subParams2.push(limit);
let query: Knex.Raw<any> = null;