aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-07-01 12:57:48 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-07-01 12:58:41 -0300
commitaafa00f4c10a6791e6470112f0f1fbe5f2c3f649 (patch)
treeeba2b5554545cc2a84933f443763a28d9f4c0a8f
parent36938b410e7c7396ee5934246fddc048b898f7ef (diff)
downloadrails-aafa00f4c10a6791e6470112f0f1fbe5f2c3f649.tar.gz
rails-aafa00f4c10a6791e6470112f0f1fbe5f2c3f649.tar.bz2
rails-aafa00f4c10a6791e6470112f0f1fbe5f2c3f649.zip
Unify the collation API for the database adpters
-rw-r--r--activerecord/CHANGELOG.md4
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb8
-rw-r--r--activerecord/lib/active_record/tasks/postgresql_database_tasks.rb2
-rw-r--r--activerecord/test/cases/adapters/postgresql/active_schema_test.rb4
-rw-r--r--activerecord/test/cases/adapters/postgresql/connection_test.rb4
-rw-r--r--activerecord/test/cases/tasks/postgresql_rake_test.rb8
6 files changed, 15 insertions, 15 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 73f9212371..84fffb3d17 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -16,7 +16,7 @@
*Brian Cardarella*
-* Add `collate` and `ctype` support to PostgreSQL. These are available for PostgreSQL 8.4 or later.
+* Add `collation` and `ctype` support to PostgreSQL. These are available for PostgreSQL 8.4 or later.
Example:
development:
@@ -26,7 +26,7 @@
username: foo
password: bar
encoding: UTF8
- collate: ja_JP.UTF8
+ collation: ja_JP.UTF8
ctype: ja_JP.UTF8
*kennyj*
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 507e937c3e..7b263fd62d 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -916,7 +916,7 @@ module ActiveRecord
end
# Create a new PostgreSQL database. Options include <tt>:owner</tt>, <tt>:template</tt>,
- # <tt>:encoding</tt>, <tt>:collate</tt>, <tt>:ctype</tt>,
+ # <tt>:encoding</tt>, <tt>:collation</tt>, <tt>:ctype</tt>,
# <tt>:tablespace</tt>, and <tt>:connection_limit</tt> (note that MySQL uses
# <tt>:charset</tt> while PostgreSQL uses <tt>:encoding</tt>).
#
@@ -934,7 +934,7 @@ module ActiveRecord
" TEMPLATE = \"#{value}\""
when :encoding
" ENCODING = '#{value}'"
- when :collate
+ when :collation
" LC_COLLATE = '#{value}'"
when :ctype
" LC_CTYPE = '#{value}'"
@@ -1064,8 +1064,8 @@ module ActiveRecord
end_sql
end
- # Returns the current database collate.
- def collate
+ # Returns the current database collation.
+ def collation
query(<<-end_sql, 'SCHEMA')[0][0]
SELECT pg_database.datcollate FROM pg_database WHERE pg_database.datname LIKE '#{current_database}'
end_sql
diff --git a/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb b/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb
index 4139460273..ea5cb888fb 100644
--- a/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb
+++ b/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb
@@ -30,7 +30,7 @@ module ActiveRecord
end
def collation
- connection.collate
+ connection.collation
end
def purge
diff --git a/activerecord/test/cases/adapters/postgresql/active_schema_test.rb b/activerecord/test/cases/adapters/postgresql/active_schema_test.rb
index 148584214e..113c27b194 100644
--- a/activerecord/test/cases/adapters/postgresql/active_schema_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/active_schema_test.rb
@@ -21,8 +21,8 @@ class PostgresqlActiveSchemaTest < ActiveRecord::TestCase
assert_equal %(CREATE DATABASE "aimonetti" ENCODING = 'latin1'), create_database(:aimonetti, :encoding => :latin1)
end
- def test_create_database_with_collate_and_ctype
- assert_equal %(CREATE DATABASE "aimonetti" ENCODING = 'UTF8' LC_COLLATE = 'ja_JP.UTF8' LC_CTYPE = 'ja_JP.UTF8'), create_database(:aimonetti, :encoding => :"UTF8", :collate => :"ja_JP.UTF8", :ctype => :"ja_JP.UTF8")
+ def test_create_database_with_collation_and_ctype
+ assert_equal %(CREATE DATABASE "aimonetti" ENCODING = 'UTF8' LC_COLLATE = 'ja_JP.UTF8' LC_CTYPE = 'ja_JP.UTF8'), create_database(:aimonetti, :encoding => :"UTF8", :collation => :"ja_JP.UTF8", :ctype => :"ja_JP.UTF8")
end
def test_add_index
diff --git a/activerecord/test/cases/adapters/postgresql/connection_test.rb b/activerecord/test/cases/adapters/postgresql/connection_test.rb
index 9b5c5eb72f..f823ce33d8 100644
--- a/activerecord/test/cases/adapters/postgresql/connection_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/connection_test.rb
@@ -21,8 +21,8 @@ module ActiveRecord
assert_not_nil @connection.encoding
end
- def test_collate
- assert_not_nil @connection.collate
+ def test_collation
+ assert_not_nil @connection.collation
end
def test_ctype
diff --git a/activerecord/test/cases/tasks/postgresql_rake_test.rb b/activerecord/test/cases/tasks/postgresql_rake_test.rb
index df1075d816..62acd53003 100644
--- a/activerecord/test/cases/tasks/postgresql_rake_test.rb
+++ b/activerecord/test/cases/tasks/postgresql_rake_test.rb
@@ -38,12 +38,12 @@ module ActiveRecord
merge('encoding' => 'latin')
end
- def test_creates_database_with_given_collate_and_ctype
+ def test_creates_database_with_given_collation_and_ctype
@connection.expects(:create_database).
- with('my-app-db', @configuration.merge('encoding' => 'utf8', 'collate' => 'ja_JP.UTF8', 'ctype' => 'ja_JP.UTF8'))
+ with('my-app-db', @configuration.merge('encoding' => 'utf8', 'collation' => 'ja_JP.UTF8', 'ctype' => 'ja_JP.UTF8'))
ActiveRecord::Tasks::DatabaseTasks.create @configuration.
- merge('collate' => 'ja_JP.UTF8', 'ctype' => 'ja_JP.UTF8')
+ merge('collation' => 'ja_JP.UTF8', 'ctype' => 'ja_JP.UTF8')
end
def test_establishes_connection_to_new_database
@@ -172,7 +172,7 @@ module ActiveRecord
end
def test_db_retrieves_collation
- @connection.expects(:collate)
+ @connection.expects(:collation)
ActiveRecord::Tasks::DatabaseTasks.collation @configuration
end
end