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

Commit 92d191d5 by Jan Aagaard Meier

type flag on select

1 parent 6cc05eaf
......@@ -104,7 +104,7 @@ module.exports = (function() {
}
this.daoFactoryManager.sequelize._metric('DAOFactory.findAll', tk.time() - start);
return this.QueryInterface.select(this, this.tableName, options)
return this.QueryInterface.select(this, this.tableName, options, { type: 'SELECT' })
}
//right now, the caller (has-many-double-linked) is in charge of the where clause
......@@ -112,11 +112,16 @@ module.exports = (function() {
var optcpy = Utils._.clone(options)
optcpy.attributes = optcpy.attributes || [Utils.addTicks(this.tableName)+".*"]
return this.QueryInterface.select(this, [this.tableName, joinTableName], optcpy)
return this.QueryInterface.select(this, [this.tableName, joinTableName], optcpy, { type: 'SELECT' })
}
DAOFactory.prototype.find = function(options) {
var start = tk.time();
var queryOptions = {
plain: true,
type: 'SELECT'
};
// no options defined?
// return an emitter which emits null
if([null, undefined].indexOf(options) !== -1) {
......@@ -143,6 +148,7 @@ module.exports = (function() {
options = { where: where }
} else if((typeof options === 'object') && (options.hasOwnProperty('include'))) {
var includes = options.include
queryOptions.hasJoin = true;
options.include = {}
......@@ -154,7 +160,7 @@ module.exports = (function() {
options.limit = 1
this.daoFactoryManager.sequelize._metric('DAOFactory.find', tk.time() - start);
return this.QueryInterface.select(this, this.tableName, options, { plain: true })
return this.QueryInterface.select(this, this.tableName, options, queryOptions)
}
DAOFactory.prototype.count = function(options) {
......@@ -180,7 +186,6 @@ module.exports = (function() {
return this.QueryInterface.rawSelect(this.tableName, options, 'min')
}
DAOFactory.prototype.build = function(values, options) {
var start = tk.time();
var instance = new DAO(values, Utils._.extend(this.options, { hasPrimaryKeys: this.hasPrimaryKeys, factory: this }))
......
......@@ -199,7 +199,7 @@ module.exports = (function() {
}
var isSelectQuery = function() {
return (this.sql.toLowerCase().indexOf('select') === 0)
return this.options.type === 'SELECT';
}
var isUpdateQuery = function() {
......@@ -207,12 +207,12 @@ module.exports = (function() {
}
var handleSelectQuery = function(results) {
var start = tk.time(), _start;
var start = tk.time();
var result = null, self = this;
if (this.options.raw) {
result = results
} else if (queryResultHasJoin.call(this, results)) {
} else if (this.options.hasJoin === true && queryResultHasJoin.call(this, results)) {
result = prepareJoinData.call(this, results)
result = groupDataByCalleeFactory.call(this, result).map(function(result) {
// let's build the actual dao instance first...
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!