Skip to content

Commit

Permalink
pass baseVersion through in force create
Browse files Browse the repository at this point in the history
  • Loading branch information
ktuite committed Aug 23, 2024
1 parent d1ac135 commit f0bfecd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/model/query/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,12 @@ const _createEntity = (dataset, entityData, submissionId, submissionDef, submiss
// eslint-disable-next-line no-param-reassign
entityData.system.label = 'auto generated';
}
const partial = await Entity.fromParseEntityData(entityData, { create: true });

// Add the branchBaseVersion to the partial if we are forcing the create and it has one
const _partial = await Entity.fromParseEntityData(entityData, { create: true });
const partial = (forceOutOfOrderProcessing)
? _partial.auxWith('def', { branchBaseVersion: _partial.def.baseVersion })
: _partial;

const sourceDetails = { submission: { instanceId: submissionDef.instanceId }, parentEventId: parentEvent ? parentEvent.id : undefined };
const sourceId = await Entities.createSource(sourceDetails, submissionDefId, event.id);
Expand Down
4 changes: 2 additions & 2 deletions test/integration/api/offline-entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ describe('Offline Entities', () => {
.replace('id="12345678-1234-4123-8234-123456789abc"', `id="${newUuid}"`)
.replace('branchId=""', `branchId="${branchId}"`)
.replace('trunkVersion="1"', 'trunkVersion=""')
.replace('baseVersion="1"', 'baseVersion="2"')
)
.set('Content-Type', 'application/xml')
.expect(200);
Expand All @@ -894,12 +895,11 @@ describe('Offline Entities', () => {
body.currentVersion.data.should.eql({ status: 'arrived' });
body.currentVersion.label.should.eql('auto generated');
body.currentVersion.branchId.should.equal(branchId);

body.currentVersion.branchBaseVersion.should.equal(2);

// This is the first version of the entity so there should be no base or trunk versions
should.not.exist(body.currentVersion.trunkVersion);
should.not.exist(body.currentVersion.baseVersion);
should.not.exist(body.currentVersion.branchBaseVersion);
});

backlogCount = await container.oneFirst(sql`select count(*) from entity_submission_backlog`);
Expand Down

0 comments on commit f0bfecd

Please sign in to comment.