mirror of https://github.com/laurent22/joplin.git
Server: Fixed issue with sync not immediately returning all items in certain cases
parent
14a2d2d795
commit
87aeffa160
|
@ -178,6 +178,14 @@ describe('ChangeModel', () => {
|
||||||
expect(changeCount).toBe(SqliteMaxVariableNum);
|
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 () => {
|
test('should delete old changes', async () => {
|
||||||
// Create the following events:
|
// Create the following events:
|
||||||
//
|
//
|
||||||
|
|
|
@ -139,8 +139,6 @@ export default class ChangeModel extends BaseModel<Change> {
|
||||||
// as the `changes` table grew. So it is now split into two queries
|
// as the `changes` table grew. So it is now split into two queries
|
||||||
// merged by a UNION ALL.
|
// merged by a UNION ALL.
|
||||||
|
|
||||||
const subQueryLimit = Math.ceil(limit / 2);
|
|
||||||
|
|
||||||
const fields = [
|
const fields = [
|
||||||
'id',
|
'id',
|
||||||
'item_id',
|
'item_id',
|
||||||
|
@ -169,7 +167,7 @@ export default class ChangeModel extends BaseModel<Change> {
|
||||||
userId,
|
userId,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!doCountQuery) subParams1.push(subQueryLimit);
|
if (!doCountQuery) subParams1.push(limit);
|
||||||
|
|
||||||
const subQuery2 = `
|
const subQuery2 = `
|
||||||
SELECT ${fieldsSql}
|
SELECT ${fieldsSql}
|
||||||
|
@ -187,7 +185,7 @@ export default class ChangeModel extends BaseModel<Change> {
|
||||||
userId,
|
userId,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!doCountQuery) subParams2.push(subQueryLimit);
|
if (!doCountQuery) subParams2.push(limit);
|
||||||
|
|
||||||
let query: Knex.Raw<any> = null;
|
let query: Knex.Raw<any> = null;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue