Open wenley opened 2 months ago
Hi! Thank you for letting us know!
We have changed the way we select models https://github.com/djezzzl/database_consistency/pull/232/files#diff-75ea970610cc52093dc977330caee9fe665e2a18c27de911808990d5d4ae4906R42
Could you please check the validity of the issues raised? If they are not valid, we probably should stop checking views and/or materialized views.
I tried my best, but the following seem not possible to implement for a view (at least for PostgreSQL):
ThreeStateBooleanChecker
, since a DB View cannot structurally guarantee a value is not nullColumnPresenceChecker
, for the same reasonForeignKeyChecker
, since views are not tables, and therefore cannot have Foreign Key checks implemented on themI would not be surprised if those also cannot be implemented for other SQL dialects.
Of the checks I listed above, MissingUniqueIndexChecker
correctly flagged an issue (yay and thank you!)
Interestingly, PrimaryKeyTypeChecker
was reporting a false positive, or at least an odd error message. We are using the result of an md5(...)
computation for the sales.uid
column, which has an output type of text
and not any numeric type.
Thank you! So, we should disable some of the checks for views.
Would you like to contribute?
When upgrading from v1.7.24 to v1.7.25, my team experienced a bunch of new violations flagged, specifically for our ActiveRecord models that are based on DB Views. This happened both for materialized and not-materialized Views.
Examples of newly flagged violations:
To be clear, I don't think these violations are necessarily incorrect to flag, but given the upgrade was only a patch version, we were surprised to see a bunch of new violations. We can work around this by disabling checks on these models and then fixing the issue incrementally.
As an FYI, we are using the scenic gem to help us manage the DB views, but I don't think that's relevant to the behavior change here.
We are running our Rails application with:
Let me know if there's any other info I can provide to help debug + test!