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

Commit 3788db7e by Jan Aagaard Meier

query hasJoin

1 parent eb41cdd0
......@@ -93,9 +93,12 @@ module.exports = (function() {
DAOFactory.prototype.findAll = function(options) {
var start = tk.time();
var hasJoin = false;
if ((typeof options === 'object') && (options.hasOwnProperty('include'))) {
var includes = options.include
hasJoin = true;
options.include = {}
includes.forEach(function(daoName) {
......@@ -104,7 +107,7 @@ module.exports = (function() {
}
this.daoFactoryManager.sequelize._metric('DAOFactory.findAll', tk.time() - start);
return this.QueryInterface.select(this, this.tableName, options, { type: 'SELECT' })
return this.QueryInterface.select(this, this.tableName, options, { type: 'SELECT', hasJoin: hasJoin })
}
//right now, the caller (has-many-double-linked) is in charge of the where clause
......@@ -118,10 +121,7 @@ module.exports = (function() {
DAOFactory.prototype.find = function(options) {
var start = tk.time();
var queryOptions = {
plain: true,
type: 'SELECT'
};
var hasJoin = false;
// no options defined?
// return an emitter which emits null
if([null, undefined].indexOf(options) !== -1) {
......@@ -148,7 +148,7 @@ module.exports = (function() {
options = { where: where }
} else if((typeof options === 'object') && (options.hasOwnProperty('include'))) {
var includes = options.include
queryOptions.hasJoin = true;
hasJoin = true;
options.include = {}
......@@ -160,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, queryOptions)
return this.QueryInterface.select(this, this.tableName, options, { plain: true, type: 'SELECT', hasJoin: hasJoin })
}
DAOFactory.prototype.count = function(options) {
......
......@@ -200,10 +200,6 @@ module.exports = (function() {
var isSelectQuery = function() {
return this.options.type === 'SELECT';
return (this.options.type && this.options.type === "SELECT") || (this.sql.toLowerCase().indexOf('select') === 0)
if (this.options.type !== undefined) return this.options.type === 'SELECT';
return (this.sql.toLowerCase().indexOf('select') === 0)
}
var isUpdateQuery = function() {
......@@ -216,7 +212,7 @@ module.exports = (function() {
if (this.options.raw) {
result = results
} else if (this.options.hasJoin === true && queryResultHasJoin.call(this, results)) {
} else if (this.options.hasJoin === true) {
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!