Skip to content
This repository has been archived by the owner on Mar 4, 2019. It is now read-only.

Commit

Permalink
fix table search w multiple columns #154
Browse files Browse the repository at this point in the history
  • Loading branch information
xivSolutions committed Dec 12, 2015
1 parent 1e5333a commit eed8887
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ Table.prototype.destroySync = DA(Table.prototype.destroy);
Table.prototype.search = function(args, next){
//search expects a columns array and the term
assert(args.columns && args.term, "Need columns as an array and a term string");

if(!_.isArray(args.columns)){
args.columns = [args.columns];
};
Expand All @@ -137,7 +136,7 @@ Table.prototype.search = function(args, next){
tsv = util.format("%s", args.columns[0])
}else{
vectorFormat = 'to_tsvector(%s)'
tsv= util.format("concat('%s')", args.columns.join(", ', '"));
tsv= util.format("concat(%s)", args.columns.join(", ' ', "));
}
var sql = "select * from " + this.delimitedFullName + " where " + util.format(vectorFormat, tsv);
sql+= " @@ to_tsquery($1);";
Expand Down

0 comments on commit eed8887

Please sign in to comment.