Skip to content

Commit

Permalink
Merge pull request #89 from balena-io-modules/top-skip-binds
Browse files Browse the repository at this point in the history
Use bind vars for $top and $skip options
  • Loading branch information
Page- authored Oct 3, 2024
2 parents cdf80a1 + f160a14 commit a6c037b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
8 changes: 6 additions & 2 deletions odata-parser.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,12 @@ SortProperty =

TopOption =
'top='
value:UnsignedInteger
value:UnsignedIntegerBind
{ return { name: '$top', value } }

SkipOption =
'skip='
value:UnsignedInteger
value:UnsignedIntegerBind
{ return { name: '$skip', value } }

InlineCountOption =
Expand Down Expand Up @@ -675,6 +675,10 @@ NumberBind =
n:Number
{ return Bind('Real', n) }

UnsignedIntegerBind =
n:UnsignedInteger
{ return Bind('Integer', n) }

Date =
type:(
'datetime'
Expand Down
23 changes: 15 additions & 8 deletions test/paging.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@ import * as assert from 'assert';

export default (test) => {
describe('Paging', function () {
test('$top=5&$skip=100', function (result) {
it('top should be specified', () => {
assert.equal(result.options.$top, 5);
});
it('skip should be specified', () => {
assert.equal(result.options.$skip, 100);
});
});
test(
'$top=5&$skip=100',
[
['Integer', 5],
['Integer', 100],
],
function (result) {
it('top should be specified', () => {
assert.deepEqual(result.options.$top, { bind: 0 });
});
it('skip should be specified', () => {
assert.deepEqual(result.options.$skip, { bind: 1 });
});
},
);

test('$inlinecount=allpages', (result) => {
it('inline should be specified', () => {
Expand Down

0 comments on commit a6c037b

Please sign in to comment.