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

You need to sign in or sign up before continuing.
Commit 92d191d5 by Jan Aagaard Meier

type flag on select

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