Skip to content

Commit

Permalink
responding to review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ktuite committed Oct 29, 2024
1 parent 6f058a1 commit 53a9f4e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/model/query/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ const _createEntity = (dataset, entityData, submissionId, submissionDef, submiss

// Extra flags
// - forceOutOfOrderProcessing: entity was in backlog and was force-processed, which affects base version calculation
// - createSubAsUpdate: submission was meant to *create* entity but is being parsed and applied as an update
// - createSubAsUpdate: submission was meant to *create* entity (and should be parsed as such) but is applied as an update
const _updateEntity = (dataset, entityData, submissionId, submissionDef, submissionDefId, event, forceOutOfOrderProcessing = false, createSubAsUpdate = false) => async ({ Audits, Entities }) => {
if (!(event.action === 'submission.create'
|| event.action === 'submission.update.version'
Expand Down Expand Up @@ -368,7 +368,7 @@ const _updateEntity = (dataset, entityData, submissionId, submissionDef, submiss
// Used by _updateVerison to figure out the intended base version in Central
// based on the branchId, trunkVersion, and baseVersion in the submission
const _computeBaseVersion = (eventId, dataset, clientEntity, submissionDef, forceOutOfOrderProcessing = false, createSubAsUpdate = false) => async ({ Entities }) => {
if (clientEntity.def.baseVersion == null && createSubAsUpdate) {
if (createSubAsUpdate) {
// if no baseVersion is specified but we are updating and trying to find the base version
// we are probably in the special case of force-apply create-as-update. get the latest version.

Expand Down
4 changes: 3 additions & 1 deletion test/integration/api/offline-entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ describe('Offline Entities', () => {
backlogCount.should.equal(0);
}));

it('should apply an entity update as a create, and then properly handle the delayed create', testOfflineEntities(async (service, container) => {
it('should apply an entity update as a create, and then properly handle the delayed create as an update', testOfflineEntities(async (service, container) => {
const asAlice = await service.login('alice');
const branchId = uuid();

Expand Down Expand Up @@ -1138,6 +1138,7 @@ describe('Offline Entities', () => {
.expect(200)
.then(({ body }) => {
body.currentVersion.data.should.eql({ status: 'checked in' });
should(body.conflict).equal(null); // conflict should be null after update-as-create
});

// First submission creates the entity, but this will be processed as an update
Expand All @@ -1153,6 +1154,7 @@ describe('Offline Entities', () => {
.then(({ body }) => {
body.currentVersion.version.should.equal(2);
body.currentVersion.data.should.eql({ age: '20', status: 'new', first_name: 'Megan' });
body.conflict.should.equal('soft'); // this should be marked as a soft conflict
});
}));

Expand Down

0 comments on commit 53a9f4e

Please sign in to comment.