0

I have this method that does a fuzzy search for a name on a sqlite3 database, meaning that if you search the letter "j" it will return any entry that has a "j" anywhere: "John" and "Vijay" would both match. However, when I push the rails app to Heroku, the application uses postgres, and the query's no longer working. According to this SO answer postgres full text search like operator, postgres does use the LIKE operator. Can anyone see what I need to change to make it work on postgres?

def getEmployeeByName

respond_with Employee.select("id, firstname, lastname, position").where("UPPER(firstname || ' ' || lastname) LIKE ('%' || ? || '%')", params[:query])

end

Note, this method is an sql query written with Ruby on Rails query helpers.

4

1 回答 1

2

我将 LIKE 更改为 ILIKE 以使搜索不区分大小写。问题解决了。

于 2013-01-23T22:34:27.743 回答