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

Commit 7ef6a12d by Sascha Depold

dramatically reduced the lookup time of the daoFactory

1 parent f72fefe8
Showing with 12 additions and 20 deletions
......@@ -141,29 +141,21 @@ module.exports = (function() {
* @return {String} The found tableName / alias.
*/
var findTableNameInAttribute = function(attribute) {
var tableName = null
this.sequelize.daoFactoryManager.daos.forEach(function(daoFactory) {
if (!!tableName) {
return
} else if (attribute.indexOf(daoFactory.tableName + ".") === 0) {
tableName = daoFactory.tableName
} else if (attribute.indexOf(Utils.singularize(daoFactory.tableName) + ".") === 0) {
tableName = Utils.singularize(daoFactory.tableName)
} else {
for (var associationName in daoFactory.associations) {
if (daoFactory.associations.hasOwnProperty(associationName)) {
var association = daoFactory.associations[associationName]
if (attribute.indexOf(association.options.as + ".") === 0) {
tableName = association.options.as
}
}
}
if (!this.options.include) {
return null
}
var tableNames = this.options.include.map(function(include) {
return include.as
}).filter(function(include) {
return attribute.indexOf(include + '.') === 0
})
return tableName
if (tableNames.length === 1) {
return tableNames[0]
} else {
return null
}
}
var queryResultHasJoin = function(results) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!