-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
MONGOID-5789 database_field_name given nil or empty string should raise UnknownAttribute exception #5836
MONGOID-5789 database_field_name given nil or empty string should raise UnknownAttribute exception #5836
Conversation
@danhealy -- as you noted on the Jira ticket, returning an empty string (instead of raising an exception) is probably more appropriate here. A few reasons:
There may still be collateral damage from such a change, but a quick check shows that at least some of the tests that were failing as a result raising the exception, pass successfully when an empty string is returned. It's worth experimenting with returning the empty string, I think. Thank you for your work on this issue! |
@danhealy I agree with @jamis and would vote against this change. I have code like the following which would break:
Nothing stops you from doing a monkey patch like:
@jamis could consider this as a bang (!) variant of the method. |
@jamis and @johnnyshields thank you, I appreciate the feedback! I see 3 paths forward with this issue:
After @jamis 's comment I modified the PR so that it attempts to implement option 2. I will need some assistance going through the test failures. |
@danhealy -- I agree that option 2 will be ideal. I'll take a look this afternoon/tomorrow and see what I can find regarding the failures, and what options we might have to fix those. Thanks for your work on this! |
This is okay, because the database_field_name method is a private API. We can change the contract here without regard for who else might be using it.
…se UnknownAttribute exception (mongodb#5836) * database_field_name given nil or empty string should raise UnknownAttribute exception * fix spec syntax * database_field_name return empty string instead of exception * `field` might be an empty string, not merely nil * fix specs to expect empty string instead of nil This is okay, because the database_field_name method is a private API. We can change the contract here without regard for who else might be using it. --------- Co-authored-by: Jamis Buck <[email protected]>
* MONGOID-5789 database_field_name given nil or empty string should raise UnknownAttribute exception (#5836) * database_field_name given nil or empty string should raise UnknownAttribute exception * fix spec syntax * database_field_name return empty string instead of exception * `field` might be an empty string, not merely nil * fix specs to expect empty string instead of nil This is okay, because the database_field_name method is a private API. We can change the contract here without regard for who else might be using it. --------- Co-authored-by: Jamis Buck <[email protected]> * see if we can update the permissions for the Ruby directories --------- Co-authored-by: Dan Healy <[email protected]>
From github discussion: #5540
We are seeing this behavior in 8.1.4
This PR changes the behavior to raise a more helpful
Mongoid::Errors::UnknownAttribute
exception instead