Only detect deletions where attribute set to null
For fields where an empty value is represented by null, it is easy to detect deletions. For other fields e.g. arrays, more complex logic needs to be developed later
This commit is contained in:
parent
63268ebca4
commit
07cdae8899
@ -18,7 +18,7 @@ mockEditHistory.__setHistory = function(mockHistoryData: EditHistoryEntry[]) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function hasDeletions(json) {
|
function hasDeletions(json) {
|
||||||
return Object.values(json).some(x => x === null || (Array.isArray(x) && x.length === 0))
|
return Object.values(json).some(x => x === null);
|
||||||
}
|
}
|
||||||
|
|
||||||
mockEditHistory.getHistoryAfterId = function(id: string, count: number, filterDeletions: boolean): Promise<EditHistoryEntry[]> {
|
mockEditHistory.getHistoryAfterId = function(id: string, count: number, filterDeletions: boolean): Promise<EditHistoryEntry[]> {
|
||||||
|
@ -14,7 +14,7 @@ const baseQuery = `
|
|||||||
JOIN users ON logs.user_id = users.user_id`;
|
JOIN users ON logs.user_id = users.user_id`;
|
||||||
|
|
||||||
const deletionCondition = `
|
const deletionCondition = `
|
||||||
EXISTS (SELECT * from jsonb_each(forward_patch) WHERE value IN ('null', '[]'))
|
EXISTS (SELECT * from jsonb_each(forward_patch) WHERE value = 'null' )
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export function getHistoryAfterId(id: string, count: number, filterDeletions: boolean = false): Promise<EditHistoryEntry[]> {
|
export function getHistoryAfterId(id: string, count: number, filterDeletions: boolean = false): Promise<EditHistoryEntry[]> {
|
||||||
|
Loading…
Reference in New Issue
Block a user