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

Commit 30b59964 by Mick Hansen

remove unused query generator methods

1 parent add75a67
Showing with 1 additions and 130 deletions
...@@ -935,131 +935,6 @@ module.exports = (function() { ...@@ -935,131 +935,6 @@ module.exports = (function() {
return result ? result : '1=1' return result ? result : '1=1'
}, },
findAssociation: function(attribute, dao){
var associationToReturn;
Object.keys(dao.associations).forEach(function(key){
if(!dao.associations[key]) return;
var association = dao.associations[key]
, associationName
if (association.associationType === 'BelongsTo') {
associationName = Utils.singularize(association.associationAccessor[0].toLowerCase() + association.associationAccessor.slice(1));
} else {
associationName = association.accessors.get.replace('get', '')
associationName = associationName[0].toLowerCase() + associationName.slice(1);
}
if(associationName === attribute){
associationToReturn = association;
}
});
return associationToReturn;
},
getAssociationFilterDAO: function(filterStr, dao){
var associationParts = filterStr.split('.')
, self = this
associationParts.pop()
associationParts.forEach(function (attribute) {
dao = self.findAssociation(attribute, dao).target;
});
return dao;
},
isAssociationFilter: function(filterStr, dao, options){
if(!dao){
return false;
}
var pattern = /^[a-z][a-zA-Z0-9]+(\.[a-z][a-zA-Z0-9]+)+$/;
if (!pattern.test(filterStr)) return false;
var associationParts = filterStr.split('.')
, attributePart = associationParts.pop()
, self = this
return associationParts.every(function (attribute) {
var association = self.findAssociation(attribute, dao);
if (!association) return false;
dao = association.target;
return !!dao;
}) && dao.rawAttributes.hasOwnProperty(attributePart);
},
getAssociationFilterColumn: function(filterStr, dao, options){
var associationParts = filterStr.split('.')
, attributePart = associationParts.pop()
, self = this
, association
, keyParts = []
associationParts.forEach(function (attribute) {
association = self.findAssociation(attribute, dao)
dao = association.target;
if (options.include) {
keyParts.push(association.as || association.options.as || dao.tableName)
}
})
if (options.include) {
return this.quoteIdentifier(keyParts.join('.')) + '.' + this.quoteIdentifiers(attributePart)
}
return this.quoteIdentifiers(dao.tableName + '.' + attributePart)
},
getConditionalJoins: function(options, originalDao){
var joins = ''
, self = this
, joinedTables = {}
if (Utils.isHash(options.where)) {
Object.keys(options.where).forEach(function(filterStr){
var associationParts = filterStr.split('.')
, attributePart = associationParts.pop()
, dao = originalDao
if (self.isAssociationFilter(filterStr, dao, options)) {
associationParts.forEach(function (attribute) {
var association = self.findAssociation(attribute, dao);
if(!joinedTables[association.target.tableName]){
joinedTables[association.target.tableName] = true;
if(association.associationType === 'BelongsTo'){
joins += ' LEFT JOIN ' + self.quoteIdentifiers(association.target.tableName)
joins += ' ON ' + self.quoteIdentifiers(association.source.tableName + '.' + association.identifier)
joins += ' = ' + self.quoteIdentifiers(association.target.tableName + '.' + association.target.autoIncrementField)
} else if (Object(association.through) === association.through) {
joinedTables[association.through.tableName] = true;
joins += ' LEFT JOIN ' + self.quoteIdentifiers(association.through.tableName)
joins += ' ON ' + self.quoteIdentifiers(association.source.tableName + '.' + association.source.autoIncrementField)
joins += ' = ' + self.quoteIdentifiers(association.through.tableName + '.' + association.identifier)
joins += ' LEFT JOIN ' + self.quoteIdentifiers(association.target.tableName)
joins += ' ON ' + self.quoteIdentifiers(association.through.tableName + '.' + association.foreignIdentifier)
joins += ' = ' + self.quoteIdentifiers(association.target.tableName + '.' + association.target.autoIncrementField)
} else {
joins += ' LEFT JOIN ' + self.quoteIdentifiers(association.target.tableName)
joins += ' ON ' + self.quoteIdentifiers(association.source.tableName + '.' + association.source.autoIncrementField)
joins += ' = ' + self.quoteIdentifiers(association.target.tableName + '.' + association.identifier)
}
}
dao = association.target;
});
}
});
}
return joins;
},
arrayValue: function(value, key, _key, factory, logicResult){ arrayValue: function(value, key, _key, factory, logicResult){
var _value = null; var _value = null;
...@@ -1090,11 +965,7 @@ module.exports = (function() { ...@@ -1090,11 +965,7 @@ module.exports = (function() {
if (options.keysEscaped) { if (options.keysEscaped) {
_key = key _key = key
} else { } else {
if(this.isAssociationFilter(key, dao, options)){ _key = this.quoteIdentifiers(key)
_key = key = this.getAssociationFilterColumn(key, dao, options);
} else {
_key = this.quoteIdentifiers(key)
}
} }
if (Array.isArray(value)) { if (Array.isArray(value)) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!