active_record_doctor icon indicating copy to clipboard operation
active_record_doctor copied to clipboard

missing_presence_validation: ignore counter cache columns

Open fatkodima opened this issue 1 year ago • 4 comments

This check produces false positives for counter cache columns. These are expected to be set by ActiveRecord, not by users.

fatkodima avatar Mar 29 '24 22:03 fatkodima

@gregnavis Can you please merge all the open PRs?

fatkodima avatar Aug 25 '24 13:08 fatkodima

Thanks for the nudge, @fatkodima! I won't merge them all today, as I'd like to see some changes made, but I definitely need to pay attention to the outstanding PRs. I left some comments on a few other PRs.

Here, I'm not sure what to do with older Rails versions. I think we'll drop 4.2 soon (I'm sure you'd love that decision!), but that would require a new major release.

For now, I suggest the following: Rails versions that fail in CI due to outdated APIs should:

  1. Show a warning to the user with the following content: "missing_presence_validation: counter cache columns will receive complaints about missing presence validations in Rails versions older than X.Y; you can add them to ignore_attributes"
  2. Skip counter cache detection for those older Rails versions.

@fatkodima, does that make sense?

gregnavis avatar Aug 26 '24 16:08 gregnavis

Sorry, I am lazy and will wait when you drop the old version.

Imo, you can easily drop activerecord < 7 and release v2 version of the gem. People on rails 4.2 don't care about best practices, so they are not the target audience of this gem.

fatkodima avatar Aug 26 '24 18:08 fatkodima

@fatkodima, you are not lazy at all! I totally understand supporting 4.2 is a total pain in the ass.

I marked this and a few other PRs for 2.0.

gregnavis avatar Aug 27 '24 16:08 gregnavis