@@ -6,6 +6,7 @@ class SchemaTest < ActiveRecord::TestCase
6
6
SCHEMA_NAME = 'test_schema'
7
7
SCHEMA2_NAME = 'test_schema2'
8
8
TABLE_NAME = 'things'
9
+ CAPITALIZED_TABLE_NAME = 'Things'
9
10
INDEX_A_NAME = 'a_index_things_on_name'
10
11
INDEX_B_NAME = 'b_index_things_on_different_columns_in_each_schema'
11
12
INDEX_A_COLUMN = 'name'
@@ -30,10 +31,15 @@ class Thing3 < ActiveRecord::Base
30
31
set_table_name 'test_schema."things.table"'
31
32
end
32
33
34
+ class Thing4 < ActiveRecord ::Base
35
+ set_table_name 'test_schema."Things"'
36
+ end
37
+
33
38
def setup
34
39
@connection = ActiveRecord ::Base . connection
35
40
@connection . execute "CREATE SCHEMA #{ SCHEMA_NAME } CREATE TABLE #{ TABLE_NAME } (#{ COLUMNS . join ( ',' ) } )"
36
41
@connection . execute "CREATE TABLE #{ SCHEMA_NAME } .\" #{ TABLE_NAME } .table\" (#{ COLUMNS . join ( ',' ) } )"
42
+ @connection . execute "CREATE TABLE #{ SCHEMA_NAME } .\" #{ CAPITALIZED_TABLE_NAME } \" (#{ COLUMNS . join ( ',' ) } )"
37
43
@connection . execute "CREATE SCHEMA #{ SCHEMA2_NAME } CREATE TABLE #{ TABLE_NAME } (#{ COLUMNS . join ( ',' ) } )"
38
44
@connection . execute "CREATE INDEX #{ INDEX_A_NAME } ON #{ SCHEMA_NAME } .#{ TABLE_NAME } USING btree (#{ INDEX_A_COLUMN } );"
39
45
@connection . execute "CREATE INDEX #{ INDEX_A_NAME } ON #{ SCHEMA2_NAME } .#{ TABLE_NAME } USING btree (#{ INDEX_A_COLUMN } );"
@@ -52,6 +58,12 @@ def test_with_schema_prefixed_table_name
52
58
end
53
59
end
54
60
61
+ def test_with_schema_prefixed_capitalized_table_name
62
+ assert_nothing_raised do
63
+ assert_equal COLUMNS , columns ( "#{ SCHEMA_NAME } .#{ CAPITALIZED_TABLE_NAME } " )
64
+ end
65
+ end
66
+
55
67
def test_with_schema_search_path
56
68
assert_nothing_raised do
57
69
with_schema_search_path ( SCHEMA_NAME ) do
@@ -74,21 +86,31 @@ def test_classes_with_qualified_schema_name
74
86
assert_equal 0 , Thing1 . count
75
87
assert_equal 0 , Thing2 . count
76
88
assert_equal 0 , Thing3 . count
89
+ assert_equal 0 , Thing4 . count
77
90
78
91
Thing1 . create ( :id => 1 , :name => "thing1" , :email => "thing1@localhost" , :moment => Time . now )
79
92
assert_equal 1 , Thing1 . count
80
93
assert_equal 0 , Thing2 . count
81
94
assert_equal 0 , Thing3 . count
95
+ assert_equal 0 , Thing4 . count
82
96
83
97
Thing2 . create ( :id => 1 , :name => "thing1" , :email => "thing1@localhost" , :moment => Time . now )
84
98
assert_equal 1 , Thing1 . count
85
99
assert_equal 1 , Thing2 . count
86
100
assert_equal 0 , Thing3 . count
101
+ assert_equal 0 , Thing4 . count
87
102
88
103
Thing3 . create ( :id => 1 , :name => "thing1" , :email => "thing1@localhost" , :moment => Time . now )
89
104
assert_equal 1 , Thing1 . count
90
105
assert_equal 1 , Thing2 . count
91
106
assert_equal 1 , Thing3 . count
107
+ assert_equal 0 , Thing4 . count
108
+
109
+ Thing4 . create ( :id => 1 , :name => "thing1" , :email => "thing1@localhost" , :moment => Time . now )
110
+ assert_equal 1 , Thing1 . count
111
+ assert_equal 1 , Thing2 . count
112
+ assert_equal 1 , Thing3 . count
113
+ assert_equal 1 , Thing4 . count
92
114
end
93
115
94
116
def test_raise_on_unquoted_schema_name
0 commit comments