Skip to content

Commit

Permalink
Rewrote for loop to functional find.
Browse files Browse the repository at this point in the history
  • Loading branch information
geon committed Aug 15, 2016
1 parent 5e53bcf commit 7050a32
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions ComposableSqlFromClause.js
Expand Up @@ -74,18 +74,17 @@ function ComposableSqlFromClause (tables) {

// If there is one, join to the first column that
// has a foreign key to the table in this join.
// TODO: Rewrite with .find().
for (var i = 0; i < earlierColumnsWithForeignKey.length; i++) {
var column = earlierColumnsWithForeignKey[i];

if (column.foreignKey.table == join.table) {
var column = earlierColumnsWithForeignKey
.find(function (column) {
return column.foreignKey.table == join.table;
});
if (column) {

join.onExpression = new ComposableSqlEq(
join.table.columns[column.foreignKey.name],
column
);
return;
}
join.onExpression = new ComposableSqlEq(
join.table.columns[column.foreignKey.name],
column
);
return;
}

// Check if any of the columns in the table of this
Expand Down

0 comments on commit 7050a32

Please sign in to comment.