Consider how #order works - it adds additional order to scope instead of 
replacing it. To replace, we use #reorder.

We can't change this behavior on #select (making #select be additive and 
adding #reselect to be replacing) because it'd break existing APIs. But we 
could at least add a method like #add_select or #append select.

In our code, we have a lot of places that go like this:

memberships.includes(:user).select("memberships.*, users.email")

It's even worse for complex joins, where I need to manually remember every 
table that would be part of the join (or risk getting attribute missing 
errors).

What I want is to just add a field to existing select and not break all the 
normal selects already there:

memberships.includes(:user).add_select("users.email")

Naming wise, I'm leaning towards #add_select as opposed to #append_select, 
because "append" implies order-specific (as opposed to "prepend") while 
this should be order-insensitive.

Anyone has an opinion?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to