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

Commit 79b80a8e by Joel Trost Committed by Matt Broadstone

Fixed bug in lib/model.js deleting clauses

1 parent da053191
......@@ -780,7 +780,6 @@ module.exports = (function() {
selectQuery: function(tableName, options, model) {
// Enter and change at your own peril -- Mick Hansen
options = options || {};
var table = null
......@@ -1259,7 +1258,7 @@ module.exports = (function() {
}
query += ';';
console.log(query);
//console.log(query);
return query;
},
......
......@@ -383,6 +383,7 @@ module.exports = (function() {
//console.log('tablename', tableName);
//console.log('options', options);
//console.log('model', model);
//console.log(options.where);
options = options || {};
var query = [
......@@ -395,8 +396,10 @@ module.exports = (function() {
query.push(SqlGenerator.getJoinClause(model, options.include[i]));
}
}
console.log(query);
if(options.hasOwnProperty('where')){
query.push(this.getWhereConditions(options.where, model.name, model, options));
}
//console.log(query);
return query.join(' ') + ';';
},
/**
......@@ -483,8 +486,18 @@ module.exports = (function() {
/*
Takes something and transforms it into values of a where condition.
*/
getWhereConditions: function(smth, tableName, factory, options, prepend) {
throwMethodUndefined('getWhereConditions');
/*
Takes something and transforms it into values of a where condition.
*/
getWhereConditions: function(smth, tableName, model, options, prepend) {
//console.log('where:', model);
//console.log('logic', smth);
if(!smth){
return SqlGenerator.getWhereClause(tableName, model, options);
}else{
return '';
}
},
prependTableNameToHash: function(tableName, hash) {
......
......@@ -490,14 +490,26 @@ module.exports = {
var primaryKey = '';
for(var key in model.rawAttributes){
if(model.rawAttributes[key].primaryKey){
primaryKey = key;
primaryKey = quoteIdentifier(key);
break;
}
}
console.log(include.association.foreignKey);
console.log(primaryKey);
//for(var i = 0; i < )
var joinType = include.required ? ' INNER JOIN ' : ' LEFT OUTER JOIN ';
var joinType = include.required ? 'INNER JOIN' : 'LEFT OUTER JOIN';
var joinTable = include.as ? include.as : include.model.name;
joinTable = quoteIdentifier(joinTable);
var tableName = quoteIdentifier(model.name);
//console.log(include);
return [
joinType,
quoteIdentifier(include.model.tableName),
'AS', joinTable,
'ON', tableName + '.' + primaryKey,
'=', joinTable + '.' + quoteIdentifier(include.association.foreignKey)
].join(' ');
},
getWhereClause: function(tableName, model, options){
//console.log('my model:', model);
}
};
......
......@@ -689,7 +689,6 @@ module.exports = (function() {
}
}).then(function() {
expandIncludeAll.call(this, options);
if (options.hooks) {
return this.runHooks('beforeFindAfterExpandIncludeAll', options);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!