activerecord-oracle_enhanced-adapter 1.3.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +0 -2
- data/History.txt +19 -0
- data/README.md +378 -0
- data/RUNNING_TESTS.md +45 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/activerecord-oracle_enhanced-adapter.gemspec +6 -9
- data/lib/active_record/connection_adapters/oracle_enhanced.rake +34 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +209 -57
- data/lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb +22 -1
- data/lib/active_record/connection_adapters/oracle_enhanced_column.rb +17 -3
- data/lib/active_record/connection_adapters/oracle_enhanced_context_index.rb +19 -3
- data/lib/active_record/connection_adapters/oracle_enhanced_jdbc_connection.rb +75 -17
- data/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb +41 -2
- data/lib/active_record/connection_adapters/oracle_enhanced_procedures.rb +3 -3
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_definitions.rb +40 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_dumper.rb +10 -3
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb +49 -10
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements_ext.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced_structure_dump.rb +54 -54
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +33 -5
- data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +66 -5
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +162 -13
- data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +1 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +1 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +43 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +150 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +5 -4
- data/spec/spec_helper.rb +3 -1
- metadata +38 -52
- data/README.rdoc +0 -89
- data/RUNNING_TESTS.rdoc +0 -28
@@ -78,6 +78,7 @@ describe "OracleEnhancedAdapter context index" do
|
|
78
78
|
after(:all) do
|
79
79
|
drop_table_posts
|
80
80
|
Object.send(:remove_const, "Post")
|
81
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
81
82
|
end
|
82
83
|
|
83
84
|
after(:each) do
|
@@ -157,6 +158,17 @@ describe "OracleEnhancedAdapter context index" do
|
|
157
158
|
Post.contains(:title, "ACE").all.should == [@post]
|
158
159
|
@conn.remove_context_index :posts, :title
|
159
160
|
end
|
161
|
+
|
162
|
+
it "should create transactional index and sync index within transaction on inserts and updates" do
|
163
|
+
@conn.add_context_index :posts, :title, :transactional => true
|
164
|
+
Post.transaction do
|
165
|
+
@post = Post.create(:title => "abc")
|
166
|
+
Post.contains(:title, "abc").all.should == [@post]
|
167
|
+
@post.update_attributes!(:title => "ghi")
|
168
|
+
Post.contains(:title, "ghi").all.should == [@post]
|
169
|
+
end
|
170
|
+
@conn.remove_context_index :posts, :title
|
171
|
+
end
|
160
172
|
end
|
161
173
|
|
162
174
|
describe "on multiple tables" do
|
@@ -176,6 +188,7 @@ describe "OracleEnhancedAdapter context index" do
|
|
176
188
|
drop_tables
|
177
189
|
Object.send(:remove_const, "Comment")
|
178
190
|
Object.send(:remove_const, "Post")
|
191
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
179
192
|
end
|
180
193
|
|
181
194
|
after(:each) do
|
@@ -200,6 +213,28 @@ describe "OracleEnhancedAdapter context index" do
|
|
200
213
|
@conn.remove_context_index :posts, :name => 'post_and_comments_index'
|
201
214
|
end
|
202
215
|
|
216
|
+
it "should create multiple table index with specified main index column (when subquery has newlines)" do
|
217
|
+
@conn.add_context_index :posts,
|
218
|
+
[:title, :body,
|
219
|
+
# specify aliases always with AS keyword
|
220
|
+
%{ SELECT
|
221
|
+
comments.author AS comment_author,
|
222
|
+
comments.body AS comment_body
|
223
|
+
FROM comments
|
224
|
+
WHERE comments.post_id = :id }
|
225
|
+
],
|
226
|
+
:name => 'post_and_comments_index',
|
227
|
+
:index_column => :all_text, :index_column_trigger_on => [:updated_at, :comments_count],
|
228
|
+
:sync => 'ON COMMIT'
|
229
|
+
@post = Post.create!(:title => "aaa", :body => "bbb")
|
230
|
+
@post.comments.create!(:author => "ccc", :body => "ddd")
|
231
|
+
@post.comments.create!(:author => "eee", :body => "fff")
|
232
|
+
["aaa", "bbb", "ccc", "ddd", "eee", "fff"].each do |word|
|
233
|
+
Post.contains(:all_text, word).all.should == [@post]
|
234
|
+
end
|
235
|
+
@conn.remove_context_index :posts, :name => 'post_and_comments_index'
|
236
|
+
end
|
237
|
+
|
203
238
|
it "should find by search term within specified field" do
|
204
239
|
@post = Post.create!(:title => "aaa", :body => "bbb")
|
205
240
|
@post.comments.create!(:author => "ccc", :body => "ddd")
|
@@ -238,6 +273,7 @@ describe "OracleEnhancedAdapter context index" do
|
|
238
273
|
after(:all) do
|
239
274
|
drop_table_posts
|
240
275
|
Object.send(:remove_const, "Post")
|
276
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
241
277
|
end
|
242
278
|
|
243
279
|
after(:each) do
|
@@ -303,13 +339,38 @@ describe "OracleEnhancedAdapter context index" do
|
|
303
339
|
options = {
|
304
340
|
:name => 'post_and_comments_index',
|
305
341
|
:index_column => :all_text, :index_column_trigger_on => :updated_at,
|
342
|
+
:transactional => true,
|
343
|
+
:sync => 'ON COMMIT'
|
344
|
+
}
|
345
|
+
sub_query = "SELECT comments.author AS comment_author, comments.body AS comment_body FROM comments WHERE comments.post_id = :id"
|
346
|
+
@conn.add_context_index :posts, [:title, :body, sub_query], options
|
347
|
+
standard_dump.should =~ /add_context_index "posts", \[:title, :body, "#{sub_query}"\], #{options.inspect[1..-2]}$/
|
348
|
+
@conn.remove_context_index :posts, :name => 'post_and_comments_index'
|
349
|
+
end
|
350
|
+
|
351
|
+
it "should dump definition of multiple table index with options (when definition is larger than 4000 bytes)" do
|
352
|
+
options = {
|
353
|
+
:name => 'post_and_comments_index',
|
354
|
+
:index_column => :all_text, :index_column_trigger_on => :updated_at,
|
355
|
+
:transactional => true,
|
356
|
+
:sync => 'ON COMMIT'
|
357
|
+
}
|
358
|
+
sub_query = "SELECT comments.author AS comment_author, comments.body AS comment_body FROM comments WHERE comments.post_id = :id#{' AND 1=1' * 500}"
|
359
|
+
@conn.add_context_index :posts, [:title, :body, sub_query], options
|
360
|
+
standard_dump.should =~ /add_context_index "posts", \[:title, :body, "#{sub_query}"\], #{options.inspect[1..-2]}$/
|
361
|
+
@conn.remove_context_index :posts, :name => 'post_and_comments_index'
|
362
|
+
end
|
363
|
+
|
364
|
+
it "should dump definition of multiple table index with options (when subquery has newlines)" do
|
365
|
+
options = {
|
366
|
+
:name => 'post_and_comments_index',
|
367
|
+
:index_column => :all_text, :index_column_trigger_on => :updated_at,
|
368
|
+
:transactional => true,
|
306
369
|
:sync => 'ON COMMIT'
|
307
370
|
}
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
], options
|
312
|
-
standard_dump.should =~ /add_context_index "posts", \[:title, :body, "SELECT comments.author AS comment_author, comments.body AS comment_body FROM comments WHERE comments.post_id = :id"\], #{options.inspect[1..-2]}$/
|
371
|
+
sub_query = "SELECT comments.author AS comment_author, comments.body AS comment_body\nFROM comments\nWHERE comments.post_id = :id"
|
372
|
+
@conn.add_context_index :posts, [:title, :body, sub_query], options
|
373
|
+
standard_dump.should =~ /add_context_index "posts", \[:title, :body, "#{sub_query.gsub(/\n/, ' ')}"\], #{options.inspect[1..-2]}$/
|
313
374
|
@conn.remove_context_index :posts, :name => 'post_and_comments_index'
|
314
375
|
end
|
315
376
|
|
@@ -107,6 +107,7 @@ describe "OracleEnhancedAdapter date type detection based on column names" do
|
|
107
107
|
# @employee.destroy if @employee
|
108
108
|
Object.send(:remove_const, "TestEmployee")
|
109
109
|
@conn.clear_types_for_columns
|
110
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
110
111
|
end
|
111
112
|
|
112
113
|
it "should return Time value from DATE column if emulate_dates_by_column_name is false" do
|
@@ -191,6 +192,7 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
|
|
191
192
|
before(:all) do
|
192
193
|
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
193
194
|
@conn = ActiveRecord::Base.connection
|
195
|
+
@conn.execute "DROP TABLE test2_employees" rescue nil
|
194
196
|
@conn.execute <<-SQL
|
195
197
|
CREATE TABLE test2_employees (
|
196
198
|
id NUMBER PRIMARY KEY,
|
@@ -208,6 +210,7 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
|
|
208
210
|
created_at DATE
|
209
211
|
)
|
210
212
|
SQL
|
213
|
+
@conn.execute "DROP SEQUENCE test2_employees_seq" rescue nil
|
211
214
|
@conn.execute <<-SQL
|
212
215
|
CREATE SEQUENCE test2_employees_seq MINVALUE 1
|
213
216
|
INCREMENT BY 1 START WITH 10040 CACHE 20 NOORDER NOCYCLE
|
@@ -266,6 +269,7 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
|
|
266
269
|
Object.send(:remove_const, "Test2Employee")
|
267
270
|
@conn.clear_types_for_columns
|
268
271
|
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans = true
|
272
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
269
273
|
end
|
270
274
|
|
271
275
|
def create_employee2
|
@@ -445,6 +449,7 @@ describe "OracleEnhancedAdapter boolean type detection based on string column ty
|
|
445
449
|
after(:each) do
|
446
450
|
Object.send(:remove_const, "Test3Employee")
|
447
451
|
@conn.clear_types_for_columns
|
452
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
448
453
|
end
|
449
454
|
|
450
455
|
def create_employee3(params={})
|
@@ -564,6 +569,7 @@ describe "OracleEnhancedAdapter timestamp with timezone support" do
|
|
564
569
|
|
565
570
|
after(:all) do
|
566
571
|
Object.send(:remove_const, "TestEmployee")
|
572
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
567
573
|
end
|
568
574
|
|
569
575
|
it "should return Time value from TIMESTAMP columns" do
|
@@ -647,6 +653,7 @@ describe "OracleEnhancedAdapter date and timestamp with different NLS date forma
|
|
647
653
|
|
648
654
|
after(:each) do
|
649
655
|
Object.send(:remove_const, "TestEmployee")
|
656
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
650
657
|
end
|
651
658
|
|
652
659
|
def create_test_employee
|
@@ -742,6 +749,7 @@ describe "OracleEnhancedAdapter assign string to :date and :datetime columns" do
|
|
742
749
|
Object.send(:remove_const, "TestEmployee")
|
743
750
|
@conn.execute "DROP TABLE test_employees"
|
744
751
|
@conn.execute "DROP SEQUENCE test_employees_seq"
|
752
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
745
753
|
end
|
746
754
|
|
747
755
|
before(:each) do
|
@@ -862,7 +870,7 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
|
|
862
870
|
@conn = ActiveRecord::Base.connection
|
863
871
|
@conn.execute <<-SQL
|
864
872
|
CREATE TABLE test_employees (
|
865
|
-
|
873
|
+
id NUMBER(6,0) PRIMARY KEY,
|
866
874
|
first_name VARCHAR2(20),
|
867
875
|
last_name VARCHAR2(25),
|
868
876
|
comments CLOB
|
@@ -872,28 +880,39 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
|
|
872
880
|
CREATE SEQUENCE test_employees_seq MINVALUE 1
|
873
881
|
INCREMENT BY 1 CACHE 20 NOORDER NOCYCLE
|
874
882
|
SQL
|
883
|
+
@conn.execute <<-SQL
|
884
|
+
CREATE TABLE test2_employees (
|
885
|
+
id NUMBER(6,0) PRIMARY KEY,
|
886
|
+
first_name VARCHAR2(20),
|
887
|
+
last_name VARCHAR2(25),
|
888
|
+
comments CLOB
|
889
|
+
)
|
890
|
+
SQL
|
891
|
+
@conn.execute <<-SQL
|
892
|
+
CREATE SEQUENCE test2_employees_seq MINVALUE 1
|
893
|
+
INCREMENT BY 1 CACHE 20 NOORDER NOCYCLE
|
894
|
+
SQL
|
875
895
|
@char_data = (0..127).to_a.pack("C*") * 800
|
876
896
|
@char_data2 = ((1..127).to_a.pack("C*") + "\0") * 800
|
877
|
-
end
|
878
|
-
|
879
|
-
after(:all) do
|
880
|
-
@conn.execute "DROP TABLE test_employees"
|
881
|
-
@conn.execute "DROP SEQUENCE test_employees_seq"
|
882
|
-
end
|
883
897
|
|
884
|
-
|
885
|
-
class ::
|
886
|
-
|
898
|
+
class ::TestEmployee < ActiveRecord::Base; end
|
899
|
+
class ::Test2Employee < ActiveRecord::Base
|
900
|
+
serialize :comments
|
887
901
|
end
|
888
902
|
end
|
889
903
|
|
890
|
-
after(:
|
904
|
+
after(:all) do
|
905
|
+
@conn.execute "DROP TABLE test_employees"
|
906
|
+
@conn.execute "DROP SEQUENCE test_employees_seq"
|
907
|
+
@conn.execute "DROP TABLE test2_employees"
|
908
|
+
@conn.execute "DROP SEQUENCE test2_employees_seq"
|
891
909
|
Object.send(:remove_const, "TestEmployee")
|
910
|
+
Object.send(:remove_const, "Test2Employee")
|
911
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
892
912
|
end
|
893
913
|
|
894
914
|
it "should create record without CLOB data when attribute is serialized" do
|
895
|
-
|
896
|
-
@employee = TestEmployee.create!(
|
915
|
+
@employee = Test2Employee.create!(
|
897
916
|
:first_name => "First",
|
898
917
|
:last_name => "Last"
|
899
918
|
)
|
@@ -989,6 +1008,7 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
|
|
989
1008
|
:comments => ''
|
990
1009
|
)
|
991
1010
|
@employee.reload
|
1011
|
+
@employee.comments.should == ''
|
992
1012
|
@employee.comments = @char_data
|
993
1013
|
@employee.save!
|
994
1014
|
@employee.reload
|
@@ -1029,6 +1049,7 @@ describe "OracleEnhancedAdapter handling of BLOB columns" do
|
|
1029
1049
|
|
1030
1050
|
after(:each) do
|
1031
1051
|
Object.send(:remove_const, "TestEmployee")
|
1052
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
1032
1053
|
end
|
1033
1054
|
|
1034
1055
|
it "should create record with BLOB data" do
|
@@ -1107,6 +1128,132 @@ describe "OracleEnhancedAdapter handling of BLOB columns" do
|
|
1107
1128
|
end
|
1108
1129
|
|
1109
1130
|
it "should update record that has zero-length BLOB data with non-empty BLOB data" do
|
1131
|
+
@employee = TestEmployee.create!(
|
1132
|
+
:first_name => "First",
|
1133
|
+
:last_name => "Last",
|
1134
|
+
:binary_data => ''
|
1135
|
+
)
|
1136
|
+
@employee.reload
|
1137
|
+
@employee.binary_data.should == ''
|
1138
|
+
@employee.binary_data = @binary_data
|
1139
|
+
@employee.save!
|
1140
|
+
@employee.reload
|
1141
|
+
@employee.binary_data.should == @binary_data
|
1142
|
+
end
|
1143
|
+
end
|
1144
|
+
|
1145
|
+
describe "OracleEnhancedAdapter handling of RAW columns" do
|
1146
|
+
before(:all) do
|
1147
|
+
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
1148
|
+
@conn = ActiveRecord::Base.connection
|
1149
|
+
@conn.execute <<-SQL
|
1150
|
+
CREATE TABLE test_employees (
|
1151
|
+
employee_id NUMBER(6,0) PRIMARY KEY,
|
1152
|
+
first_name VARCHAR2(20),
|
1153
|
+
last_name VARCHAR2(25),
|
1154
|
+
binary_data RAW(1024)
|
1155
|
+
)
|
1156
|
+
SQL
|
1157
|
+
@conn.execute <<-SQL
|
1158
|
+
CREATE SEQUENCE test_employees_seq MINVALUE 1
|
1159
|
+
INCREMENT BY 1 CACHE 20 NOORDER NOCYCLE
|
1160
|
+
SQL
|
1161
|
+
@binary_data = "\0\1\2\3\4\5\6\7\8\9"*100
|
1162
|
+
@binary_data2 = "\1\2\3\4\5\6\7\8\9\0"*100
|
1163
|
+
end
|
1164
|
+
|
1165
|
+
after(:all) do
|
1166
|
+
@conn.execute "DROP TABLE test_employees"
|
1167
|
+
@conn.execute "DROP SEQUENCE test_employees_seq"
|
1168
|
+
end
|
1169
|
+
|
1170
|
+
before(:each) do
|
1171
|
+
class ::TestEmployee < ActiveRecord::Base
|
1172
|
+
set_primary_key :employee_id
|
1173
|
+
end
|
1174
|
+
end
|
1175
|
+
|
1176
|
+
after(:each) do
|
1177
|
+
Object.send(:remove_const, "TestEmployee")
|
1178
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
1179
|
+
end
|
1180
|
+
|
1181
|
+
it "should create record with RAW data" do
|
1182
|
+
@employee = TestEmployee.create!(
|
1183
|
+
:first_name => "First",
|
1184
|
+
:last_name => "Last",
|
1185
|
+
:binary_data => @binary_data
|
1186
|
+
)
|
1187
|
+
@employee.reload
|
1188
|
+
@employee.binary_data.should == @binary_data
|
1189
|
+
end
|
1190
|
+
|
1191
|
+
it "should update record with RAW data" do
|
1192
|
+
@employee = TestEmployee.create!(
|
1193
|
+
:first_name => "First",
|
1194
|
+
:last_name => "Last"
|
1195
|
+
)
|
1196
|
+
@employee.reload
|
1197
|
+
@employee.binary_data.should be_nil
|
1198
|
+
@employee.binary_data = @binary_data
|
1199
|
+
@employee.save!
|
1200
|
+
@employee.reload
|
1201
|
+
@employee.binary_data.should == @binary_data
|
1202
|
+
end
|
1203
|
+
|
1204
|
+
it "should update record with zero-length RAW data" do
|
1205
|
+
@employee = TestEmployee.create!(
|
1206
|
+
:first_name => "First",
|
1207
|
+
:last_name => "Last"
|
1208
|
+
)
|
1209
|
+
@employee.reload
|
1210
|
+
@employee.binary_data.should be_nil
|
1211
|
+
@employee.binary_data = ''
|
1212
|
+
@employee.save!
|
1213
|
+
@employee.reload
|
1214
|
+
@employee.binary_data.should.nil?
|
1215
|
+
end
|
1216
|
+
|
1217
|
+
it "should update record that has existing RAW data with different RAW data" do
|
1218
|
+
@employee = TestEmployee.create!(
|
1219
|
+
:first_name => "First",
|
1220
|
+
:last_name => "Last",
|
1221
|
+
:binary_data => @binary_data
|
1222
|
+
)
|
1223
|
+
@employee.reload
|
1224
|
+
@employee.binary_data = @binary_data2
|
1225
|
+
@employee.save!
|
1226
|
+
@employee.reload
|
1227
|
+
@employee.binary_data.should == @binary_data2
|
1228
|
+
end
|
1229
|
+
|
1230
|
+
it "should update record that has existing RAW data with nil" do
|
1231
|
+
@employee = TestEmployee.create!(
|
1232
|
+
:first_name => "First",
|
1233
|
+
:last_name => "Last",
|
1234
|
+
:binary_data => @binary_data
|
1235
|
+
)
|
1236
|
+
@employee.reload
|
1237
|
+
@employee.binary_data = nil
|
1238
|
+
@employee.save!
|
1239
|
+
@employee.reload
|
1240
|
+
@employee.binary_data.should be_nil
|
1241
|
+
end
|
1242
|
+
|
1243
|
+
it "should update record that has existing RAW data with zero-length RAW data" do
|
1244
|
+
@employee = TestEmployee.create!(
|
1245
|
+
:first_name => "First",
|
1246
|
+
:last_name => "Last",
|
1247
|
+
:binary_data => @binary_data
|
1248
|
+
)
|
1249
|
+
@employee.reload
|
1250
|
+
@employee.binary_data = ''
|
1251
|
+
@employee.save!
|
1252
|
+
@employee.reload
|
1253
|
+
@employee.binary_data.should.nil?
|
1254
|
+
end
|
1255
|
+
|
1256
|
+
it "should update record that has zero-length BLOB data with non-empty RAW data" do
|
1110
1257
|
@employee = TestEmployee.create!(
|
1111
1258
|
:first_name => "First",
|
1112
1259
|
:last_name => "Last",
|
@@ -1120,6 +1267,7 @@ describe "OracleEnhancedAdapter handling of BLOB columns" do
|
|
1120
1267
|
end
|
1121
1268
|
end
|
1122
1269
|
|
1270
|
+
|
1123
1271
|
describe "OracleEnhancedAdapter quoting of NCHAR and NVARCHAR2 columns" do
|
1124
1272
|
before(:all) do
|
1125
1273
|
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
@@ -1148,6 +1296,7 @@ describe "OracleEnhancedAdapter quoting of NCHAR and NVARCHAR2 columns" do
|
|
1148
1296
|
|
1149
1297
|
after(:each) do
|
1150
1298
|
Object.send(:remove_const, "TestItem")
|
1299
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
1151
1300
|
end
|
1152
1301
|
|
1153
1302
|
it "should set nchar instance variable" do
|
@@ -30,6 +30,7 @@ if ActiveRecord::Base.instance_methods.include?('changed?')
|
|
30
30
|
Object.send(:remove_const, "TestEmployee")
|
31
31
|
@conn.execute "DROP TABLE test_employees"
|
32
32
|
@conn.execute "DROP SEQUENCE test_employees_seq"
|
33
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
33
34
|
end
|
34
35
|
|
35
36
|
it "should not mark empty string (stored as NULL) as changed when reassigning it" do
|
@@ -155,6 +155,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
155
155
|
|
156
156
|
after(:each) do
|
157
157
|
Object.send(:remove_const, "TestEmployee")
|
158
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
158
159
|
end
|
159
160
|
|
160
161
|
it "should create record" do
|
@@ -6,6 +6,7 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
6
6
|
before(:all) do
|
7
7
|
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
8
8
|
@conn = ActiveRecord::Base.connection
|
9
|
+
@oracle11g = !! @conn.select_value("SELECT * FROM v$version WHERE banner LIKE 'Oracle%11g%'")
|
9
10
|
end
|
10
11
|
|
11
12
|
def standard_dump(options = {})
|
@@ -85,12 +86,24 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
85
86
|
standard_dump.should =~ /create_table "test_posts".*add_index "test_posts"/m
|
86
87
|
end
|
87
88
|
|
89
|
+
it "should remove table prefix with $ sign in schema dump" do
|
90
|
+
ActiveRecord::Base.table_name_prefix = 'xxx$'
|
91
|
+
create_test_posts_table
|
92
|
+
standard_dump.should =~ /create_table "test_posts".*add_index "test_posts"/m
|
93
|
+
end
|
94
|
+
|
88
95
|
it "should remove table suffix in schema dump" do
|
89
96
|
ActiveRecord::Base.table_name_suffix = '_xxx'
|
90
97
|
create_test_posts_table
|
91
98
|
standard_dump.should =~ /create_table "test_posts".*add_index "test_posts"/m
|
92
99
|
end
|
93
100
|
|
101
|
+
it "should remove table suffix with $ sign in schema dump" do
|
102
|
+
ActiveRecord::Base.table_name_suffix = '$xxx'
|
103
|
+
create_test_posts_table
|
104
|
+
standard_dump.should =~ /create_table "test_posts".*add_index "test_posts"/m
|
105
|
+
end
|
106
|
+
|
94
107
|
it "should not include schema_migrations table with prefix in schema dump" do
|
95
108
|
ActiveRecord::Base.table_name_prefix = 'xxx_'
|
96
109
|
@conn.initialize_schema_migrations_table
|
@@ -332,5 +345,35 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
332
345
|
end
|
333
346
|
end
|
334
347
|
|
348
|
+
describe 'virtual columns' do
|
349
|
+
before(:all) do
|
350
|
+
schema_define do
|
351
|
+
create_table :test_names, :force => true do |t|
|
352
|
+
t.string :first_name
|
353
|
+
t.string :last_name
|
354
|
+
t.virtual :full_name, :default=>"first_name || ', ' || last_name" if @oracle11g
|
355
|
+
end
|
356
|
+
end
|
357
|
+
end
|
358
|
+
before(:each) do
|
359
|
+
class ::TestName < ActiveRecord::Base
|
360
|
+
set_table_name "test_names"
|
361
|
+
end
|
362
|
+
end
|
363
|
+
|
364
|
+
after(:all) do
|
365
|
+
schema_define do
|
366
|
+
drop_table :test_names
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
it 'should dump correctly' do
|
371
|
+
pending "Not supported in this database version" unless @oracle11g
|
372
|
+
standard_dump.should =~ /t.virtual "full_name",(\s*):limit => 512,(\s*):default => "/
|
373
|
+
end
|
374
|
+
|
375
|
+
end
|
376
|
+
|
377
|
+
|
335
378
|
end
|
336
379
|
|