-
Notifications
You must be signed in to change notification settings - Fork 28
reject queries that are not string #116
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
base: master
Are you sure you want to change the base?
reject queries that are not string #116
Conversation
If you pass an ActiveRecord::Relation, it will be executed when the call is analyzed for logging purposes, potentially timing out the migration.
|
Note: I haven't been able to execute the tests locally; there doesn't seem to be documentation on how to do that. I assume I need to configure a database somehow? |
| # SQL | ||
| # | ||
| def create_continuous_aggregate(table_name, query, **options) | ||
| raise ArgumentError, 'query must be a string' unless query.is_a?(String) |
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.
Just thinking about old migrations that are already in place.
| raise ArgumentError, 'query must be a string' unless query.is_a?(String) | |
| query = query.to_sql if query.respond_to(:to_sql) | |
| raise ArgumentError, 'query must be a string or implement the `to_sql` method ' unless query.is_a?(String) |
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.
You're right to think about backwards compatibility, but if I apply your changes then this PR fixes nothing.
The problem is caused by allowing people to pass an ActiveRecord::Relation as an input to create_continuous_aggregate.
If you want to preserve backwards compatibility for now, we could look into making it a warning instead of an exception.
jonatas
left a comment
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.
Thanks for the improvement @exterm !
Let's avoid breaking compatibility with the previous migrations and allow folks to continue using scopes for it.
If you pass an ActiveRecord::Relation, it will be executed when the call is analyzed for logging purposes, potentially timing out the migration.
Fix #115
I'm not quite sure why github id displaying my commit as unverified, it should be signed as usual.