diff options
Diffstat (limited to 'activerecord/lib/active_record')
3 files changed, 9 insertions, 18 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb index be5be0fff4..caf4ba75de 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb @@ -118,10 +118,5 @@ module ActiveRecord conn = self.send(spec.adapter_method, spec.config) active_connections[self] = conn end - - # Converts all strings in a hash to symbols. - def self.symbolize_strings_in_hash(hash) #:nodoc: - hash.symbolize_keys - end end -end
\ No newline at end of file +end diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index c9c639bf5f..9f38dabdcc 100755 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -1,5 +1,4 @@ require 'active_record/connection_adapters/abstract_adapter' -require 'parsedate' module ActiveRecord class Base @@ -20,8 +19,7 @@ module ActiveRecord end end - symbolize_strings_in_hash(config) - + config = config.symbolize_keys host = config[:host] port = config[:port] socket = config[:socket] diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index cee3483e35..320ef2752b 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -1,14 +1,12 @@ -# Author: Luke Holden <lholden@cablelan.net> - require 'active_record/connection_adapters/abstract_adapter' -require 'parsedate' module ActiveRecord class Base # Establishes a connection to the database that's used by all Active Record objects def self.postgresql_connection(config) # :nodoc: require_library_or_gem 'postgres' unless self.class.const_defined?(:PGconn) - symbolize_strings_in_hash(config) + + config = config.symbolize_keys host = config[:host] port = config[:port] || 5432 unless host.nil? username = config[:username].to_s @@ -66,7 +64,7 @@ module ActiveRecord :time => { :name => "timestamp" }, :date => { :name => "date" }, :binary => { :name => "bytea" }, - :boolean => { :name => "boolean"} + :boolean => { :name => "boolean" } } end @@ -78,7 +76,7 @@ module ActiveRecord # QUOTING ================================================== def quote(value, column = nil) - if value.class == String && column && column.type == :binary + if value.kind_of?(String) && column && column.type == :binary "'#{escape_bytea(value)}'" else super @@ -98,13 +96,13 @@ module ActiveRecord def select_one(sql, name = nil) #:nodoc: result = select(sql, name) - result.nil? ? nil : result.first + result.first if result end def insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) #:nodoc: execute(sql, name) table = sql.split(" ", 4)[2] - return id_value || last_insert_id(table, pk) + id_value || last_insert_id(table, pk) end def query(sql, name = nil) #:nodoc: @@ -240,7 +238,7 @@ module ActiveRecord private BYTEA_COLUMN_TYPE_OID = 17 - def last_insert_id(table, column = "id") + def last_insert_id(table, column = nil) sequence_name = "#{table}_#{column || 'id'}_seq" @connection.exec("SELECT currval('#{sequence_name}')")[0][0].to_i end |