Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rbi for ActiveRecord::Sanitization::ClassMethods #235

Merged
merged 2 commits into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/activerecord/all/activerecord.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ class ActiveRecord::Base
extend ActiveRecord::Scoping::Default::ClassMethods # via ActiveRecord::Scoping::Default Concern inclusion
include ActiveRecord::Scoping::Named # via ActiveRecord::Scoping#included hook
extend ActiveRecord::Scoping::Named::ClassMethods # via ActiveRecord::Scoping::Named Concern inclusion
include ActiveRecord::Sanitization
include ActiveRecord::AttributeAssignment
include ActiveModel::Conversion
include ActiveRecord::Integration
Expand Down
6 changes: 6 additions & 0 deletions lib/activerecord/all/activerecord_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,9 @@ def test_activerecord_instance_methods
T.assert_type!(relation.size, Integer)
end
end

class ActiveRecordBaseTest
def sanitize_sql_test
ActiveRecord::Base.sanitize_sql(["where id IN ?", [1, 2, 3]])
end
end
34 changes: 34 additions & 0 deletions lib/activerecord/all/sanitization.rbi
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# typed: stict

class ActiveRecord::Base
include ActiveRecord::Sanitization
extend ActiveRecord::Sanitization::ClassMethods # via ActiveRecord::Sanitization concern
end

# @see https://github.com/rails/rails/blob/eca6c273fe2729b9634907562c2717cf86443b6b/activerecord/lib/active_record/sanitization.rb
module ActiveRecord::Sanitization::ClassMethods
sig { params(condition: T.any(T.nilable(String), Array)).returns(T.nilable(String)) }
def sanitize_sql_for_conditions(condition)
end
alias :sanitize_sql :sanitize_sql_for_conditions

sig { params(assignments: T.any(Array, Hash, String), default_table_name: String).returns(String) }
def sanitize_sql_for_assignment(assignments, default_table_name)
end

sig { params(condition: T.any(Array, String)).returns(String) }
def sanitize_sql_for_order(condition)
end

sig { params(attrs: Hash, table: String).returns(String) }
def sanitize_sql_hash_for_assignment(attrs, table)
end

sig { params(string: String, escape_character: String).returns(String) }
def sanitize_sql_like(string, escape_character = "\\")
end

sig { params(ary: Array).returns(String) }
def sanitize_sql_array(ary)
end
end