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

Defer Arel attribute lookup to the model class #23457

Merged
merged 2 commits into from Feb 3, 2016

Conversation

matthewd
Copy link
Member

@matthewd matthewd commented Feb 3, 2016

This still isn't as separated as I'd like, but it at least moves most of the burden of alias mapping in one place.

@sgrif I was initially expecting has_attribute?(an_alias) to be true -- which would save us the two remaining places we explicitly ask whether we have an alias.

.. and then there's the one that needs a list of all "arel resolvable" attribute names (i.e., including aliases).

This still isn't as separated as I'd like, but it at least moves most of
the burden of alias mapping in one place.
@sgrif
Copy link
Contributor

sgrif commented Feb 3, 2016

I'd still really prefer that we had TableMetadata be the point of separation for this -- I don't like the model class itself being the point of coupling for AST builder related functions. That said, if we really want to go this route, we could probably give the second argument a default at least.

@matthewd
Copy link
Member Author

matthewd commented Feb 3, 2016

I'm going via the TableMetadata where that's already how we were getting the columns. Here I'm just aiming for a simple extract (and unify) method refactoring, without rearranging anything overall.

As it currently stands, the TableMetadata already relies on the klass for aliases.

Overall, I think this is not much of an improvement, but not an architectural regression.

@sgrif
Copy link
Contributor

sgrif commented Feb 3, 2016

My concern with it is that it creates the klass as the sole place to override this behavior, not TableMetadata.

@sgrif
Copy link
Contributor

sgrif commented Feb 3, 2016

Anyway I don't feel super strongly about this. Go with whatever you think is best.

@matthewd
Copy link
Member Author

matthewd commented Feb 3, 2016

My thinking is that it's all private anyway: once we've taught the other places to use the tablemetadata, then we stop it delegating to klass, and kill the method on the model; this just works as a small interim step.

@sgrif
Copy link
Contributor

sgrif commented Feb 3, 2016

👍

@kbrock
Copy link
Contributor

kbrock commented Feb 3, 2016

thanks @sgrif and @matthewd

matthewd added a commit that referenced this pull request Feb 3, 2016
Defer Arel attribute lookup to the model class
@matthewd matthewd merged commit eeaf6ee into rails:master Feb 3, 2016
@matthewd matthewd deleted the arel-attribute branch June 11, 2017 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants