@@ -5,8 +5,8 @@ module Sanitization
5
5
extend ActiveSupport ::Concern
6
6
7
7
module ClassMethods
8
- # Accepts an array or string of SQL conditions and sanitizes
9
- # them into a valid SQL fragment for a WHERE clause.
8
+ # Accepts an array of SQL conditions and sanitizes them into a valid
9
+ # SQL fragment for a WHERE clause.
10
10
#
11
11
# sanitize_sql_for_conditions(["name=? and group_id=?", "foo'bar", 4])
12
12
# # => "name='foo''bar' and group_id=4"
@@ -17,6 +17,9 @@ module ClassMethods
17
17
# sanitize_sql_for_conditions(["name='%s' and group_id='%s'", "foo'bar", 4])
18
18
# # => "name='foo''bar' and group_id='4'"
19
19
#
20
+ # This method will NOT sanitize a SQL string since it won't contain
21
+ # any conditions in it and will return the string as is.
22
+ #
20
23
# sanitize_sql_for_conditions("name='foo''bar' and group_id='4'")
21
24
# # => "name='foo''bar' and group_id='4'"
22
25
#
@@ -37,8 +40,8 @@ def sanitize_sql_for_conditions(condition)
37
40
end
38
41
alias :sanitize_sql :sanitize_sql_for_conditions
39
42
40
- # Accepts an array, hash, or string of SQL conditions and sanitizes
41
- # them into a valid SQL fragment for a SET clause.
43
+ # Accepts an array or hash of SQL conditions and sanitizes them into
44
+ # a valid SQL fragment for a SET clause.
42
45
#
43
46
# sanitize_sql_for_assignment(["name=? and group_id=?", nil, 4])
44
47
# # => "name=NULL and group_id=4"
@@ -49,6 +52,9 @@ def sanitize_sql_for_conditions(condition)
49
52
# Post.sanitize_sql_for_assignment({ name: nil, group_id: 4 })
50
53
# # => "`posts`.`name` = NULL, `posts`.`group_id` = 4"
51
54
#
55
+ # This method will NOT sanitize a SQL string since it won't contain
56
+ # any conditions in it and will return the string as is.
57
+ #
52
58
# sanitize_sql_for_assignment("name=NULL and group_id='4'")
53
59
# # => "name=NULL and group_id='4'"
54
60
#
0 commit comments