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

[4.2] Don't allow relations to be accessed via snake case #3423

Closed
wants to merge 1 commit into from
Closed

[4.2] Don't allow relations to be accessed via snake case #3423

wants to merge 1 commit into from

Conversation

anlutro
Copy link
Contributor

@anlutro anlutro commented Feb 1, 2014

This is just a weird inconsistency that will catch you off guard. If you eager load a multi-word relationship (using camel case function names of course) but access it via snake case, it will bypass the eager loading.

The alternative is to move the converting of $key to camel case before checking if the key exists in the already loaded relations.

@JoostK
Copy link
Contributor

JoostK commented Feb 1, 2014

I remember how this has been such a pain in the early days :(

@taylorotwell
Copy link
Member

Not going to do this. Just define functions as camelCase and access them camelCase.

@anlutro anlutro deleted the no-snake-relation branch February 8, 2014 07:58
@lazychaser
Copy link
Contributor

@taylorotwell why then camel_case attribute here? It allows to access same attribute two ways which obfuscates a little.

@Xethron
Copy link
Contributor

Xethron commented May 12, 2014

Agreed! I quite like the snake_case, however, I've spend the past few hours figuring out why my view generates 400 queries, and if it wasn't for @anlutro, I never would've found it. If I got an error this would've saved me a LOT of time.

So, ether set eager loading to work with snake_case, or drop snake_case altogether! But having a semi working snake_case implementation will only cause problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants