不要怂,就是干,撸起袖子干!

Commit dd1911eb by Paul Bienkowski Committed by Sushant

fix(model): improve warning message when unexpected attribute passed to finder options (#7894)

1 parent da4cb748
Showing with 2 additions and 2 deletions
...@@ -1573,7 +1573,7 @@ class Model { ...@@ -1573,7 +1573,7 @@ class Model {
const unrecognizedOptions = _.difference(Object.keys(options), validQueryKeywords); const unrecognizedOptions = _.difference(Object.keys(options), validQueryKeywords);
const unexpectedModelAttributes = _.intersection(unrecognizedOptions, validColumnNames); const unexpectedModelAttributes = _.intersection(unrecognizedOptions, validColumnNames);
if (!options.where && unexpectedModelAttributes.length > 0) { if (!options.where && unexpectedModelAttributes.length > 0) {
Utils.warn(`Model attributes (${unexpectedModelAttributes.join(', ')}) passed into finder method options, but the options.where object is empty. Did you forget to use options.where?`); Utils.warn(`Model attributes (${unexpectedModelAttributes.join(', ')}) passed into finder method options of model ${this.name}, but the options.where object is empty. Did you forget to use options.where?`);
} }
} }
......
...@@ -22,7 +22,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -22,7 +22,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('Warns the user if they use a model attribute without a where clause', () => { it('Warns the user if they use a model attribute without a where clause', () => {
const User = current.define('User', {firstName: 'string'}); const User = current.define('User', {firstName: 'string'});
User.warnOnInvalidOptions({firstName : 12, order: []}, ['firstName']); User.warnOnInvalidOptions({firstName : 12, order: []}, ['firstName']);
const expectedError = 'Model attributes (firstName) passed into finder method options, but the options.where object is empty. Did you forget to use options.where?'; const expectedError = 'Model attributes (firstName) passed into finder method options of model User, but the options.where object is empty. Did you forget to use options.where?';
expect(this.loggerSpy.calledWith(expectedError)).to.equal(true); expect(this.loggerSpy.calledWith(expectedError)).to.equal(true);
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!