mirror of https://github.com/rails/rails
Fix sanitize_sql_like with escape_character doc [ci-skip]
When an `escape_character` is specified, `sanitize_sql_like` will escape occurrences of it rather than `"\\"`. This commit also modifies the examples to demonstrate that behavior.
This commit is contained in:
parent
02ad57a46b
commit
659cdebc68
|
@ -92,16 +92,17 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sanitizes a +string+ so that it is safe to use within an SQL
|
# Sanitizes a +string+ so that it is safe to use within an SQL
|
||||||
# LIKE statement. This method uses +escape_character+ to escape all occurrences of "\", "_" and "%".
|
# LIKE statement. This method uses +escape_character+ to escape all
|
||||||
|
# occurrences of itself, "_" and "%".
|
||||||
#
|
#
|
||||||
# sanitize_sql_like("100%")
|
# sanitize_sql_like("100% true!")
|
||||||
# # => "100\\%"
|
# # => "100\\% true!"
|
||||||
#
|
#
|
||||||
# sanitize_sql_like("snake_cased_string")
|
# sanitize_sql_like("snake_cased_string")
|
||||||
# # => "snake\\_cased\\_string"
|
# # => "snake\\_cased\\_string"
|
||||||
#
|
#
|
||||||
# sanitize_sql_like("100%", "!")
|
# sanitize_sql_like("100% true!", "!")
|
||||||
# # => "100!%"
|
# # => "100!% true!!"
|
||||||
#
|
#
|
||||||
# sanitize_sql_like("snake_cased_string", "!")
|
# sanitize_sql_like("snake_cased_string", "!")
|
||||||
# # => "snake!_cased!_string"
|
# # => "snake!_cased!_string"
|
||||||
|
|
Loading…
Reference in New Issue