class RuboCop::Cop::Rails::ArelStar
# good
MyTable.arel_table[“*”]
# bad
@example
it might denote legitimate access to a column named ‘*`.
supported by Rails, and even though it is usually a mistake,
an SQL `*`, unquoted. `*` is a valid column name in certain databases
This cop’s autocorrection is unsafe because it turns a quoted ‘*` into
@safety
to expanding the column list as one would likely expect.
database to look for a column named `*` (or `“*”`) as opposed
quoted asterisk (e.g. `my_model`.`*`). This causes the
Using `arel_table` causes the outputted string to be a literal
Prevents usage of `“*”` on an Arel::Table column reference.
def on_send(node)
def on_send(node) return unless (star = star_bracket?(node)) add_offense(star) do |corrector| corrector.replace(star, 'Arel.star') end end