You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-08-10 22:11:50 +02:00
Desktop,Cli: Fix data API failure when including both conflicts and deleted notes in results (#12650)
This commit is contained in:
@@ -20,7 +20,7 @@ export interface WhereQuery {
|
||||
export default async function(db: any, tableName: string, pagination: Pagination, whereQuery: WhereQuery = null, fields: string[] = null): Promise<ModelFeedPage> {
|
||||
fields = fields ? fields.slice() : ['id'];
|
||||
|
||||
const where = whereQuery ? [whereQuery.sql] : [];
|
||||
const where = whereQuery && whereQuery.sql ? [whereQuery.sql] : [];
|
||||
const sqlParams = whereQuery && whereQuery.params ? whereQuery.params.slice() : [];
|
||||
|
||||
if (!pagination.order.length) throw new Error('Pagination order must be provided');
|
||||
|
@@ -11,7 +11,7 @@ import NoteTag from '../../models/NoteTag';
|
||||
import ResourceService from '../../services/ResourceService';
|
||||
import SearchEngine from '../search/SearchEngine';
|
||||
const { MarkupToHtml } = require('@joplin/renderer');
|
||||
import { ResourceEntity } from '../database/types';
|
||||
import { NoteEntity, ResourceEntity } from '../database/types';
|
||||
|
||||
const createFolderForPagination = async (num: number, time: number) => {
|
||||
await Folder.save({
|
||||
@@ -961,4 +961,25 @@ describe('services/rest/Api', () => {
|
||||
await SearchEngine.instance().destroy();
|
||||
|
||||
}));
|
||||
|
||||
it('should not fail when both deleted and conflict notes are included', (async () => {
|
||||
const folder = await Folder.save({});
|
||||
const note1 = await Note.save({ parent_id: folder.id });
|
||||
await msleep(1);
|
||||
const note2 = await Note.save({ parent_id: folder.id, deleted_time: 1 });
|
||||
await msleep(1);
|
||||
const note3 = await Note.save({ parent_id: folder.id, is_conflict: 1 });
|
||||
|
||||
const r1 = await api.route(RequestMethod.GET, 'notes', {
|
||||
limit: 3,
|
||||
include_conflicts: '1',
|
||||
include_deleted: '1',
|
||||
});
|
||||
|
||||
expect(r1.items.map((item: NoteEntity) => item.id)).toEqual([
|
||||
note1.id,
|
||||
note2.id,
|
||||
note3.id,
|
||||
]);
|
||||
}));
|
||||
});
|
||||
|
Reference in New Issue
Block a user