Skip to content

Commit

Permalink
#250 and #257 - change to of query JSON schema to represent lt in…
Browse files Browse the repository at this point in the history
…stead of `lte` (#258)

this better matches many other APIs that operate with a [inclusive, exclusive) system (e.g. `String.prototype.slice`)
  • Loading branch information
dcrousso authored Mar 13, 2023
1 parent d21765b commit 28bbf5e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/interfaces/records/messages/records-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ export class RecordsQuery extends Message {
case 'dateCreated':
var rangeFilter: RangeFilter = {
gte : filter.dateCreated.from,
lte : filter.dateCreated.to
lt : filter.dateCreated.to
};
if (rangeFilter.gte === undefined) {
delete rangeFilter.gte;
}
if (rangeFilter.lte === undefined) {
delete rangeFilter.lte;
if (rangeFilter.lt === undefined) {
delete rangeFilter.lt;
}
result.dateCreated = rangeFilter;
break;
Expand Down
3 changes: 1 addition & 2 deletions tests/interfaces/records/handlers/records-query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,8 @@ describe('RecordsQueryHandler.handle()', () => {
dateSort : DateSort.CreatedAscending
});
const reply4 = await dwn.processMessage(alice.did, recordsQuery4.message);
expect(reply4.entries?.length).to.equal(2);
expect(reply4.entries?.length).to.equal(1);
expect((reply4.entries[0] as any).encodedData).to.equal(Encoder.bytesToBase64Url(write2.dataBytes));
expect((reply4.entries[1] as any).encodedData).to.equal(Encoder.bytesToBase64Url(write3.dataBytes));
});

it('should be able use range and exact match queries at the same time', async () => {
Expand Down

0 comments on commit 28bbf5e

Please sign in to comment.