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

Changeset 4424

Show
Ignore:
Timestamp:
06/03/06 21:57:03 (2 years ago)
Author:
david
Message:

Fixed issues with BLOB limits, charsets, and booleans for Firebird (closes #5194, #5191, #5189) [kennethkunz@gmail.com]

Files:

Legend:

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

    r4422 r4424  
    11*SVN* 
     2 
     3* Fixed issues with BLOB limits, charsets, and booleans for Firebird #5194, #5191, #5189 [kennethkunz@gmail.com] 
    24 
    35* Fixed usage of :limit and with_scope when the association in scope is a 1:m #5208 [alex@purefiction.net] 
  • trunk/activerecord/lib/active_record/connection_adapters/firebird_adapter.rb

    r4421 r4424  
    55module FireRuby # :nodoc: all 
    66  class Database 
    7     def self.new_from_params(database, host, port, service) 
    8       db_string = "" 
    9       if host 
    10         db_string << host 
    11         db_string << "/#{service || port}" if service || port 
    12         db_string << ":" 
    13       end 
    14       db_string << database 
    15       new(db_string) 
     7    def self.new_from_params(database, host, port, service, charset) 
     8      host_string = [host, service, port].compact.first(2).join("/") if host 
     9      db_string = [host_string, database].join(":") 
     10      db = new(db_string) 
     11      db.character_set = charset 
     12      db 
    1613    end 
    1714  end 
     
    2724          'to be running an older version -- please update FireRuby (gem install fireruby).' 
    2825      end 
    29       config = config.symbolize_keys 
     26      config.symbolize_keys! 
    3027      unless config.has_key?(:database) 
    3128        raise ArgumentError, "No database specified. Missing argument: database." 
    3229      end 
    33       options = config[:charset] ? { CHARACTER_SET => config[:charset] } : {} 
    34       connection_params = [config[:username], config[:password], options] 
    35       db = FireRuby::Database.new_from_params(*config.values_at(:database, :host, :port, :service)
     30      db_params = config.values_at(:database, :host, :port, :service, :charset) 
     31      connection_params = config.values_at(:username, :password) 
     32      db = FireRuby::Database.new_from_params(*db_params
    3633      connection = db.connect(*connection_params) 
    3734      ConnectionAdapters::FirebirdAdapter.new(connection, logger, connection_params) 
     
    4845        super(name.downcase, nil, @firebird_type, !null_flag) 
    4946        @default = parse_default(default_source) if default_source 
    50         @limit = type == 'BLOB' ? BLOB_MAX_LENGTH : length 
     47        @limit = @firebird_type == 'BLOB' ? BLOB_MAX_LENGTH : length 
    5148        @domain, @sub_type, @precision, @scale = domain, sub_type, precision, scale 
    5249      end 
     
    7774      end 
    7875 
    79       def type_cast(value) 
    80         if type == :boolean 
    81           value == true or value == ActiveRecord::ConnectionAdapters::FirebirdAdapter.boolean_domain[:true] 
    82         else 
    83           super 
    84         end 
     76      def self.value_to_boolean(value) 
     77        %W(#{FirebirdAdapter.boolean_domain[:true]} true t 1).include? value.to_s.downcase 
    8578      end 
    8679 
  • trunk/activerecord/test/connections/native_firebird/connection.rb

    r3182 r4424  
    1313  :username => "rails", 
    1414  :password => "rails", 
    15   :database => db1 
     15  :database => db1, 
     16  :charset  => "UTF8" 
    1617) 
    1718