Skip to content

Commit

Permalink
don't apply optimistic concurrency if optCon array
Browse files Browse the repository at this point in the history
  • Loading branch information
IslandRhythms committed Jun 13, 2023
1 parent 40528ce commit 97dec73
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ Model.prototype.$__handleSave = function(options, callback) {
const optionsWithCustomValues = Object.assign({}, options, saveOptions);
const where = this.$__where();
const optimisticConcurrency = this.$__schema.options.optimisticConcurrency;
if (optimisticConcurrency) {
if (optimisticConcurrency && !Array.isArray(optimisticConcurrency)) {
const key = this.$__schema.options.versionKey;
const val = this.$__getValue(key);
if (val != null) {
Expand Down
4 changes: 2 additions & 2 deletions test/versioning.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ describe('versioning', function() {
assert.equal(err.name, 'VersionError');
});

it('should support optimisticConcurrency being an array of strings asdf', async function() {
it('should support optimisticConcurrency being an array of strings', async function() {
const thingSchema = new Schema({ price: Number, name: String }, { optimisticConcurrency: ['price', 'name'] });
const Thing = db.model('Thing', thingSchema);

Expand All @@ -526,7 +526,7 @@ describe('versioning', function() {
assert.equal(thing_1.__v, 1);
thing_2.set({ price: 1, name: 'Test' });
const err = await thing_2.save().then(() => null, err => err);
assert.equal(err.name, 'VersionError');
assert.ok(!err)
});

it('gh-1898', async function() {
Expand Down

0 comments on commit 97dec73

Please sign in to comment.