Skip to content

Commit

Permalink
Merge pull request #465 from getodk/split-and-filter
Browse files Browse the repository at this point in the history
bug: allow user to both splitSelectMultiples and $filter.
  • Loading branch information
matthew-white authored Mar 11, 2022
2 parents 3462cd5 + 0cf3136 commit 367a7f5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/model/query/submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ inner join
on defs.id=form_field_values."submissionDefId"
inner join
(select * from submissions
where "deletedAt" is null and draft=${draft}) as subs
on subs.id=defs."submissionId"
where "deletedAt" is null and draft=${draft}) as submissions
on submissions.id=defs."submissionId"
where
form_field_values."formId"=${formId} and
${odataFilter(options.filter)}
Expand Down
24 changes: 24 additions & 0 deletions test/integration/api/submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,30 @@ describe('api: /forms/:id/submissions', () => {
done();
}))))));

it('should split select multiples and filter given both options', testService((service, container) =>
service.login('alice', (asAlice) =>
asAlice.post('/v1/projects/1/forms?publish=true')
.set('Content-Type', 'application/xml')
.send(testData.forms.selectMultiple)
.then(() => asAlice.post('/v1/projects/1/forms/selectMultiple/submissions')
.set('Content-Type', 'application/xml')
.send(testData.instances.selectMultiple.one))
.then(() => asAlice.post('/v1/projects/1/forms/selectMultiple/submissions')
.set('Content-Type', 'application/xml')
.send(testData.instances.selectMultiple.two))
.then(() => asAlice.patch('/v1/projects/1/forms/selectMultiple/submissions/two')
.send({ reviewState: 'approved' }))
.then(() => exhaust(container))
.then(() => new Promise((done) =>
zipStreamToFiles(asAlice.get('/v1/projects/1/forms/selectMultiple/submissions.csv.zip?splitSelectMultiples=true&$filter=__system/reviewState eq null'), (result) => {
const lines = result['selectMultiple.csv'].split('\n');
lines.length.should.equal(3);
lines[1].should.containEql(',one,');
lines[1].should.not.containEql('two');
lines[2].should.equal('');
done();
}))))));

it('should export deleted fields and values if ?deletedFields=true', testService((service) =>
service.login('alice', (asAlice) =>
asAlice.post('/v1/projects/1/forms/simple/submissions')
Expand Down

0 comments on commit 367a7f5

Please sign in to comment.