aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql/schema_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql/schema_test.rb')
-rw-r--r--activerecord/test/cases/adapters/postgresql/schema_test.rb88
1 files changed, 44 insertions, 44 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/schema_test.rb b/activerecord/test/cases/adapters/postgresql/schema_test.rb
index 52ef07f654..029314874e 100644
--- a/activerecord/test/cases/adapters/postgresql/schema_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/schema_test.rb
@@ -1,6 +1,6 @@
require "cases/helper"
-require 'models/default'
-require 'support/schema_dumping_helper'
+require "models/default"
+require "support/schema_dumping_helper"
module PGSchemaHelper
def with_schema_search_path(schema_search_path)
@@ -17,32 +17,32 @@ class SchemaTest < ActiveRecord::PostgreSQLTestCase
include PGSchemaHelper
self.use_transactional_tests = false
- SCHEMA_NAME = 'test_schema'
- SCHEMA2_NAME = 'test_schema2'
- TABLE_NAME = 'things'
- CAPITALIZED_TABLE_NAME = 'Things'
- INDEX_A_NAME = 'a_index_things_on_name'
- INDEX_B_NAME = 'b_index_things_on_different_columns_in_each_schema'
- INDEX_C_NAME = 'c_index_full_text_search'
- INDEX_D_NAME = 'd_index_things_on_description_desc'
- INDEX_E_NAME = 'e_index_things_on_name_vector'
- INDEX_A_COLUMN = 'name'
- INDEX_B_COLUMN_S1 = 'email'
- INDEX_B_COLUMN_S2 = 'moment'
+ SCHEMA_NAME = "test_schema"
+ SCHEMA2_NAME = "test_schema2"
+ TABLE_NAME = "things"
+ CAPITALIZED_TABLE_NAME = "Things"
+ INDEX_A_NAME = "a_index_things_on_name"
+ INDEX_B_NAME = "b_index_things_on_different_columns_in_each_schema"
+ INDEX_C_NAME = "c_index_full_text_search"
+ INDEX_D_NAME = "d_index_things_on_description_desc"
+ INDEX_E_NAME = "e_index_things_on_name_vector"
+ INDEX_A_COLUMN = "name"
+ INDEX_B_COLUMN_S1 = "email"
+ INDEX_B_COLUMN_S2 = "moment"
INDEX_C_COLUMN = %q{(to_tsvector('english', coalesce(things.name, '')))}
- INDEX_D_COLUMN = 'description'
- INDEX_E_COLUMN = 'name_vector'
+ INDEX_D_COLUMN = "description"
+ INDEX_E_COLUMN = "name_vector"
COLUMNS = [
- 'id integer',
- 'name character varying(50)',
- 'email character varying(50)',
- 'description character varying(100)',
- 'name_vector tsvector',
- 'moment timestamp without time zone default now()'
+ "id integer",
+ "name character varying(50)",
+ "email character varying(50)",
+ "description character varying(100)",
+ "name_vector tsvector",
+ "moment timestamp without time zone default now()"
]
- PK_TABLE_NAME = 'table_with_pk'
- UNMATCHED_SEQUENCE_NAME = 'unmatched_primary_key_default_value_seq'
- UNMATCHED_PK_TABLE_NAME = 'table_with_unmatched_sequence_for_pk'
+ PK_TABLE_NAME = "table_with_pk"
+ UNMATCHED_SEQUENCE_NAME = "unmatched_primary_key_default_value_seq"
+ UNMATCHED_PK_TABLE_NAME = "table_with_unmatched_sequence_for_pk"
class Thing1 < ActiveRecord::Base
self.table_name = "test_schema.things"
@@ -61,7 +61,7 @@ class SchemaTest < ActiveRecord::PostgreSQLTestCase
end
class Thing5 < ActiveRecord::Base
- self.table_name = 'things'
+ self.table_name = "things"
end
class Song < ActiveRecord::Base
@@ -168,21 +168,21 @@ class SchemaTest < ActiveRecord::PostgreSQLTestCase
def test_raise_wrapped_exception_on_bad_prepare
assert_raises(ActiveRecord::StatementInvalid) do
- @connection.exec_query "select * from developers where id = ?", 'sql', [bind_param(1)]
+ @connection.exec_query "select * from developers where id = ?", "sql", [bind_param(1)]
end
end
if ActiveRecord::Base.connection.prepared_statements
def test_schema_change_with_prepared_stmt
altered = false
- @connection.exec_query "select * from developers where id = $1", 'sql', [bind_param(1)]
- @connection.exec_query "alter table developers add column zomg int", 'sql', []
+ @connection.exec_query "select * from developers where id = $1", "sql", [bind_param(1)]
+ @connection.exec_query "alter table developers add column zomg int", "sql", []
altered = true
- @connection.exec_query "select * from developers where id = $1", 'sql', [bind_param(1)]
+ @connection.exec_query "select * from developers where id = $1", "sql", [bind_param(1)]
ensure
# We are not using DROP COLUMN IF EXISTS because that syntax is only
# supported by pg 9.X
- @connection.exec_query("alter table developers drop column zomg", 'sql', []) if altered
+ @connection.exec_query("alter table developers drop column zomg", "sql", []) if altered
end
end
@@ -200,7 +200,7 @@ class SchemaTest < ActiveRecord::PostgreSQLTestCase
end
def test_data_source_exists_when_not_on_schema_search_path
- with_schema_search_path('PUBLIC') do
+ with_schema_search_path("PUBLIC") do
assert(!@connection.data_source_exists?(TABLE_NAME), "data_source exists but should not be found")
end
end
@@ -246,9 +246,9 @@ class SchemaTest < ActiveRecord::PostgreSQLTestCase
end
def test_proper_encoding_of_table_name
- assert_equal '"table_name"', @connection.quote_table_name('table_name')
+ assert_equal '"table_name"', @connection.quote_table_name("table_name")
assert_equal '"table.name"', @connection.quote_table_name('"table.name"')
- assert_equal '"schema_name"."table_name"', @connection.quote_table_name('schema_name.table_name')
+ assert_equal '"schema_name"."table_name"', @connection.quote_table_name("schema_name.table_name")
assert_equal '"schema_name"."table.name"', @connection.quote_table_name('schema_name."table.name"')
assert_equal '"schema.name"."table_name"', @connection.quote_table_name('"schema.name".table_name')
assert_equal '"schema.name"."table.name"', @connection.quote_table_name('"schema.name"."table.name"')
@@ -287,7 +287,7 @@ class SchemaTest < ActiveRecord::PostgreSQLTestCase
def test_raise_on_unquoted_schema_name
assert_raises(ActiveRecord::StatementInvalid) do
- with_schema_search_path '$user,public'
+ with_schema_search_path "$user,public"
end
end
@@ -307,7 +307,7 @@ class SchemaTest < ActiveRecord::PostgreSQLTestCase
assert @connection.index_name_exists?(TABLE_NAME, INDEX_D_NAME, true)
assert @connection.index_name_exists?(TABLE_NAME, INDEX_E_NAME, true)
assert @connection.index_name_exists?(TABLE_NAME, INDEX_E_NAME, true)
- assert_not @connection.index_name_exists?(TABLE_NAME, 'missing_index', true)
+ assert_not @connection.index_name_exists?(TABLE_NAME, "missing_index", true)
end
end
@@ -356,13 +356,13 @@ class SchemaTest < ActiveRecord::PostgreSQLTestCase
%(#{SCHEMA_NAME}."#{PK_TABLE_NAME}"),
%(#{SCHEMA_NAME}.#{PK_TABLE_NAME})
].each do |given|
- assert_equal 'id', @connection.primary_key(given), "primary key should be found when table referenced as #{given}"
+ assert_equal "id", @connection.primary_key(given), "primary key should be found when table referenced as #{given}"
end
end
def test_primary_key_assuming_schema_search_path
with_schema_search_path(SCHEMA_NAME) do
- assert_equal 'id', @connection.primary_key(PK_TABLE_NAME), "primary key should be found"
+ assert_equal "id", @connection.primary_key(PK_TABLE_NAME), "primary key should be found"
end
end
@@ -381,7 +381,7 @@ class SchemaTest < ActiveRecord::PostgreSQLTestCase
%("#{SCHEMA_NAME}"."#{UNMATCHED_PK_TABLE_NAME}")
].each do |given|
pk, seq = @connection.pk_and_sequence_for(given)
- assert_equal 'id', pk, "primary key should be found when table referenced as #{given}"
+ assert_equal "id", pk, "primary key should be found when table referenced as #{given}"
assert_equal pg_name.new(SCHEMA_NAME, "#{PK_TABLE_NAME}_id_seq"), seq, "sequence name should be found when table referenced as #{given}" if given == %("#{SCHEMA_NAME}"."#{PK_TABLE_NAME}")
assert_equal pg_name.new(SCHEMA_NAME, UNMATCHED_SEQUENCE_NAME), seq, "sequence name should be found when table referenced as #{given}" if given == %("#{SCHEMA_NAME}"."#{UNMATCHED_PK_TABLE_NAME}")
end
@@ -389,10 +389,10 @@ class SchemaTest < ActiveRecord::PostgreSQLTestCase
def test_current_schema
{
- %('$user',public) => 'public',
+ %('$user',public) => "public",
SCHEMA_NAME => SCHEMA_NAME,
%(#{SCHEMA2_NAME},#{SCHEMA_NAME},public) => SCHEMA2_NAME,
- %(public,#{SCHEMA2_NAME},#{SCHEMA_NAME}) => 'public'
+ %(public,#{SCHEMA2_NAME},#{SCHEMA_NAME}) => "public"
}.each do |given,expect|
with_schema_search_path(given) { assert_equal expect, @connection.current_schema }
end
@@ -414,10 +414,10 @@ class SchemaTest < ActiveRecord::PostgreSQLTestCase
def test_schema_exists?
{
- 'public' => true,
+ "public" => true,
SCHEMA_NAME => true,
SCHEMA2_NAME => true,
- 'darkside' => false
+ "darkside" => false
}.each do |given,expect|
assert_equal expect, @connection.schema_exists?(given)
end
@@ -442,7 +442,7 @@ class SchemaTest < ActiveRecord::PostgreSQLTestCase
private
def columns(table_name)
@connection.send(:column_definitions, table_name).map do |name, type, default|
- "#{name} #{type}" + (default ? " default #{default}" : '')
+ "#{name} #{type}" + (default ? " default #{default}" : "")
end
end