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

warning: too many arguments for format string #239

Closed
brendon opened this issue Nov 15, 2016 · 0 comments
Closed

warning: too many arguments for format string #239

brendon opened this issue Nov 15, 2016 · 0 comments
Assignees

Comments

@brendon
Copy link
Owner

brendon commented Nov 15, 2016

These warnings are popping up in the tests and I've isolated it to this method:

      define_singleton_method :update_all_with_touch do |updates|
        record = new
        attrs = record.send(:timestamp_attributes_for_update_in_model)
        now = record.send(:current_time_from_proper_timezone)

        query = attrs.map { |attr| "#{connection.quote_column_name(attr)} = :now" }
        query.push updates
        query = query.join(", ")

        update_all([query, now: now])
      end

Basically we end up with multiple copies of :now in the string but are only passing the one now: now into the update_all. I believe this might be a deeper rails bug but we could alleviate it possibly by naming each :now uniquely and passing all of those now's by name in as a hash.

Alternatively, is there a way to do all of this without resorting to string concatenation? Can't we build up the query as a hash and pass it in?

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

No branches or pull requests

3 participants