提交 f98ec352 编写于 作者: J Jeremy Kemper

Get rid of old symbolize_strings_in_hash.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2427 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 ee5fe97a
......@@ -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
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]
......
# 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 @@ 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册