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

Commit 4a184db6 by Mick Hansen

Apparently tableName.* is invalid

1 parent 43ed6755
...@@ -584,9 +584,15 @@ module.exports = (function() { ...@@ -584,9 +584,15 @@ module.exports = (function() {
DAOFactory.prototype.count = function(options) { DAOFactory.prototype.count = function(options) {
options = Utils._.clone(options || {}) options = Utils._.clone(options || {})
return new Utils.CustomEventEmitter(function (emitter) { return new Utils.CustomEventEmitter(function (emitter) {
var col = this.sequelize.col('*')
if (options.include) {
col = this.sequelize.col(this.tableName+'.'+(this.primaryKeyAttributes[0] || 'id'))
}
options.attributes = [ options.attributes = [
[this.sequelize.fn('COUNT', this.sequelize.col(this.tableName+'.*')), 'count'] [this.sequelize.fn('COUNT', col), 'count']
] ]
options.includeIgnoreAttributes = false options.includeIgnoreAttributes = false
......
...@@ -396,7 +396,7 @@ module.exports = (function() { ...@@ -396,7 +396,7 @@ module.exports = (function() {
query = query || "" query = query || ""
if (options.offset && !options.limit) { if (options.offset && !options.limit) {
query += " LIMIT " + options.offset + ", " + 18440000000000000000; query += " LIMIT " + options.offset + ", " + 18440000000000000000;
} else if (options.limit && !(options.include && (options.limit === 1))) { } else if (options.limit) {
if (options.offset) { if (options.offset) {
query += " LIMIT " + options.offset + ", " + options.limit query += " LIMIT " + options.offset + ", " + options.limit
} else { } else {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!