On Jan 14, 2:13 pm, Hung Tran <[email protected]> wrote: > Just notice that by default queries like: > > DB[:person].filter(:first_name.like("%#{q}") > > will generate this query: > SELECT * from person where first_name like binary '%queryvalue%" > > Which does case sensitive. In order to get case insensitive you must > give the option also. > > DB[:person].filter(:first_name.like("%#{q}%", :case_insensitive => > true)) > SELECT * from person where first_name like '%queryvalue%" > > The cheat sheet here threw me off a little because it did not mention > the default is > insensitive:http://sequel.rubyforge.org/rdoc/files/doc/cheat_sheet_rdoc.html > > Here's the doc page that explains the > option:http://sequel.rubyforge.org/rdoc/classes/Sequel/SQL/StringExpression....
You should use ilike instead of like for case insensitive searching. The problems with patches to the cheat sheet is that different databases handle things differently. For example, SQLite and MSSQL are case insensitive for both like and ilike, while PostgreSQL and MySQL are case sensitive for like and case insensitive for ilike. Putting that in the cheat sheet doesn't make sense, as the cheat sheet is supposed to be short and not go into details. The documentation already explained that ilike is case insensitive and like is case sensitive, but I've just added a patch that explains that this behavior depends on the database being used: http://github.com/jeremyevans/sequel/commit/a8b4da069c1c5ba0207b5f4913ac078787287e23 Jeremy
-- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
