Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OData subtable: $top=0 returns all records #337

Closed
matthew-white opened this issue Mar 5, 2021 · 3 comments · Fixed by #345
Closed

OData subtable: $top=0 returns all records #337

matthew-white opened this issue Mar 5, 2021 · 3 comments · Fixed by #345

Comments

@matthew-white
Copy link
Member

When I specify $top=0 for the Submissions table, it returns an empty array. However, when I specify $top=0 for a subtable, it seems to return all records.

As background, I was specifying $top=0 together with $count=true in order to determine the number of records in a repeat group, related to this forum post. I ended up specifying $top=1 in order not to pull all records. (By the way, I would also be interested if there is a better way to determine that count!)

I think this logic can be found in the extractPaging() function below, where if limit is 0, it defaults to Infinity:

const extractPaging = (table, query) => {
const limit = parseInt(query.$top, 10) || Infinity;
const offset = parseInt(query.$skip, 10) || 0;
const shouldCount = isTrue(query.$count);
const result = { limit: max(0, limit), offset: max(0, offset), shouldCount };
return Object.assign(result, (table === 'Submissions')
? { doLimit: Infinity, doOffset: 0 }
: { doLimit: result.limit, doOffset: result.offset });
};

@issa-tseng
Copy link
Member

looks like odata doesn't have any independent count-only endpoint so we'd have to make one if we wanted one

@matthew-white
Copy link
Member Author

That's interesting that OData doesn't have an independent count-only endpoint. What do you think about using the combination of $count=true + $top=0 to fetch just the count?

@issa-tseng
Copy link
Member

yeah i'll fix this top thing rn

issa-tseng added a commit that referenced this issue Mar 25, 2021
issa-tseng added a commit that referenced this issue Mar 25, 2021
bug #337: $top=0 would accidentally give ALL rows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants