Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActiveSupport::Duration sql quoting

#688

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

Reported by Boris Nadion · July 24th, 2008 @ 09:50 AM

State: stale
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Clemens Kofler
    Clemens Kofler

    Make it 1.minute.to_i and you should be fine.

    July 25th, 2008 @ 12:13 AM

  2. josh
    josh
    • State changed from new to stale

    Staling out, please reopen if this is still a problem.

    October 28th, 2008 @ 04:33 PM