-
Notifications
You must be signed in to change notification settings - Fork 80
Forms: make conflation of published/draft explicit #1527
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
base: master
Are you sure you want to change the base?
Conversation
Current `master` allows requests for forms through query functions to implicitly conflate form drafts and published versions. This leads to surprising behaviours in the API like: * getodk#1404 * TODO others? Affected functions: pretty much all form querying functions.
@@ -22,6 +24,12 @@ const Option = require('../../util/option'); | |||
const Problem = require('../../util/problem'); | |||
const { PURGE_DAY_RANGE } = require('../../util/constants'); | |||
|
|||
const describe = m => (typeof m === 'object' ? JSON.stringify(m) : m); | |||
const fatalError = (...message) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert these
lib/model/query/forms.js
Outdated
@@@@@@ _getSql() @@@@@@ | ||
${require('node:util').inspect(query)} | ||
@@@@@@@@@@@@@@@@@@@@@@@ | ||
`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
test/integration/api/forms/draft.js
Outdated
@@ -3,6 +3,7 @@ const appRoot = require('app-root-path'); | |||
const should = require('should'); | |||
const { testService } = require('../../setup'); | |||
const testData = require('../../../data/xml'); | |||
const { getOrNotFound } = require(appRoot + '/lib/util/promise'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert
@@ -2021,7 +2020,7 @@ describe('Entities API', () => { | |||
|
|||
const logger = (action, actee, details) => log(containerTx1.context.auth.actor, action, actee, details); | |||
|
|||
const entity = await getById(dataset.id, '12345678-1234-4123-8234-123456789abc', QueryOptions.forUpdate)(containerTx1).then(getOrNotFound); | |||
const entity = await getById(dataset.id, '12345678-1234-4123-8234-123456789abc', QueryOptions.forUpdate)(containerTx1).then((o) => o.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-revert - leave this to the dedicated PR
@@ -1224,7 +1225,7 @@ describe('api: /projects/:id/forms (create, read, update)', () => { | |||
.set('Content-Type', 'application/xml') | |||
.expect(200) | |||
.then(() => service.login('chelsea', (asChelsea) => | |||
asChelsea.get('/v1/projects/1/forms/withAttachments/attachments') | |||
asChelsea.get('/v1/projects/1/forms/withAttachments/draft/attachments') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separate PR?
TODO
xml, version
argsNoDefRequired
toWithoutDef
WithoutDef
)PublishedVersion
in non-/draft
forms APICurrent
master
allows requests for forms through query functions to implicitly conflate form drafts and published versions.This leads to surprising behaviours in the API like:
Affected functions: pretty much all form querying functions.
Closes #
What has been done to verify that this works as intended?
Why is this the best possible solution? Were any other approaches considered?
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Does this change require updates to the API documentation? If so, please update docs/api.yaml as part of this PR.
Before submitting this PR, please make sure you have:
make test
and confirmed all checks still pass OR confirm CircleCI build passes