Skip to content
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

Does this gem recognize a find on a column without index? #174

Open
mak-dunkelziffer opened this issue Jan 2, 2023 · 4 comments
Open

Does this gem recognize a find on a column without index? #174

mak-dunkelziffer opened this issue Jan 2, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@mak-dunkelziffer
Copy link

mak-dunkelziffer commented Jan 2, 2023

From having a brief glance at the code, it seems like the gem doesn't analyze calls to #find and #find_by_<attribute>, but I might have missed something.

It would be really valuable to check, whether all those calls have an appropriate DB index on the corresponding column.

@djezzzl
Copy link
Owner

djezzzl commented Jan 3, 2023

Hi @mak-dunkelziffer,

This would indeed be a great feature! Please point me in the direction of how you think this should be implemented. Is it using some AST parser?

@djezzzl djezzzl added the enhancement New feature or request label Jan 3, 2023
@mak-dunkelziffer
Copy link
Author

Yes, I guess you would need to parse the whole source code for that. Before you start implementing that yourself, it might be worth to investigate, whether this would be easier to implement as an additional cop for Rubocop. Rubocop already parses everything, but I don't know, whether it is able to then compare the currently parsed file against the indexes from the schema.rb.

@djezzzl
Copy link
Owner

djezzzl commented Jan 12, 2023

Thank you for the suggestion, @mak-dunkelziffer! I will look into that.

BTW, would you like to contribute?

@toydestroyer
Copy link
Contributor

Not related to the topic, but since we are talking about AST here. It would be nice to have it as a part of DatabaseConsistency because we would finally be able to write autocorrections for checkers that requires model code changes.

Also, some cool GitHub Action would be possible that can point you to the line where you missed validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants