-
Notifications
You must be signed in to change notification settings - Fork 1
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
Turn off enforcement of not-null db validations requiring default values #29
Conversation
This is something I'd definitely like to see discussion on. I can definitely see a case (which should be avoided at all costs) where someone has to write a crazy data migration rake task because records, where the default value was intended vs it's there just because it's the default, are totally indistinguishable. Default values are super useful if the business logic of an app necessitates one, and the default value itself is reasonable, but I'm not so sure about it being required. Would love to hear more thoughts on this though. |
Yeah of the PRs I have open now I think this one should get the most discussion. I'm not sold on this stance but I think it's worth considering... my thought has been that business logic constraints should live in the model, not the db, so if you do need a default value you should set it there instead. |
I can go either way on what we suggest for enforcement here. I can see both sides, but for some thoughts:
|
I'm in favor of this change. I like the Rubocop cops that should always be part of our code style. In this case, since there are valid situations where you would not want a default value I don't think we should have Rubocop insist that one should be provided. That could in turn influence an engineer to provide a default value when one shouldn't be there which can have unintended consequences and would be difficult for a reviewer without a ton of context to catch. |
If that's all we want to use, then we should probably turn almost every setting off, because valid exceptions run abound. |
Maybe there's a misunderstanding between always part of our code style and always adhered to. For example, I like the code style regarding line length. However, I find that it isn't always a good idea to adhere to this style, especially in test files. Maybe that cop can be configured to ignore test files but that's another story. As it is, I think there's value to Rubocop pointing out when lines go beyond a certain length. I don't feel the same way about this cop because in some scenarios adding a default value is wrong. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apalmer0 can you rebase this so we can merge it in?
21a1438
to
edda06f
Compare
(not so great) documentation
I don't know if people agree with this but I think I'd rather a save fail if a value is null rather than succeed by saving some arbitrary default value.