This project is archived and is in readonly mode.

#688 ✓stale
Boris Nadion

ActiveSupport::Duration sql quoting

Reported by Boris Nadion | July 24th, 2008 @ 09:50 AM | in 2.x

ActiveRecord::Base.connection.quote(1.minute) returns quoted yaml instead of quoted fixnum, that leads to wrong query generation, for example: User.find(:all, :conditions => ["some_value < ?", 1..minute]) will generate:

SELECT * FROM `users` WHERE (some_value < '--- 60\n')

instead of:

SELECT * FROM `users` WHERE (some_value < 60)

Temporary solution:

module ActiveRecord
  module ConnectionAdapters
    module Quoting
      
      def quote_with_active_support_duration(value, column = nil)
        return value.quoted_id if value.respond_to?(:quoted_id)
        if value.is_a? ActiveSupport::Duration
          value.to_i
        else
          quote_without_active_support_duration(value, column)
        end
      end
      alias_method_chain :quote, :active_support_duration
    end
  end
end

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages