Comments (5)
Hi there ๐
First, thank you both for using the gem and reporting the issue!
The idea that @chaadow has suggested seems reasonable here. Even though it may bring false positives (in cases with custom if: :something
), at least we will have less noise now. Also, it's worth adding that covering this case is "nice to have" rather than a critical issue (like missing unique indexes).
There is also a way to patch ActiveRecord to "mark" those presence validators with this optimized "if" condition. As the database_consistency
runner is expected to run as a separate process on demand, we can do that without affecting other environments (development/production/test, etc). However, maintaining it could be slightly more complicated and unwelcome.
With that said, I would go with this proposal by chaadow.
Would you mind creating a PR? I would be happy to merge it and release it ASAP.
P.S. It would be good to add one more check to your condition that the ActiveRecord's version is 7.1+
P.P.S. And again, thank you, @chaadow and @agrobbin! Sorry for being late.
from database_consistency.
Released in 1.7.21!
Thank you again! Have a great week!
from database_consistency.
@djezzzl @agrobbin I made this little "quick fix" which made all my belongs_to pass with rails 7.1 defaults
chaadow@2270738
haven't tested backward compatibility. but if you can take a look maybe I can create a PR with this change
from database_consistency.
HI @djezzzl Unfortunately this checker fails in rails 7.1 ( which was released about a week ago )
from database_consistency.
At first glance it seems like a reasonable guess, but I'll defer to @djezzzl here, as I'm not sure if that's "safe enough".
from database_consistency.
Related Issues (20)
- Excluding Database Connections to Non Primary Databases Including sqlserver HOT 2
- Ensure that generated todo files are created with consistent ordering HOT 6
- MissingIndexChecker violation on polymorphic association HOT 3
- ForeignKeyCascadeChecker default mapping HOT 3
- "undefined method `null' for nil:NilClass" in column_presence_checker.rb:54 HOT 7
- UniqueIndexChecker and postgresql partial indexes HOT 1
- Extendable database_consistency HOT 5
- Checker for implicit_order_column for table with uuid as primary key HOT 8
- False-positive when index columns are defined as a string and not array HOT 4
- ActiveRecord 7.0.5 internal error HOT 3
- MissingAssociationClassChecker fails with `undefined method klass for nil:NilClass` HOT 4
- undefined method `split' for nil:NilClass HOT 2
- Error when running ForeignKeyCascadeChecker HOT 1
- Add a file extension to debug output HOT 3
- Improve Documentation to describe how to work with indexes
- Error in NullConstraintChecker and other checkers
- Database_ัonsistency Gem Does Not Detect Some Validations HOT 2
- `MissingUniqueIndexChecker` autocorrect is wrong when column is a function
- Error on on length check
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from database_consistency.