The escaped_like extension adds escaped_like
and escaped_ilike
methods to Sequel::SQL::StringMethods
, which allow them to be easily used with most of Sequel’s expression objects. Example:
DB[:table].where{string_column.escaped_like('?%', user_input)} # user_input is 'foo': # SELECT * FROM table WHERE string_column LIKE 'foo%' ESCAPE '\' # user_input is '%foo': # SELECT * FROM table WHERE string_column LIKE '\%foo%' ESCAPE '\'
To load the extension:
Sequel.extension :escaped_like
Related modules: Sequel::SQL::StringMethods
, Sequel::SQL::EscapedLikeExpression