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

Commit f6b78555 by Jan Aagaard Meier

Don't try to select the primary key for models without primary key. Closes #4607

1 parent 492dad28
# Next
- [FIXED] Partial rollback of datatype validations by hiding it behind the `typeValidation` flag.
- [FIXED] Don't try to select the primary key for models without primary key [#4607](https://github.com/sequelize/sequelize/issues/4607)
# 3.11.0
- [INTERNALS] Updated dependencies [#4594](https://github.com/sequelize/sequelize/pull/4594)
......
......@@ -1354,7 +1354,7 @@ Model.prototype.findAll = function(options) {
validateIncludedElements.call(this, options, tableNames);
// If we're not raw, we have to make sure we include the primary key for deduplication
if (!options.raw && options.attributes.indexOf(this.primaryKeyAttribute) === -1) {
if (options.attributes && !options.raw && this.primaryKeyAttribute && options.attributes.indexOf(this.primaryKeyAttribute) === -1) {
options.originalAttributes = options.attributes;
options.attributes = [this.primaryKeyAttribute].concat(options.attributes);
}
......
......@@ -68,6 +68,25 @@ describe(Support.getTestDialectTeaser('Model'), function() {
]);
});
});
it('works for models without PK #4607', function () {
var Model = current.define('model', {}, { timestamps: false });
var Foo = current.define('foo');
Model.hasOne(Foo);
Model.removeAttribute('id');
return Model.findAll({
attributes: {
include: ['name']
},
include: [Foo]
}).bind(this).then(function () {
expect(this.stub.getCall(0).args[2].attributes).to.deep.equal([
'name'
]);
});
});
});
});
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!