From f98ec352b65a00eae4ec541f1c90a6020576566e Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 30 Sep 2005 12:10:04 +0000 Subject: [PATCH] Get rid of old symbolize_strings_in_hash. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2427 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../abstract/connection_specification.rb | 7 +------ .../connection_adapters/mysql_adapter.rb | 4 +--- .../connection_adapters/postgresql_adapter.rb | 16 +++++++--------- 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 @@ def self.connection=(spec) 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 @@ def self.mysql_connection(config) # :nodoc: 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 - 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 @@ def native_database_types :time => { :name => "timestamp" }, :date => { :name => "date" }, :binary => { :name => "bytea" }, - :boolean => { :name => "boolean"} + :boolean => { :name => "boolean" } } end @@ -78,7 +76,7 @@ def supports_migrations? # 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 @@ def select_all(sql, name = nil) #:nodoc: 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 @@ def remove_index(table_name, options) #:nodoc: 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 -- GitLab