-
Notifications
You must be signed in to change notification settings - Fork 84
make entities.uuid
DB column of type uuid (rather than varchar(255)
)
#1618
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
0d35408
to
5e69b48
Compare
5e69b48
to
d0bd95b
Compare
d0bd95b
to
46169c4
Compare
46169c4
to
20a68fd
Compare
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.
These migrations are small enough that I don't think we should use this pattern of the sidecar sql files. Especially because the mechanism for loading the extra files is longer than the migrations themselves. If we want to use this pattern more in the future, maybe we put getSqlFiles
in a utility file or something instead of copying it from migration to migration.
one: `<data xmlns:jr="http://openrosa.org/javarosa" xmlns:entities="http://www.opendatakit.org/xforms" id="simpleEntity" version="1.0"> | ||
<meta> | ||
<instanceID>one</instanceID> | ||
<entities:entity dataset="people" id="uuid:12345678-1234-4123-8234-123456789abc" create="1"> |
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.
These prefixes should stay in these tests. I can't find where it's mentioned explicitly in the spec but this was an explicit decision to allow these prefixes in submissions and then strip them out before storing them because there's a similar functionality for submission instance IDs.
When test/data/xml.js
is reverted, most of the other test files (the ones that remove the uuid
) also need to be reverted.
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.
allow these prefixes in submissions and then strip them out before storing them because there's a similar functionality for submission instance IDs.
IIUC submission instance IDs are stored as-is though. They're not mangled (that is, their uuid:
(if they have one at all - instance IDs are freeform strings...) prefix is not stripped).
|
||
it('should call entities purge if entities uuid is specified', testTask(() => | ||
purgeTask({ entityUuid: 'abc', projectId: 1, datasetName: 'people' }) | ||
purgeTask({ entityUuid: '00000000-0000-0000-8000-000000000000', projectId: 1, datasetName: 'people' }) |
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.
This type of change is reasonable to me.
But if you change abc
to a valid uuid structure here, you should probably do that for the other tests in this file, even though many of them never get to the uuid validity checking stage.
create: '1', | ||
dataset: 'people', | ||
id: 'uuid:12345678-1234-4123-8234-123456789abc' | ||
id: '12345678-1234-4123-8234-123456789abc' |
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 this to bring uuid: back here and elsewhere in this file
.then((result) => { | ||
should(result.system).eql({ | ||
create: '1', | ||
id: 'uuid:12345678-1234-4123-8234-123456789abc', |
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 this to bring uuid: back here and elsewhere in this file
.send(testData.instances.simpleEntity.one | ||
.replace('create="1"', 'update="1"') | ||
.replace('<instanceID>one', '<deprecatedID>one</deprecatedID><instanceID>one2') | ||
.replace('id="uuid:12345678-1234-4123-8234-123456789abc"', 'id="uuid:12345678-1234-4123-8234-123456789aaa"')) |
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 this to bring uuid: back here and in similar situations in this file
await asAlice.post('/v1/projects/1/datasets/people/entities/bulk-delete') | ||
.send({ | ||
ids: ['12345678-1234-4123-8234-nonexistent'] | ||
ids: ['12345678-1234-4123-8234-0123456789ab'] |
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.
This kind of change to make it into a valid UUID is good.
const asAlice = await service.login('alice'); | ||
|
||
await asAlice.post('/v1/projects/1/datasets/people/entities/nonexistant/restore') | ||
await asAlice.post('/v1/projects/1/datasets/people/entities/00000000-0000-0000-0000-000000000000/restore') |
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.
This change is fine but maybe there should be another test of the other way this endpoint can fail
it('should reject if the entity uuid is not valid', testEntities(async (service) => {
const asAlice = await service.login('alice');
await asAlice.post('/v1/projects/1/datasets/people/entities/abc/restore')
.expect(400)
.then(({ body }) => {
body.code.should.equal(400.11);
body.message.should.equal('Invalid input data type: expected "abc" to be (type uuid)');
});
}));
I'm not thinking of a test like this for every endpoint using entity UUIDs, but at least one somewhere to capture this new validation.
it('should return notfound if the dataset does not exist', testEntities(async (service) => { | ||
const asAlice = await service.login('alice'); | ||
|
||
await asAlice.get('/v1/projects/1/datasets/nonexistent/entities/123') |
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.
These changes are fine
await asAlice.post('/v1/projects/1/forms/multiPropertyEntity2/submissions') | ||
.send(testData.instances.multiPropertyEntity.one | ||
.replace('multiPropertyEntity', 'multiPropertyEntity2') | ||
.replace('uuid:12345678-1234-4123-8234-123456789aaa', 'uuid:12345678-1234-4123-8234-123456789ccc') |
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 this to bring uuid: back here and elsewhere in this file
Following up on this Slack discussion.
What has been done to verify that this works as intended?
Tests, a few of which needed fixing, as they were supplying non-UUIDs as if they were UUIDs.
Why is this the best possible solution? Were any other approaches considered?
No. Well, it'd be good to do some light validation of inputs before they reach the DB. You'll get a 500 when supplying a non-UUID.
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.
Not really.
Before submitting this PR, please make sure you have:
make test
and confirmed all checks still pass OR confirm CircleCI build passes