-
Notifications
You must be signed in to change notification settings - Fork 21.9k
Use attribute_names over column_names #25304
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
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @sgrif (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Yeah I think this is too private API focused. Overall I'm trying to reduce the amount of places where "an active record class" is the interface desired. |
Did you just say that you prefer using
So while yes, you don't want to pass a sql expression to |
f18160f
to
b2424c0
Compare
@sgrif Hi again. I thought relation.select_values = column_names.map { |cn|
@klass.has_attribute?(cn) || @klass.attribute_alias?(cn) ? arel_attribute(cn) : cn
} Used the same logic in if @klass.has_attribute?(column_name.to_s) || @klass.attribute_alias?(column_name.to_s)
@klass.arel_attribute(column_name)
else
Arel.sql(column_name == :all ? "*" : column_name.to_s)
end
|
the fix in rails is: rails/rails#25304 But need to find a good way to get that PR merged. In the mean time, we can support on our side.
b2424c0
to
27f8f74
Compare
the fix in rails is: rails/rails#25304 But need to find a good way to get that PR merged. In the mean time, we can support on our side.
the fix in rails is: rails/rails#25304 But need to find a good way to get that PR merged. In the mean time, we can support on our side. (transferred from ManageIQ/manageiq@8accb7f)
Summary
Rails know how to convert a column name to an
Arel::Attribute
.The rest of the code base uses
arel_attribute
overArel::Attribute.new
.This patch cleans up this one spot.
//cc @matthewd was able to remove the aliases code
/cc @sgrif Do you feel this is too private api focused? Any suggestions for a different approach? thnx