Skip to content
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

fix: rollback PR #13951 in v6 #14004

Merged
merged 1 commit into from Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/model.js
Expand Up @@ -314,7 +314,7 @@ class Model {

/**
* Returns the attributes of the model.
*
*
* @returns {object|any}
*/
static getAttributes() {
Expand Down Expand Up @@ -1916,7 +1916,8 @@ class Model {
}

// Bypass a possible overloaded findOne
return await Model.findOne.call(this, options);
// note: in v6, we don't bypass overload https://github.com/sequelize/sequelize/issues/14003
return await this.findOne(options);
}

/**
Expand Down Expand Up @@ -1950,9 +1951,10 @@ class Model {
}

// Bypass a possible overloaded findAll.
return await Model.findAll.call(this, (_.defaults(options, {
plain: true,
})));
// note: in v6, we don't bypass overload https://github.com/sequelize/sequelize/issues/14003
return await this.findAll(_.defaults(options, {
plain: true
}));
}

/**
Expand Down Expand Up @@ -2569,7 +2571,7 @@ class Model {
* @param {boolean} [options.hooks=true] Run before / after bulk create hooks?
* @param {boolean} [options.individualHooks=false] Run before / after create hooks for each individual Instance? BulkCreate hooks will still be run if options.hooks is true.
* @param {boolean} [options.ignoreDuplicates=false] Ignore duplicate values for primary keys? (not supported by MSSQL or Postgres < 9.5)
* @param {Array} [options.updateOnDuplicate] Fields to update if row key already exists (on duplicate key update)? (only supported by MySQL, MariaDB, SQLite >= 3.24.0 & Postgres >= 9.5).
* @param {Array} [options.updateOnDuplicate] Fields to update if row key already exists (on duplicate key update)? (only supported by MySQL, MariaDB, SQLite >= 3.24.0 & Postgres >= 9.5).
* @param {Transaction} [options.transaction] Transaction to run query under
* @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql.
* @param {boolean} [options.benchmark=false] Pass query execution time in milliseconds as second argument to logging function (options.logging).
Expand Down
42 changes: 0 additions & 42 deletions test/unit/model/find-by-pk.test.js

This file was deleted.

34 changes: 0 additions & 34 deletions test/unit/model/find-one.test.js
Expand Up @@ -105,39 +105,5 @@ describe(Support.getTestDialectTeaser('Model'), () => {
await Model.findOne({ where: { unique1: 42 } });
expect(this.stub.getCall(0).args[0]).to.be.an('object').to.have.property('limit');
});
it('should call internal findAll() method if findOne() is overridden', async () => {
const Model = current.define('model', {
unique1: {
type: DataTypes.INTEGER,
unique: 'unique',
},
unique2: {
type: DataTypes.INTEGER,
unique: 'unique',
},
});
Model.findAll = sinon.stub();

await Model.findOne();
Model.findAll.should.not.have.been.called;
Sequelize.Model.findAll.should.have.been.called;
});
it('should call internal findAll() method if findOne() is overridden', async () => {
const Model = current.define('model', {
unique1: {
type: DataTypes.INTEGER,
unique: 'unique',
},
unique2: {
type: DataTypes.INTEGER,
unique: 'unique',
},
});
Model.findAll = sinon.stub();

await Model.findOne();
Model.findAll.should.not.have.been.called;
Sequelize.Model.findAll.should.have.been.called;
});
});
});