Skip to content

Commit 082adf1

Browse files
fix api and test
1 parent 83a9d1e commit 082adf1

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/transaction/predicate-impl.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,13 @@ export class PredicateImpl<T = any, U = any> implements IPredicate<T, U> {
9090
}
9191

9292
deleteAll(): IPredicate<T, U> {
93-
this.delete(this._data);
93+
const deleteDiff = this._diff.deletes.get(this)!;
94+
95+
for (const node of this._data) {
96+
deleteDiff.add(node);
97+
}
98+
99+
this._data.splice(0, this._data.length);
94100
return this;
95101
}
96102

tests/delete.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ describe('Delete handling', function() {
2929
{
3030
uid: '0x3',
3131
'Person.name': 'Kamil'
32+
},
33+
{
34+
uid: '0x4',
35+
'Person.name': 'Adam'
3236
}
3337
]
3438
}
@@ -46,7 +50,7 @@ describe('Delete handling', function() {
4650
transaction.tree[0].friends.delete(jane);
4751

4852
// XXX: here kamil is not deleted in the friends predicate
49-
expect(transaction.tree[0].friends.get().length).toBe(1);
53+
expect(transaction.tree[0].friends.get().length).toBe(2);
5054

5155
expect(transaction.getDeleteNQuadsString()).toEqual(
5256
`<0x3> * * .
@@ -63,6 +67,8 @@ describe('Delete handling', function() {
6367
<0x2> * * .
6468
<0x1> <Person.friends> <0x2> .
6569
<0x1> <Person.friends> <0x3> .
70+
<0x4> * * .
71+
<0x1> <Person.friends> <0x4> .
6672
`
6773
);
6874
});

0 commit comments

Comments
 (0)