aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2008-07-16 17:45:28 -0500
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-07-16 17:45:28 -0500
commit73ade4fe100ae7f48c5f95dcdf7067f6a0cd51fa (patch)
tree2f1601292978a844226e16f3cef428ed760b9eb5 /activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
parent8fe01de2e8753d045408ecde3178ab4e9192bf9a (diff)
parent90c930f45c5c6766306929241462ffff8f67b86e (diff)
downloadrails-73ade4fe100ae7f48c5f95dcdf7067f6a0cd51fa.tar.gz
rails-73ade4fe100ae7f48c5f95dcdf7067f6a0cd51fa.tar.bz2
rails-73ade4fe100ae7f48c5f95dcdf7067f6a0cd51fa.zip
Resolved conflict
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 2e2d50ccf4..6a20f41a4b 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -49,7 +49,6 @@ module ActiveRecord
private
def extract_limit(sql_type)
case sql_type
- when /^integer/i; 4
when /^bigint/i; 8
when /^smallint/i; 2
else super
@@ -623,6 +622,19 @@ module ActiveRecord
end
end
+ # Returns the current database name.
+ def current_database
+ query('select current_database()')[0][0]
+ end
+
+ # Returns the current database encoding format.
+ def encoding
+ query(<<-end_sql)[0][0]
+ SELECT pg_encoding_to_char(pg_database.encoding) FROM pg_database
+ WHERE pg_database.datname LIKE '#{current_database}'
+ end_sql
+ end
+
# Sets the schema search path to a string of comma-separated schema names.
# Names beginning with $ have to be quoted (e.g. $user => '$user').
# See: http://www.postgresql.org/docs/current/static/ddl-schemas.html
@@ -855,7 +867,7 @@ module ActiveRecord
end
private
- # The internal PostgreSQL identifer of the money data type.
+ # The internal PostgreSQL identifier of the money data type.
MONEY_COLUMN_TYPE_OID = 790 #:nodoc:
# Connects to a PostgreSQL server and sets up the adapter depending on the