Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6061

Show
Ignore:
Timestamp:
01/28/07 07:58:02 (2 years ago)
Author:
bitsweat
Message:

Use Date#to_s(:db) for quoted dates. Closes #7411.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r6051 r6061  
    11*SVN* 
     2 
     3* Use Date#to_s(:db) for quoted dates.  #7411 [Michael Schoen] 
    24 
    35* Don't create instance writer methods for class attributes.  Closes #7401 [Rick] 
  • trunk/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb

    r5953 r6061  
    2626          when BigDecimal               then value.to_s('F') 
    2727          else 
    28             if value.acts_like?(:date) 
    29               "'#{value.to_s}'" 
    30             elsif value.acts_like?(:time) 
     28            if value.acts_like?(:date) || value.acts_like?(:time) 
    3129              "'#{quoted_date(value)}'" 
    3230            else 
     
    5149        "'t'" 
    5250      end 
    53        
     51 
    5452      def quoted_false 
    5553        "'f'" 
    5654      end 
    57        
     55 
    5856      def quoted_date(value) 
    59         value.strftime("%Y-%m-%d %H:%M:%S"
     57        value.to_s(:db
    6058      end 
    6159    end 
  • trunk/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb

    r5937 r6061  
    126126      end 
    127127 
     128      # Include microseconds if the value is a Time responding to usec. 
    128129      def quoted_date(value) 
    129         value.strftime("%Y-%m-%d %H:%M:%S.#{sprintf("%06d", value.usec)}") 
     130        if value.acts_like?(:time) && value.respond_to?(:usec) 
     131          "#{super}.#{sprintf("%06d", value.usec)}" 
     132        else 
     133          super 
     134        end 
    130135      end 
    131136