-
-
Notifications
You must be signed in to change notification settings - Fork 357
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
Add frozen_string_literal pragma to ruby files #305
Add frozen_string_literal pragma to ruby files #305
Conversation
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.
@swanandp, are you happy with this change? Is there a way to define this globally within our gem?
@@ -21,11 +23,11 @@ def self.define_class_methods(caller_class, position_column) | |||
end | |||
|
|||
define_singleton_method :decrement_all do | |||
update_all_with_touch "#{quoted_position_column} = (#{quoted_position_column_with_table_name} - 1)" | |||
update_all_with_touch "#{quoted_position_column} = (#{quoted_position_column_with_table_name} - 1)".dup |
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.
Sorry, I'm feeling dense today :) Can you explain why we need to dup the 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.
Here this string is concatenating with touch_record_sql
but one cannot change a frozen 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.
Could we instead unfreeze (.dup
?) updates
in:
update_all(updates.dup << touch_record_sql)
?
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.
In this case, we won't mutate updates
so maybe we can change it to concatenation?
update_all(updates + touch_record_sql)
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.
Yep, that't cleaner :)
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.
@brendon changed! :)
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 @krzysiek1507, I'll just wait on @swanandp's check and then we'll be GTG.
Thanks @krzysiek1507 :D |
49fb4f6
to
b4c478d
Compare
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.
👍, when TravisCI confirms this is backward compatible
TravisCI fails on Rails 5.2 and MySQL but it also fails on master. |
I just checked, Rails 5.2 is a different issue not related to this one. |
We seem to be having suite failures for Rails 5.2 and certain rubies. I think it might be to do with rake versions? or something like that. I don't have time to look into it this weekend, but if either of you two can that would be cool :) |
The problem is mysql2. It is old and doesn't work with Rails 5.2 but |
Ah yes, sorry I already had this fixed in a branch. I'm just running it through the suite with the latest from master then I'll merge it in. Once that's done, can you update from master and we'll see if the suite passes still :) |
Hi @brendon! I'll do it! :) |
@krzysiek1507 Can you update from master, then it should be all green :) |
b4c478d
to
7e02b81
Compare
@brendon all green! |
Thanks @krzysiek1507 :) Great job! |
Thank you! |
According to this blog post: https://www.mikeperham.com/2018/02/28/ruby-optimization-with-one-magic-comment/