stargate / data-api

JSON document API for Apache Cassandra (formerly known as JSON API)
https://stargate.io
Apache License 2.0
14 stars 16 forks source link

`deleteOne` and `updateOne` w/ `$ne` can delete (/update) multiple documents #1729

Open toptobes opened 1 week ago

toptobes commented 1 week ago

Example (text is partition key; int is clustering key):

await table.insertMany(Array.from({ length: 10 }, (_, i) => ({ text: key, int: i })));

await table.deleteOne({ text: key, int: { $ne: 5 } });

for (let i = 0; i < 10; i++) {
  if (i === 5) {
    assert.deepStrictEqual(await table.findOne({ text: key, int: i }, { projection: { text: 1, int: 1 } }), { text: key, int: i });
  } else {
    assert.deepStrictEqual(await table.findOne({ text: key, int: i }), null);
  }
}
amorton commented 5 days ago

the fix is probably making sure that we check there is a filter on every column in the OK, which we do, and also check that the operations is $eq (probably not checking the operation)

amorton commented 5 days ago

also for updateOne