instance method
annotate
Ruby on Rails 7.1.6
Since v6.0.6Signature
annotate(*args)
Adds an SQL comment to queries generated from this relation. For example:
User.annotate("selecting user names").select(:name) # SELECT "users"."name" FROM "users" /* selecting user names */ User.annotate("selecting", "user", "names").select(:name) # SELECT "users"."name" FROM "users" /* selecting */ /* user */ /* names */
The SQL block comment delimiters, “/*” and “*/”, will be added automatically.
Some escaping is performed, however untrusted user input should not be used.
Parameters
-
argsrest
Source
# File activerecord/lib/active_record/relation/query_methods.rb, line 1428
def annotate(*args)
check_if_method_has_arguments!(__callee__, args)
spawn.annotate!(*args)
end
Defined in activerecord/lib/active_record/relation/query_methods.rb line 1428
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::QueryMethods