Skip to content

Commit 12a42f7

Browse files
authored
Merge pull request rails#26000 from kamipo/remove_sanitize
Remove internal `sanitize` method
2 parents a1e4c19 + d14a5de commit 12a42f7

File tree

2 files changed

+1
-13
lines changed

2 files changed

+1
-13
lines changed

activerecord/lib/active_record/sanitization.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ module Sanitization
55
extend ActiveSupport::Concern
66

77
module ClassMethods
8-
# Used to sanitize objects before they're used in an SQL SELECT statement.
9-
# Delegates to {connection.quote}[rdoc-ref:ConnectionAdapters::Quoting#quote].
10-
def sanitize(object) # :nodoc:
11-
connection.quote(object)
12-
end
13-
alias_method :quote_value, :sanitize
14-
158
protected
169

1710
# Accepts an array or string of SQL conditions and sanitizes
@@ -216,7 +209,7 @@ def raise_if_bind_arity_mismatch(statement, expected, provided) # :nodoc:
216209

217210
# TODO: Deprecate this
218211
def quoted_id # :nodoc:
219-
self.class.quote_value(@attributes[self.class.primary_key].value_for_database)
212+
self.class.connection.quote(@attributes[self.class.primary_key].value_for_database)
220213
end
221214
end
222215
end

activerecord/test/cases/finder_test.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -874,11 +874,6 @@ def test_named_bind_variables
874874
assert_kind_of Time, Topic.where(["id = :id", { id: 1 }]).first.written_on
875875
end
876876

877-
def test_string_sanitation
878-
assert_not_equal "'something ' 1=1'", ActiveRecord::Base.sanitize("something ' 1=1")
879-
assert_equal "'something; select table'", ActiveRecord::Base.sanitize("something; select table")
880-
end
881-
882877
def test_count_by_sql
883878
assert_equal(0, Entrant.count_by_sql("SELECT COUNT(*) FROM entrants WHERE id > 3"))
884879
assert_equal(1, Entrant.count_by_sql(["SELECT COUNT(*) FROM entrants WHERE id > ?", 2]))

0 commit comments

Comments
 (0)