activerecord-oracle_enhanced-adapter 1.4.3 → 1.5.0.beta1
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.
- checksums.yaml +4 -4
- data/Gemfile +4 -14
- data/History.md +51 -0
- data/README.md +32 -1
- data/VERSION +1 -1
- data/activerecord-oracle_enhanced-adapter.gemspec +2 -4
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +315 -57
- data/lib/active_record/connection_adapters/oracle_enhanced_column_dumper.rb +55 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_context_index.rb +4 -13
- data/lib/active_record/connection_adapters/oracle_enhanced_dirty.rb +5 -6
- data/lib/active_record/connection_adapters/oracle_enhanced_jdbc_connection.rb +19 -11
- data/lib/active_record/connection_adapters/oracle_enhanced_procedures.rb +163 -232
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_definitions.rb +18 -10
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_dumper.rb +20 -32
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb +54 -35
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +5 -74
- data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +3 -2
- data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +98 -98
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +5 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb +3 -3
- data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +11 -5
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +56 -55
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +15 -8
- data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +4 -3
- data/spec/spec_helper.rb +25 -54
- metadata +32 -20
- data/lib/active_record/connection_adapters/oracle_enhanced_activerecord_patches.rb +0 -41
- data/lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb +0 -121
- data/lib/active_record/connection_adapters/oracle_enhanced_tasks.rb +0 -17
@@ -6,7 +6,8 @@ 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
|
-
@
|
9
|
+
@oracle11g_or_higher = !! @conn.select_value(
|
10
|
+
"select * from product_component_version where product like 'Oracle%' and to_number(substr(version,1,2)) >= 11")
|
10
11
|
end
|
11
12
|
|
12
13
|
def standard_dump(options = {})
|
@@ -17,7 +18,7 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def create_test_posts_table(options = {})
|
20
|
-
options.merge! :
|
21
|
+
options.merge! force: true
|
21
22
|
schema_define do
|
22
23
|
create_table :test_posts, options do |t|
|
23
24
|
t.string :title
|
@@ -42,12 +43,12 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
42
43
|
|
43
44
|
it "should not include ignored table names in schema dump" do
|
44
45
|
create_test_posts_table
|
45
|
-
standard_dump(:
|
46
|
+
standard_dump(ignore_tables: %w(test_posts)).should_not =~ /create_table "test_posts"/
|
46
47
|
end
|
47
48
|
|
48
49
|
it "should not include ignored table regexes in schema dump" do
|
49
50
|
create_test_posts_table
|
50
|
-
standard_dump(:
|
51
|
+
standard_dump(ignore_tables: [ /test_posts/i ]).should_not =~ /create_table "test_posts"/
|
51
52
|
end
|
52
53
|
|
53
54
|
end
|
@@ -55,9 +56,9 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
55
56
|
describe "dumping default values" do
|
56
57
|
before :each do
|
57
58
|
schema_define do
|
58
|
-
create_table "test_defaults", :
|
59
|
-
t.string "regular", :
|
60
|
-
t.string "special_c", :
|
59
|
+
create_table "test_defaults", force: true do |t|
|
60
|
+
t.string "regular", default: "c"
|
61
|
+
t.string "special_c", default: "\n"
|
61
62
|
end
|
62
63
|
end
|
63
64
|
end
|
@@ -69,7 +70,7 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
69
70
|
end
|
70
71
|
|
71
72
|
it "should be able to dump default values using special characters" do
|
72
|
-
standard_dump.should =~ /t.string \"special_c\", :
|
73
|
+
standard_dump.should =~ /t.string \"special_c\", default: "\\n"/
|
73
74
|
end
|
74
75
|
end
|
75
76
|
describe "table prefixes and suffixes" do
|
@@ -124,8 +125,8 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
124
125
|
end
|
125
126
|
|
126
127
|
it "should include non-default primary key in schema dump" do
|
127
|
-
create_test_posts_table(:
|
128
|
-
standard_dump.should =~ /create_table "test_posts", :
|
128
|
+
create_test_posts_table(primary_key: 'post_id')
|
129
|
+
standard_dump.should =~ /create_table "test_posts", primary_key: "post_id"/
|
129
130
|
end
|
130
131
|
|
131
132
|
end
|
@@ -138,13 +139,13 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
138
139
|
end
|
139
140
|
|
140
141
|
it "should include primary key trigger in schema dump" do
|
141
|
-
create_test_posts_table(:
|
142
|
+
create_test_posts_table(primary_key_trigger: true)
|
142
143
|
standard_dump.should =~ /create_table "test_posts".*add_primary_key_trigger "test_posts"/m
|
143
144
|
end
|
144
145
|
|
145
146
|
it "should include primary key trigger with non-default primary key in schema dump" do
|
146
|
-
create_test_posts_table(:
|
147
|
-
standard_dump.should =~ /create_table "test_posts", :
|
147
|
+
create_test_posts_table(primary_key_trigger: true, primary_key: 'post_id')
|
148
|
+
standard_dump.should =~ /create_table "test_posts", primary_key: "post_id".*add_primary_key_trigger "test_posts", primary_key: "post_id"/m
|
148
149
|
end
|
149
150
|
|
150
151
|
end
|
@@ -152,11 +153,11 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
152
153
|
describe "foreign key constraints" do
|
153
154
|
before(:all) do
|
154
155
|
schema_define do
|
155
|
-
create_table :test_posts, :
|
156
|
+
create_table :test_posts, force: true do |t|
|
156
157
|
t.string :title
|
157
158
|
end
|
158
|
-
create_table :test_comments, :
|
159
|
-
t.string :body, :
|
159
|
+
create_table :test_comments, force: true do |t|
|
160
|
+
t.string :body, limit: 4000
|
160
161
|
t.references :test_post
|
161
162
|
end
|
162
163
|
end
|
@@ -165,7 +166,7 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
165
166
|
after(:each) do
|
166
167
|
schema_define do
|
167
168
|
remove_foreign_key :test_comments, :test_posts rescue nil
|
168
|
-
remove_foreign_key :test_comments, :
|
169
|
+
remove_foreign_key :test_comments, name: 'comments_posts_baz_fooz_fk' rescue nil
|
169
170
|
end
|
170
171
|
end
|
171
172
|
after(:all) do
|
@@ -179,49 +180,49 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
179
180
|
schema_define do
|
180
181
|
add_foreign_key :test_comments, :test_posts
|
181
182
|
end
|
182
|
-
standard_dump.should =~ /add_foreign_key "test_comments", "test_posts", :
|
183
|
+
standard_dump.should =~ /add_foreign_key "test_comments", "test_posts", name: "test_comments_test_post_id_fk"/
|
183
184
|
end
|
184
185
|
|
185
186
|
it "should include foreign key with delete dependency in schema dump" do
|
186
187
|
schema_define do
|
187
|
-
add_foreign_key :test_comments, :test_posts, :
|
188
|
+
add_foreign_key :test_comments, :test_posts, dependent: :delete
|
188
189
|
end
|
189
|
-
standard_dump.should =~ /add_foreign_key "test_comments", "test_posts", :
|
190
|
+
standard_dump.should =~ /add_foreign_key "test_comments", "test_posts", name: "test_comments_test_post_id_fk", dependent: :delete/
|
190
191
|
end
|
191
192
|
|
192
193
|
it "should include foreign key with nullify dependency in schema dump" do
|
193
194
|
schema_define do
|
194
|
-
add_foreign_key :test_comments, :test_posts, :
|
195
|
+
add_foreign_key :test_comments, :test_posts, dependent: :nullify
|
195
196
|
end
|
196
|
-
standard_dump.should =~ /add_foreign_key "test_comments", "test_posts", :
|
197
|
+
standard_dump.should =~ /add_foreign_key "test_comments", "test_posts", name: "test_comments_test_post_id_fk", dependent: :nullify/
|
197
198
|
end
|
198
199
|
|
199
200
|
it "should not include foreign keys on ignored table names in schema dump" do
|
200
201
|
schema_define do
|
201
202
|
add_foreign_key :test_comments, :test_posts
|
202
203
|
end
|
203
|
-
standard_dump(:
|
204
|
+
standard_dump(ignore_tables: %w(test_comments)).should_not =~ /add_foreign_key "test_comments"/
|
204
205
|
end
|
205
206
|
|
206
207
|
it "should not include foreign keys on ignored table regexes in schema dump" do
|
207
208
|
schema_define do
|
208
209
|
add_foreign_key :test_comments, :test_posts
|
209
210
|
end
|
210
|
-
standard_dump(:
|
211
|
+
standard_dump(ignore_tables: [ /test_comments/i ]).should_not =~ /add_foreign_key "test_comments"/
|
211
212
|
end
|
212
213
|
|
213
214
|
it "should include foreign keys referencing ignored table names in schema dump" do
|
214
215
|
schema_define do
|
215
216
|
add_foreign_key :test_comments, :test_posts
|
216
217
|
end
|
217
|
-
standard_dump(:
|
218
|
+
standard_dump(ignore_tables: %w(test_posts)).should =~ /add_foreign_key "test_comments"/
|
218
219
|
end
|
219
220
|
|
220
221
|
it "should include foreign keys referencing ignored table regexes in schema dump" do
|
221
222
|
schema_define do
|
222
223
|
add_foreign_key :test_comments, :test_posts
|
223
224
|
end
|
224
|
-
standard_dump(:
|
225
|
+
standard_dump(ignore_tables: [ /test_posts/i ]).should =~ /add_foreign_key "test_comments"/
|
225
226
|
end
|
226
227
|
|
227
228
|
it "should include composite foreign keys" do
|
@@ -237,9 +238,9 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
237
238
|
add_column :test_comments, :baz_id, :integer
|
238
239
|
add_column :test_comments, :fooz_id, :integer
|
239
240
|
|
240
|
-
add_foreign_key :test_comments, :test_posts, :
|
241
|
+
add_foreign_key :test_comments, :test_posts, columns: ["baz_id", "fooz_id"], name: 'comments_posts_baz_fooz_fk'
|
241
242
|
end
|
242
|
-
standard_dump.should =~ /add_foreign_key "test_comments", "test_posts", :
|
243
|
+
standard_dump.should =~ /add_foreign_key "test_comments", "test_posts", columns: \["baz_id", "fooz_id"\], name: "comments_posts_baz_fooz_fk"/
|
243
244
|
end
|
244
245
|
it "should include foreign keys following all tables" do
|
245
246
|
# if foreign keys preceed declaration of all tables
|
@@ -261,37 +262,37 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
261
262
|
|
262
263
|
it "should include synonym to other schema table in schema dump" do
|
263
264
|
schema_define do
|
264
|
-
add_synonym :test_synonym, "schema_name.table_name", :
|
265
|
+
add_synonym :test_synonym, "schema_name.table_name", force: true
|
265
266
|
end
|
266
|
-
standard_dump.should =~ /add_synonym "test_synonym", "schema_name.table_name", :
|
267
|
+
standard_dump.should =~ /add_synonym "test_synonym", "schema_name.table_name", force: true/
|
267
268
|
end
|
268
269
|
|
269
270
|
it "should include synonym to other database table in schema dump" do
|
270
271
|
schema_define do
|
271
|
-
add_synonym :test_synonym, "table_name@link_name", :
|
272
|
+
add_synonym :test_synonym, "table_name@link_name", force: true
|
272
273
|
end
|
273
|
-
standard_dump.should =~ /add_synonym "test_synonym", "table_name@link_name(\.[-A-Za-z0-9_]+)*", :
|
274
|
+
standard_dump.should =~ /add_synonym "test_synonym", "table_name@link_name(\.[-A-Za-z0-9_]+)*", force: true/
|
274
275
|
end
|
275
276
|
|
276
277
|
it "should not include ignored table names in schema dump" do
|
277
278
|
schema_define do
|
278
|
-
add_synonym :test_synonym, "schema_name.table_name", :
|
279
|
+
add_synonym :test_synonym, "schema_name.table_name", force: true
|
279
280
|
end
|
280
|
-
standard_dump(:
|
281
|
+
standard_dump(ignore_tables: %w(test_synonym)).should_not =~ /add_synonym "test_synonym"/
|
281
282
|
end
|
282
283
|
|
283
284
|
it "should not include ignored table regexes in schema dump" do
|
284
285
|
schema_define do
|
285
|
-
add_synonym :test_synonym, "schema_name.table_name", :
|
286
|
+
add_synonym :test_synonym, "schema_name.table_name", force: true
|
286
287
|
end
|
287
|
-
standard_dump(:
|
288
|
+
standard_dump(ignore_tables: [ /test_synonym/i ]).should_not =~ /add_synonym "test_synonym"/
|
288
289
|
end
|
289
290
|
|
290
291
|
it "should include synonyms to ignored table regexes in schema dump" do
|
291
292
|
schema_define do
|
292
|
-
add_synonym :test_synonym, "schema_name.table_name", :
|
293
|
+
add_synonym :test_synonym, "schema_name.table_name", force: true
|
293
294
|
end
|
294
|
-
standard_dump(:
|
295
|
+
standard_dump(ignore_tables: [ /table_name/i ]).should =~ /add_synonym "test_synonym"/
|
295
296
|
end
|
296
297
|
|
297
298
|
end
|
@@ -302,8 +303,8 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
302
303
|
end
|
303
304
|
|
304
305
|
it "should include temporary options" do
|
305
|
-
create_test_posts_table(:
|
306
|
-
standard_dump.should =~ /create_table "test_posts", :
|
306
|
+
create_test_posts_table(temporary: true)
|
307
|
+
standard_dump.should =~ /create_table "test_posts", temporary: true/
|
307
308
|
end
|
308
309
|
end
|
309
310
|
|
@@ -314,20 +315,20 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
314
315
|
|
315
316
|
it "should not specify default tablespace in add index" do
|
316
317
|
create_test_posts_table
|
317
|
-
standard_dump.should =~ /add_index "test_posts", \["title"\], :
|
318
|
+
standard_dump.should =~ /add_index "test_posts", \["title"\], name: "index_test_posts_on_title"$/
|
318
319
|
end
|
319
320
|
|
320
321
|
it "should specify non-default tablespace in add index" do
|
321
322
|
tablespace_name = @conn.default_tablespace
|
322
323
|
@conn.stub!(:default_tablespace).and_return('dummy')
|
323
324
|
create_test_posts_table
|
324
|
-
standard_dump.should =~ /add_index "test_posts", \["title"\], :
|
325
|
+
standard_dump.should =~ /add_index "test_posts", \["title"\], name: "index_test_posts_on_title", tablespace: "#{tablespace_name}"$/
|
325
326
|
end
|
326
327
|
|
327
328
|
it "should create and dump function-based indexes" do
|
328
329
|
create_test_posts_table
|
329
|
-
@conn.add_index :test_posts, "NVL(created_at, updated_at)", :
|
330
|
-
standard_dump.should =~ /add_index "test_posts", \["NVL\(\\"CREATED_AT\\",\\"UPDATED_AT\\"\)"\], :
|
330
|
+
@conn.add_index :test_posts, "NVL(created_at, updated_at)", name: "index_test_posts_cr_upd_at"
|
331
|
+
standard_dump.should =~ /add_index "test_posts", \["NVL\(\\"CREATED_AT\\",\\"UPDATED_AT\\"\)"\], name: "index_test_posts_cr_upd_at"$/
|
331
332
|
end
|
332
333
|
|
333
334
|
end
|
@@ -347,7 +348,7 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
347
348
|
|
348
349
|
describe 'virtual columns' do
|
349
350
|
before(:all) do
|
350
|
-
if @
|
351
|
+
if @oracle11g_or_higher
|
351
352
|
schema_define do
|
352
353
|
create_table :test_names, :force => true do |t|
|
353
354
|
t.string :first_name
|
@@ -366,7 +367,7 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
366
367
|
end
|
367
368
|
|
368
369
|
before(:each) do
|
369
|
-
if @
|
370
|
+
if @oracle11g_or_higher
|
370
371
|
class ::TestName < ActiveRecord::Base
|
371
372
|
if self.respond_to?(:table_name=)
|
372
373
|
self.table_name = "test_names"
|
@@ -378,7 +379,7 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
378
379
|
end
|
379
380
|
|
380
381
|
after(:all) do
|
381
|
-
if @
|
382
|
+
if @oracle11g_or_higher
|
382
383
|
schema_define do
|
383
384
|
drop_table :test_names
|
384
385
|
end
|
@@ -386,12 +387,12 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
386
387
|
end
|
387
388
|
|
388
389
|
it 'should dump correctly' do
|
389
|
-
standard_dump.should =~ /t\.virtual "full_name",(\s*):
|
390
|
-
standard_dump.should =~ /t\.virtual "short_name",(\s*):
|
391
|
-
standard_dump.should =~ /t\.virtual "full_name_length",(\s*):
|
392
|
-
standard_dump.should =~ /t\.virtual "name_ratio",(\s*):
|
393
|
-
standard_dump.should =~ /t\.virtual "abbrev_name",(\s*):
|
394
|
-
standard_dump.should =~ /t\.virtual "field_with_leading_space",(\s*):
|
390
|
+
standard_dump.should =~ /t\.virtual "full_name",(\s*)limit: 512,(\s*)as: "\\"FIRST_NAME\\"\|\|', '\|\|\\"LAST_NAME\\"",(\s*)type: :string/
|
391
|
+
standard_dump.should =~ /t\.virtual "short_name",(\s*)limit: 300,(\s*)as:(.*),(\s*)type: :string/
|
392
|
+
standard_dump.should =~ /t\.virtual "full_name_length",(\s*)precision: 38,(\s*)scale: 0,(\s*)as:(.*),(\s*)type: :integer/
|
393
|
+
standard_dump.should =~ /t\.virtual "name_ratio",(\s*)as:(.*)\"$/ # no :type
|
394
|
+
standard_dump.should =~ /t\.virtual "abbrev_name",(\s*)limit: 100,(\s*)as:(.*),(\s*)type: :string/
|
395
|
+
standard_dump.should =~ /t\.virtual "field_with_leading_space",(\s*)limit: 300,(\s*)as: "' '\|\|\\"FIRST_NAME\\"\|\|' '",(\s*)type: :string/
|
395
396
|
end
|
396
397
|
|
397
398
|
context 'with column cache' do
|
@@ -417,14 +418,14 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
417
418
|
|
418
419
|
context "with index on virtual column" do
|
419
420
|
before(:all) do
|
420
|
-
if @
|
421
|
+
if @oracle11g_or_higher
|
421
422
|
schema_define do
|
422
423
|
add_index 'test_names', 'field_with_leading_space', :name => "index_on_virtual_col"
|
423
424
|
end
|
424
425
|
end
|
425
426
|
end
|
426
427
|
after(:all) do
|
427
|
-
if @
|
428
|
+
if @oracle11g_or_higher
|
428
429
|
schema_define do
|
429
430
|
remove_index 'test_names', :name => 'index_on_virtual_col'
|
430
431
|
end
|
@@ -6,7 +6,8 @@ describe "OracleEnhancedAdapter schema definition" do
|
|
6
6
|
|
7
7
|
before(:all) do
|
8
8
|
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
9
|
-
@
|
9
|
+
@oracle11g_or_higher = !! !! ActiveRecord::Base.connection.select_value(
|
10
|
+
"select * from product_component_version where product like 'Oracle%' and to_number(substr(version,1,2)) >= 11")
|
10
11
|
end
|
11
12
|
|
12
13
|
describe "table and sequence creation with non-default primary key" do
|
@@ -52,6 +53,15 @@ describe "OracleEnhancedAdapter schema definition" do
|
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
56
|
+
describe "default sequence name" do
|
57
|
+
|
58
|
+
it "should return sequence name without truncating too much" do
|
59
|
+
seq_name_length = ActiveRecord::Base.connection.sequence_name_length
|
60
|
+
tname = "#{DATABASE_USER}" + "." +"a"*(seq_name_length - DATABASE_USER.length) + "z"*(DATABASE_USER).length
|
61
|
+
ActiveRecord::Base.connection.default_sequence_name(tname).should match (/z_seq$/)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
55
65
|
describe "sequence creation parameters" do
|
56
66
|
|
57
67
|
def create_test_employees_table(sequence_start_value = nil)
|
@@ -817,7 +827,6 @@ end
|
|
817
827
|
end
|
818
828
|
|
819
829
|
it "should add foreign key in change_table" do
|
820
|
-
return pending("Not in this ActiveRecord version") unless ENV['RAILS_GEM_VERSION'] >= '2.1'
|
821
830
|
schema_define do
|
822
831
|
create_table :test_comments, :force => true do |t|
|
823
832
|
t.string :body, :limit => 4000
|
@@ -833,7 +842,6 @@ end
|
|
833
842
|
end
|
834
843
|
|
835
844
|
it "should add foreign key in change_table references" do
|
836
|
-
return pending("Not in this ActiveRecord version") unless ENV['RAILS_GEM_VERSION'] >= '2.1'
|
837
845
|
schema_define do
|
838
846
|
create_table :test_comments, :force => true do |t|
|
839
847
|
t.string :body, :limit => 4000
|
@@ -848,7 +856,6 @@ end
|
|
848
856
|
end
|
849
857
|
|
850
858
|
it "should remove foreign key by table name" do
|
851
|
-
return pending("Not in this ActiveRecord version") unless ENV['RAILS_GEM_VERSION'] >= '2.1'
|
852
859
|
schema_define do
|
853
860
|
create_table :test_comments, :force => true do |t|
|
854
861
|
t.string :body, :limit => 4000
|
@@ -1080,7 +1087,7 @@ end
|
|
1080
1087
|
|
1081
1088
|
describe 'virtual columns in create_table' do
|
1082
1089
|
before(:each) do
|
1083
|
-
pending "Not supported in this database version" unless @
|
1090
|
+
pending "Not supported in this database version" unless @oracle11g_or_higher
|
1084
1091
|
end
|
1085
1092
|
|
1086
1093
|
it 'should create virtual column with old syntax' do
|
@@ -1130,7 +1137,7 @@ end
|
|
1130
1137
|
|
1131
1138
|
describe 'virtual columns' do
|
1132
1139
|
before(:each) do
|
1133
|
-
pending "Not supported in this database version" unless @
|
1140
|
+
pending "Not supported in this database version" unless @oracle11g_or_higher
|
1134
1141
|
expr = "( numerator/NULLIF(denominator,0) )*100"
|
1135
1142
|
schema_define do
|
1136
1143
|
create_table :test_fractions, :force => true do |t|
|
@@ -1150,7 +1157,7 @@ end
|
|
1150
1157
|
end
|
1151
1158
|
|
1152
1159
|
after(:each) do
|
1153
|
-
if @
|
1160
|
+
if @oracle11g_or_higher
|
1154
1161
|
schema_define do
|
1155
1162
|
drop_table :test_fractions
|
1156
1163
|
end
|
@@ -1295,7 +1302,7 @@ end
|
|
1295
1302
|
it "should use correct tablespace" do
|
1296
1303
|
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:table] = DATABASE_NON_DEFAULT_TABLESPACE
|
1297
1304
|
@conn.create_table :tablespace_tests do |t|
|
1298
|
-
t.
|
1305
|
+
t.string :foo
|
1299
1306
|
end
|
1300
1307
|
@would_execute_sql.should =~ /CREATE +TABLE .* \(.*\) TABLESPACE #{DATABASE_NON_DEFAULT_TABLESPACE}/
|
1301
1308
|
end
|
@@ -6,7 +6,8 @@ describe "OracleEnhancedAdapter structure dump" do
|
|
6
6
|
before(:all) do
|
7
7
|
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
8
8
|
@conn = ActiveRecord::Base.connection
|
9
|
-
@
|
9
|
+
@oracle11g_or_higher = !! @conn.select_value(
|
10
|
+
"select * from product_component_version where product like 'Oracle%' and to_number(substr(version,1,2)) >= 11")
|
10
11
|
end
|
11
12
|
describe "structure dump" do
|
12
13
|
before(:each) do
|
@@ -143,7 +144,7 @@ describe "OracleEnhancedAdapter structure dump" do
|
|
143
144
|
end
|
144
145
|
|
145
146
|
it "should dump virtual columns" do
|
146
|
-
pending "Not supported in this database version" unless @
|
147
|
+
pending "Not supported in this database version" unless @oracle11g_or_higher
|
147
148
|
@conn.execute <<-SQL
|
148
149
|
CREATE TABLE bars (
|
149
150
|
id NUMBER(38,0) NOT NULL,
|
@@ -250,7 +251,7 @@ describe "OracleEnhancedAdapter structure dump" do
|
|
250
251
|
describe "full drop" do
|
251
252
|
before(:each) do
|
252
253
|
@conn.create_table :full_drop_test do |t|
|
253
|
-
t.
|
254
|
+
t.string :foo
|
254
255
|
end
|
255
256
|
@conn.create_table :full_drop_test_temp, :temporary => true do |t|
|
256
257
|
t.string :foo
|
data/spec/spec_helper.rb
CHANGED
@@ -13,35 +13,21 @@ elsif RUBY_ENGINE == 'jruby'
|
|
13
13
|
puts "==> Running specs with JRuby version #{JRUBY_VERSION}"
|
14
14
|
end
|
15
15
|
|
16
|
-
ENV['RAILS_GEM_VERSION'] ||= '
|
17
|
-
NO_COMPOSITE_PRIMARY_KEYS = true
|
16
|
+
ENV['RAILS_GEM_VERSION'] ||= '4.0-master'
|
17
|
+
NO_COMPOSITE_PRIMARY_KEYS = true
|
18
18
|
|
19
19
|
puts "==> Running specs with Rails version #{ENV['RAILS_GEM_VERSION']}"
|
20
20
|
|
21
21
|
require 'active_record'
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
require 'active_support/core_ext/class/attribute_accessors'
|
27
|
-
|
28
|
-
if ENV['RAILS_GEM_VERSION'] =~ /^3.0.0.beta/
|
29
|
-
require "rails/log_subscriber"
|
30
|
-
require 'active_record/railties/log_subscriber'
|
31
|
-
else
|
32
|
-
require "active_support/log_subscriber"
|
33
|
-
require 'active_record/log_subscriber'
|
34
|
-
end
|
23
|
+
require 'action_dispatch'
|
24
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
25
|
+
require 'active_support/core_ext/class/attribute_accessors'
|
35
26
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
require 'active_record/session_store'
|
41
|
-
elsif ENV['RAILS_GEM_VERSION'] <= '2.3'
|
42
|
-
require 'action_pack'
|
43
|
-
require 'action_controller/session/active_record_store'
|
44
|
-
end
|
27
|
+
require "active_support/log_subscriber"
|
28
|
+
require 'active_record/log_subscriber'
|
29
|
+
|
30
|
+
require 'logger'
|
45
31
|
|
46
32
|
require 'active_record/connection_adapters/oracle_enhanced_adapter'
|
47
33
|
require 'ruby-plsql'
|
@@ -51,30 +37,16 @@ module LoggerSpecHelper
|
|
51
37
|
@logger = MockLogger.new
|
52
38
|
@old_logger = ActiveRecord::Base.logger
|
53
39
|
|
54
|
-
|
55
|
-
@notifier = ActiveSupport::Notifications::Fanout.new
|
56
|
-
|
57
|
-
ActiveSupport::LogSubscriber.colorize_logging = false
|
40
|
+
@notifier = ActiveSupport::Notifications::Fanout.new
|
58
41
|
|
59
|
-
|
60
|
-
@old_notifier = ActiveSupport::Notifications.notifier
|
61
|
-
ActiveSupport::Notifications.notifier = @notifier
|
42
|
+
ActiveSupport::LogSubscriber.colorize_logging = false
|
62
43
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
else # ActiveRecord 2.x
|
68
|
-
if ActiveRecord::Base.respond_to?(:connection_pool)
|
69
|
-
ActiveRecord::Base.connection_pool.clear_reloadable_connections!
|
70
|
-
else
|
71
|
-
ActiveRecord::Base.clear_active_connections!
|
72
|
-
end
|
73
|
-
ActiveRecord::Base.logger = @logger
|
74
|
-
ActiveRecord::Base.colorize_logging = false
|
75
|
-
# ActiveRecord::Base.logger.level = Logger::DEBUG
|
76
|
-
end
|
44
|
+
ActiveRecord::Base.logger = @logger
|
45
|
+
@old_notifier = ActiveSupport::Notifications.notifier
|
46
|
+
ActiveSupport::Notifications.notifier = @notifier
|
77
47
|
|
48
|
+
ActiveRecord::LogSubscriber.attach_to(:active_record)
|
49
|
+
ActiveSupport::Notifications.subscribe("sql.active_record", ActiveRecord::ExplainSubscriber.new)
|
78
50
|
end
|
79
51
|
|
80
52
|
class MockLogger
|
@@ -115,11 +87,8 @@ module LoggerSpecHelper
|
|
115
87
|
ActiveRecord::Base.logger = @old_logger
|
116
88
|
@logger = nil
|
117
89
|
|
118
|
-
|
119
|
-
|
120
|
-
@notifier = nil
|
121
|
-
end
|
122
|
-
|
90
|
+
ActiveSupport::Notifications.notifier = @old_notifier
|
91
|
+
@notifier = nil
|
123
92
|
end
|
124
93
|
|
125
94
|
# Wait notifications to be published (for Rails 3.0)
|
@@ -177,11 +146,13 @@ SYSTEM_CONNECTION_PARAMS = {
|
|
177
146
|
|
178
147
|
DATABASE_NON_DEFAULT_TABLESPACE = ENV['DATABASE_NON_DEFAULT_TABLESPACE'] || "SYSTEM"
|
179
148
|
|
180
|
-
# Set default $KCODE to UTF8
|
181
|
-
if RUBY_VERSION < "1.9"
|
182
|
-
$KCODE = "UTF8"
|
183
|
-
end
|
184
|
-
|
185
149
|
# set default time zone in TZ environment variable
|
186
150
|
# which will be used to set session time zone
|
187
151
|
ENV['TZ'] ||= 'Europe/Riga'
|
152
|
+
|
153
|
+
# ActiveRecord::Base.logger = Logger.new(STDOUT)
|
154
|
+
|
155
|
+
# Set default_timezone :local explicitly
|
156
|
+
# because this default value has been changed to :utc atrails master branch
|
157
|
+
ActiveRecord::Base.default_timezone = :local
|
158
|
+
|