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

Commit 6e3f07c8 by Alexander Reiff

Use model.primaryKeyField for HasMany.count column

In HasMany.count(), replaces model.primaryKeyName with primaryKeyField as is used in Model.count(). This fixes an error when doing a count() on an association with "id" primary key attribute mapped to a field name other than "id"
1 parent b4f3e544
Showing with 1 additions and 1 deletions
...@@ -342,7 +342,7 @@ HasMany.prototype.count = function(instance, options) { ...@@ -342,7 +342,7 @@ HasMany.prototype.count = function(instance, options) {
options = association.target.__optClone(options) || {}; options = association.target.__optClone(options) || {};
options.attributes = [ options.attributes = [
[sequelize.fn('COUNT', sequelize.col(model.primaryKeyAttribute)), 'count'] [sequelize.fn('COUNT', sequelize.col(model.primaryKeyField)), 'count']
]; ];
options.raw = true; options.raw = true;
options.plain = true; options.plain = true;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!