activerecord-oracle_enhanced-adapter 1.5.6 → 1.6.9
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/.travis/oracle/download.sh +14 -0
- data/.travis/oracle/install.sh +31 -0
- data/.travis/setup_accounts.sh +9 -0
- data/.travis.yml +39 -0
- data/Gemfile +8 -8
- data/History.md +189 -0
- data/README.md +388 -178
- data/RUNNING_TESTS.md +11 -6
- data/VERSION +1 -1
- data/activerecord-oracle_enhanced-adapter.gemspec +29 -26
- data/lib/active_record/connection_adapters/{oracle_enhanced_column.rb → oracle_enhanced/column.rb} +14 -63
- data/lib/active_record/connection_adapters/oracle_enhanced/column_dumper.rb +66 -0
- data/lib/active_record/connection_adapters/{oracle_enhanced_connection.rb → oracle_enhanced/connection.rb} +2 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +347 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +260 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/dirty.rb +40 -0
- data/lib/active_record/connection_adapters/{oracle_enhanced_jdbc_connection.rb → oracle_enhanced/jdbc_connection.rb} +13 -4
- data/lib/active_record/connection_adapters/{oracle_enhanced_oci_connection.rb → oracle_enhanced/oci_connection.rb} +11 -5
- data/lib/active_record/connection_adapters/{oracle_enhanced_procedures.rb → oracle_enhanced/procedures.rb} +1 -1
- data/lib/active_record/connection_adapters/{oracle_enhanced_schema_creation.rb → oracle_enhanced/schema_creation.rb} +34 -35
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +95 -0
- data/lib/active_record/connection_adapters/{oracle_enhanced_schema_dumper.rb → oracle_enhanced/schema_dumper.rb} +14 -37
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +562 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +65 -0
- data/lib/active_record/connection_adapters/{oracle_enhanced_structure_dump.rb → oracle_enhanced/structure_dump.rb} +63 -14
- data/lib/active_record/connection_adapters/oracle_enhanced/version.rb +1 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +171 -73
- data/lib/active_record/oracle_enhanced/type/integer.rb +13 -0
- data/lib/active_record/oracle_enhanced/type/raw.rb +13 -0
- data/lib/active_record/oracle_enhanced/type/timestamp.rb +11 -0
- data/lib/activerecord-oracle_enhanced-adapter.rb +1 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +127 -49
- data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +46 -5
- data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +11 -3
- data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +3 -3
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +151 -78
- data/spec/active_record/connection_adapters/oracle_enhanced_database_tasks_spec.rb +4 -4
- data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +10 -16
- data/spec/active_record/connection_adapters/oracle_enhanced_emulate_oracle_adapter_spec.rb +1 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +5 -5
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +65 -181
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +114 -11
- data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +17 -1
- data/spec/spec_config.yaml.template +11 -0
- data/spec/spec_helper.rb +31 -12
- data/spec/support/alter_system_user_password.sql +2 -0
- data/spec/support/create_oracle_enhanced_users.sql +31 -0
- metadata +37 -27
- data/lib/active_record/connection_adapters/oracle_enhanced_column_dumper.rb +0 -77
- data/lib/active_record/connection_adapters/oracle_enhanced_context_index.rb +0 -350
- data/lib/active_record/connection_adapters/oracle_enhanced_database_statements.rb +0 -262
- data/lib/active_record/connection_adapters/oracle_enhanced_dirty.rb +0 -45
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_definitions.rb +0 -197
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb +0 -450
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements_ext.rb +0 -258
- data/lib/active_record/connection_adapters/oracle_enhanced_version.rb +0 -1
- /data/lib/active_record/connection_adapters/{oracle_enhanced_cpk.rb → oracle_enhanced/cpk.rb} +0 -0
- /data/lib/active_record/connection_adapters/{oracle_enhanced_database_tasks.rb → oracle_enhanced/database_tasks.rb} +0 -0
@@ -30,7 +30,7 @@ describe "OracleEnhancedAdapter establish connection" do
|
|
30
30
|
ActiveRecord::Base.connection.reconnect!
|
31
31
|
ActiveRecord::Base.connection.should be_active
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
end
|
35
35
|
|
36
36
|
describe "OracleEnhancedAdapter" do
|
@@ -40,7 +40,7 @@ describe "OracleEnhancedAdapter" do
|
|
40
40
|
before(:all) do
|
41
41
|
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
describe "ignore specified table columns" do
|
45
45
|
before(:all) do
|
46
46
|
@conn = ActiveRecord::Base.connection
|
@@ -171,7 +171,7 @@ describe "OracleEnhancedAdapter" do
|
|
171
171
|
end
|
172
172
|
|
173
173
|
it 'should identify virtual columns as such' do
|
174
|
-
|
174
|
+
skip "Not supported in this database version" unless @oracle11g_or_higher
|
175
175
|
te = TestEmployee.connection.columns('test_employees').detect(&:virtual?)
|
176
176
|
te.name.should == 'full_name'
|
177
177
|
end
|
@@ -274,11 +274,11 @@ describe "OracleEnhancedAdapter" do
|
|
274
274
|
end
|
275
275
|
|
276
276
|
it "should tell ActiveRecord that count distinct is supported" do
|
277
|
-
ActiveRecord::Base.connection.supports_count_distinct?.should
|
277
|
+
ActiveRecord::Base.connection.supports_count_distinct?.should be true
|
278
278
|
end
|
279
279
|
|
280
280
|
it "should execute correct SQL COUNT DISTINCT statement" do
|
281
|
-
lambda { TestEmployee.count(:employee_id
|
281
|
+
lambda { TestEmployee.distinct.count(:employee_id) }.should_not raise_error
|
282
282
|
end
|
283
283
|
|
284
284
|
end
|
@@ -345,56 +345,56 @@ describe "OracleEnhancedAdapter" do
|
|
345
345
|
end
|
346
346
|
|
347
347
|
it "should be valid with letters and digits" do
|
348
|
-
@adapter.valid_table_name?("abc_123").should
|
348
|
+
@adapter.valid_table_name?("abc_123").should be true
|
349
349
|
end
|
350
350
|
|
351
351
|
it "should be valid with schema name" do
|
352
|
-
@adapter.valid_table_name?("abc_123.def_456").should
|
352
|
+
@adapter.valid_table_name?("abc_123.def_456").should be true
|
353
353
|
end
|
354
354
|
|
355
355
|
it "should be valid with $ in name" do
|
356
|
-
@adapter.valid_table_name?("sys.v$session").should
|
356
|
+
@adapter.valid_table_name?("sys.v$session").should be true
|
357
357
|
end
|
358
358
|
|
359
359
|
it "should be valid with upcase schema name" do
|
360
|
-
@adapter.valid_table_name?("ABC_123.DEF_456").should
|
360
|
+
@adapter.valid_table_name?("ABC_123.DEF_456").should be true
|
361
361
|
end
|
362
362
|
|
363
363
|
it "should be valid with irregular schema name and database links" do
|
364
|
-
@adapter.valid_table_name?('abc$#_123.abc$#_123@abc$#@._123').should
|
364
|
+
@adapter.valid_table_name?('abc$#_123.abc$#_123@abc$#@._123').should be true
|
365
365
|
end
|
366
366
|
|
367
367
|
it "should not be valid with two dots in name" do
|
368
|
-
@adapter.valid_table_name?("abc_123.def_456.ghi_789").should
|
368
|
+
@adapter.valid_table_name?("abc_123.def_456.ghi_789").should be false
|
369
369
|
end
|
370
370
|
|
371
371
|
it "should not be valid with invalid characters" do
|
372
|
-
@adapter.valid_table_name?("warehouse-things").should
|
372
|
+
@adapter.valid_table_name?("warehouse-things").should be false
|
373
373
|
end
|
374
374
|
|
375
375
|
it "should not be valid with for camel-case" do
|
376
|
-
@adapter.valid_table_name?("Abc").should
|
377
|
-
@adapter.valid_table_name?("aBc").should
|
378
|
-
@adapter.valid_table_name?("abC").should
|
376
|
+
@adapter.valid_table_name?("Abc").should be false
|
377
|
+
@adapter.valid_table_name?("aBc").should be false
|
378
|
+
@adapter.valid_table_name?("abC").should be false
|
379
379
|
end
|
380
|
-
|
380
|
+
|
381
381
|
it "should not be valid for names > 30 characters" do
|
382
|
-
@adapter.valid_table_name?("a" * 31).should
|
382
|
+
@adapter.valid_table_name?("a" * 31).should be false
|
383
383
|
end
|
384
|
-
|
384
|
+
|
385
385
|
it "should not be valid for schema names > 30 characters" do
|
386
|
-
@adapter.valid_table_name?(("a" * 31) + ".validname").should
|
386
|
+
@adapter.valid_table_name?(("a" * 31) + ".validname").should be false
|
387
387
|
end
|
388
|
-
|
388
|
+
|
389
389
|
it "should not be valid for database links > 128 characters" do
|
390
|
-
@adapter.valid_table_name?("name@" + "a" * 129).should
|
390
|
+
@adapter.valid_table_name?("name@" + "a" * 129).should be false
|
391
391
|
end
|
392
|
-
|
392
|
+
|
393
393
|
it "should not be valid for names that do not begin with alphabetic characters" do
|
394
|
-
@adapter.valid_table_name?("1abc").should
|
395
|
-
@adapter.valid_table_name?("_abc").should
|
396
|
-
@adapter.valid_table_name?("abc.1xyz").should
|
397
|
-
@adapter.valid_table_name?("abc._xyz").should
|
394
|
+
@adapter.valid_table_name?("1abc").should be false
|
395
|
+
@adapter.valid_table_name?("_abc").should be false
|
396
|
+
@adapter.valid_table_name?("abc.1xyz").should be false
|
397
|
+
@adapter.valid_table_name?("abc._xyz").should be false
|
398
398
|
end
|
399
399
|
end
|
400
400
|
|
@@ -457,7 +457,7 @@ describe "OracleEnhancedAdapter" do
|
|
457
457
|
|
458
458
|
cc = CamelCase.create!(:name => "Foo", :foo => 2)
|
459
459
|
cc.id.should_not be_nil
|
460
|
-
|
460
|
+
|
461
461
|
@conn.tables.should include("CamelCase")
|
462
462
|
end
|
463
463
|
|
@@ -476,7 +476,7 @@ describe "OracleEnhancedAdapter" do
|
|
476
476
|
t.string :title
|
477
477
|
# cannot update LOBs over database link
|
478
478
|
t.string :body
|
479
|
-
t.timestamps
|
479
|
+
t.timestamps null: true
|
480
480
|
end
|
481
481
|
@db_link_username = SYSTEM_CONNECTION_PARAMS[:username]
|
482
482
|
@db_link_password = SYSTEM_CONNECTION_PARAMS[:password]
|
@@ -554,7 +554,7 @@ describe "OracleEnhancedAdapter" do
|
|
554
554
|
@conn.create_table :foos, :temporary => true, :id => false do |t|
|
555
555
|
t.integer :id
|
556
556
|
end
|
557
|
-
@conn.temporary_table?("foos").should
|
557
|
+
@conn.temporary_table?("foos").should be true
|
558
558
|
end
|
559
559
|
end
|
560
560
|
|
@@ -600,7 +600,7 @@ describe "OracleEnhancedAdapter" do
|
|
600
600
|
posts.size.should == @ids.size
|
601
601
|
end
|
602
602
|
|
603
|
-
end
|
603
|
+
end
|
604
604
|
|
605
605
|
describe "with statement pool" do
|
606
606
|
before(:all) do
|
@@ -628,8 +628,8 @@ describe "OracleEnhancedAdapter" do
|
|
628
628
|
end
|
629
629
|
|
630
630
|
it "should clear older cursors when statement limit is reached" do
|
631
|
-
pk = TestPost.
|
632
|
-
sub = @conn.substitute_at(pk, 0)
|
631
|
+
pk = TestPost.columns_hash[TestPost.primary_key]
|
632
|
+
sub = @conn.substitute_at(pk, 0).to_sql
|
633
633
|
binds = [[pk, 1]]
|
634
634
|
|
635
635
|
lambda {
|
@@ -641,8 +641,8 @@ describe "OracleEnhancedAdapter" do
|
|
641
641
|
|
642
642
|
it "should cache UPDATE statements with bind variables" do
|
643
643
|
lambda {
|
644
|
-
pk = TestPost.
|
645
|
-
sub = @conn.substitute_at(pk, 0)
|
644
|
+
pk = TestPost.columns_hash[TestPost.primary_key]
|
645
|
+
sub = @conn.substitute_at(pk, 0).to_sql
|
646
646
|
binds = [[pk, 1]]
|
647
647
|
@conn.exec_update("UPDATE test_posts SET id = #{sub}", "SQL", binds)
|
648
648
|
}.should change(@statements, :length).by(+1)
|
@@ -654,7 +654,7 @@ describe "OracleEnhancedAdapter" do
|
|
654
654
|
@conn.exec_update("UPDATE test_posts SET id = 1", "SQL", binds)
|
655
655
|
}.should_not change(@statements, :length)
|
656
656
|
end
|
657
|
-
end
|
657
|
+
end
|
658
658
|
|
659
659
|
describe "explain" do
|
660
660
|
before(:all) do
|
@@ -682,36 +682,114 @@ describe "OracleEnhancedAdapter" do
|
|
682
682
|
end
|
683
683
|
|
684
684
|
it "should explain query with binds" do
|
685
|
-
pk = TestPost.
|
685
|
+
pk = TestPost.columns_hash[TestPost.primary_key]
|
686
686
|
sub = @conn.substitute_at(pk, 0)
|
687
687
|
explain = TestPost.where(TestPost.arel_table[pk.name].eq(sub)).bind([pk, 1]).explain
|
688
688
|
explain.should include("Cost")
|
689
689
|
explain.should include("INDEX UNIQUE SCAN")
|
690
690
|
end
|
691
|
-
end
|
691
|
+
end
|
692
692
|
|
693
|
-
describe "
|
693
|
+
describe "using offset and limit" do
|
694
694
|
before(:all) do
|
695
|
-
@
|
695
|
+
@conn = ActiveRecord::Base.connection
|
696
|
+
@conn.execute "DROP TABLE test_employees" rescue nil
|
697
|
+
@conn.execute <<-SQL
|
698
|
+
CREATE TABLE test_employees (
|
699
|
+
id NUMBER PRIMARY KEY,
|
700
|
+
sort_order NUMBER(38,0),
|
701
|
+
first_name VARCHAR2(20),
|
702
|
+
last_name VARCHAR2(25),
|
703
|
+
updated_at DATE,
|
704
|
+
created_at DATE
|
705
|
+
)
|
706
|
+
SQL
|
707
|
+
@conn.execute "DROP SEQUENCE test_employees_seq" rescue nil
|
708
|
+
@conn.execute <<-SQL
|
709
|
+
CREATE SEQUENCE test_employees_seq MINVALUE 1
|
710
|
+
INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE
|
711
|
+
SQL
|
712
|
+
@employee = Class.new(ActiveRecord::Base) do
|
713
|
+
self.table_name = :test_employees
|
714
|
+
end
|
715
|
+
i = 0
|
716
|
+
@employee.create!(sort_order: i+=1, first_name: 'Peter', last_name: 'Parker')
|
717
|
+
@employee.create!(sort_order: i+=1, first_name: 'Tony', last_name: 'Stark')
|
718
|
+
@employee.create!(sort_order: i+=1, first_name: 'Steven', last_name: 'Rogers')
|
719
|
+
@employee.create!(sort_order: i+=1, first_name: 'Bruce', last_name: 'Banner')
|
720
|
+
@employee.create!(sort_order: i+=1, first_name: 'Natasha', last_name: 'Romanova')
|
696
721
|
end
|
697
722
|
|
698
|
-
|
699
|
-
@
|
700
|
-
@
|
723
|
+
after(:all) do
|
724
|
+
@conn.execute "DROP TABLE test_employees"
|
725
|
+
@conn.execute "DROP SEQUENCE test_employees_seq"
|
701
726
|
end
|
702
727
|
|
703
|
-
|
704
|
-
|
728
|
+
after(:each) do
|
729
|
+
ActiveRecord::Base.connection.clear_ignored_table_columns
|
730
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
731
|
+
end
|
732
|
+
|
733
|
+
it "should return n records with limit(n)" do
|
734
|
+
@employee.limit(3).to_a.size.should be(3)
|
705
735
|
end
|
706
736
|
|
707
|
-
it "should return
|
708
|
-
@
|
709
|
-
@adapter.is_integer_column?("foo_id").should be_true
|
737
|
+
it "should return less than n records with limit(n) if there exist less than n records" do
|
738
|
+
@employee.limit(10).to_a.size.should be(5)
|
710
739
|
end
|
711
740
|
|
712
|
-
it "should return
|
713
|
-
@
|
741
|
+
it "should return the records starting from offset n with offset(n)" do
|
742
|
+
expect(@employee.order(:sort_order).first.first_name.should).to eq("Peter")
|
743
|
+
expect(@employee.order(:sort_order).offset(0).first.first_name.should).to eq("Peter")
|
744
|
+
expect(@employee.order(:sort_order).offset(1).first.first_name.should).to eq("Tony")
|
745
|
+
expect(@employee.order(:sort_order).offset(4).first.first_name.should).to eq("Natasha")
|
714
746
|
end
|
715
747
|
end
|
716
748
|
|
749
|
+
describe 'serialized column' do
|
750
|
+
|
751
|
+
before(:all) do
|
752
|
+
schema_define do
|
753
|
+
create_table :test_serialized_columns do |t|
|
754
|
+
t.text :serialized
|
755
|
+
end
|
756
|
+
end
|
757
|
+
class ::TestSerializedColumn < ActiveRecord::Base
|
758
|
+
serialize :serialized, Array
|
759
|
+
end
|
760
|
+
end
|
761
|
+
|
762
|
+
after(:all) do
|
763
|
+
schema_define do
|
764
|
+
drop_table :test_serialized_columns
|
765
|
+
end
|
766
|
+
Object.send(:remove_const, 'TestSerializedColumn')
|
767
|
+
ActiveRecord::Base.table_name_prefix = nil
|
768
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
769
|
+
end
|
770
|
+
|
771
|
+
before(:each) do
|
772
|
+
set_logger
|
773
|
+
end
|
774
|
+
|
775
|
+
after(:each) do
|
776
|
+
clear_logger
|
777
|
+
end
|
778
|
+
|
779
|
+
it 'should serialize' do
|
780
|
+
new_value = 'new_value'
|
781
|
+
serialized_column = TestSerializedColumn.new
|
782
|
+
|
783
|
+
expect(serialized_column.serialized.should).to eq([])
|
784
|
+
serialized_column.serialized << new_value
|
785
|
+
expect(serialized_column.serialized.should).to eq([new_value])
|
786
|
+
serialized_column.save
|
787
|
+
expect(serialized_column.save!.should).to eq(true)
|
788
|
+
|
789
|
+
serialized_column.reload
|
790
|
+
expect(serialized_column.serialized.should).to eq([new_value])
|
791
|
+
serialized_column.serialized = []
|
792
|
+
expect(serialized_column.save!.should).to eq(true)
|
793
|
+
end
|
794
|
+
end
|
717
795
|
end
|
@@ -16,7 +16,7 @@ describe "OracleEnhancedConnection" do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should ping active connection" do
|
19
|
-
@conn.ping.should
|
19
|
+
@conn.ping.should be true
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should not ping inactive connection" do
|
@@ -35,6 +35,30 @@ describe "OracleEnhancedConnection" do
|
|
35
35
|
|
36
36
|
end
|
37
37
|
|
38
|
+
describe "create connection with schema option" do
|
39
|
+
before(:all) do
|
40
|
+
@conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(CONNECTION_WITH_SCHEMA_PARAMS)
|
41
|
+
end
|
42
|
+
|
43
|
+
before(:each) do
|
44
|
+
@conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(CONNECTION_WITH_SCHEMA_PARAMS) unless @conn.active?
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should create new connection" do
|
48
|
+
@conn.should be_active
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should swith to specified schema" do
|
52
|
+
@conn.select_value("select SYS_CONTEXT('userenv', 'current_schema') from dual").should == CONNECTION_WITH_SCHEMA_PARAMS[:schema].upcase
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should swith to specified schema after reset" do
|
56
|
+
@conn.reset!
|
57
|
+
@conn.select_value("select SYS_CONTEXT('userenv', 'current_schema') from dual").should == CONNECTION_WITH_SCHEMA_PARAMS[:schema].upcase
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
38
62
|
describe "create connection with NLS parameters" do
|
39
63
|
after do
|
40
64
|
ENV['NLS_DATE_FORMAT'] = nil
|
@@ -86,6 +110,23 @@ describe "OracleEnhancedConnection" do
|
|
86
110
|
end
|
87
111
|
end
|
88
112
|
|
113
|
+
describe 'with host="connection-string"' do
|
114
|
+
let(:username) { CONNECTION_PARAMS[:username] }
|
115
|
+
let(:password) { CONNECTION_PARAMS[:password] }
|
116
|
+
let(:connection_string) { "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=#{DATABASE_HOST})(PORT=#{DATABASE_PORT})))(CONNECT_DATA=(SERVICE_NAME=#{DATABASE_NAME})))" }
|
117
|
+
let(:params) { { username: username, password: password, host: 'connection-string', database: connection_string } }
|
118
|
+
|
119
|
+
it 'uses the database param as the connection string' do
|
120
|
+
if ORACLE_ENHANCED_CONNECTION == :jdbc
|
121
|
+
expect(java.sql.DriverManager).to receive(:getConnection).with("jdbc:oracle:thin:@#{connection_string}", anything).and_call_original
|
122
|
+
else
|
123
|
+
expect(OCI8).to receive(:new).with(username, password, connection_string, nil).and_call_original
|
124
|
+
end
|
125
|
+
conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(params)
|
126
|
+
expect(conn).to be_active
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
89
130
|
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
90
131
|
|
91
132
|
describe "create JDBC connection" do
|
@@ -125,7 +166,7 @@ describe "OracleEnhancedConnection" do
|
|
125
166
|
import 'org.apache.commons.dbcp.PoolableConnectionFactory'
|
126
167
|
import 'org.apache.commons.dbcp.DriverManagerConnectionFactory'
|
127
168
|
rescue NameError => e
|
128
|
-
return
|
169
|
+
return skip e.message
|
129
170
|
end
|
130
171
|
|
131
172
|
class InitialContextMock
|
@@ -146,7 +187,7 @@ describe "OracleEnhancedConnection" do
|
|
146
187
|
end
|
147
188
|
end
|
148
189
|
|
149
|
-
javax.naming.InitialContext.stub
|
190
|
+
javax.naming.InitialContext.stub(:new).and_return(InitialContextMock.new)
|
150
191
|
|
151
192
|
params = {}
|
152
193
|
params[:jndi] = 'java:comp/env/jdbc/test'
|
@@ -161,7 +202,7 @@ describe "OracleEnhancedConnection" do
|
|
161
202
|
params[:url] = "jdbc:oracle:thin:@#{DATABASE_HOST && "//#{DATABASE_HOST}#{DATABASE_PORT && ":#{DATABASE_PORT}"}/"}#{DATABASE_NAME}"
|
162
203
|
params[:host] = nil
|
163
204
|
params[:database] = nil
|
164
|
-
java.sql.DriverManager.stub
|
205
|
+
java.sql.DriverManager.stub(:getConnection).and_raise('no suitable driver found')
|
165
206
|
@conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(params)
|
166
207
|
@conn.should be_active
|
167
208
|
end
|
@@ -227,7 +268,7 @@ describe "OracleEnhancedConnection" do
|
|
227
268
|
|
228
269
|
it "should execute prepared statement with decimal bind parameter " do
|
229
270
|
cursor = @conn.prepare("INSERT INTO test_employees VALUES(:1)")
|
230
|
-
column = ActiveRecord::ConnectionAdapters::OracleEnhancedColumn.new('age', nil, 'NUMBER(10,2)')
|
271
|
+
column = ActiveRecord::ConnectionAdapters::OracleEnhancedColumn.new('age', nil, ActiveRecord::Type::Decimal.new, 'NUMBER(10,2)')
|
231
272
|
column.type.should == :decimal
|
232
273
|
cursor.bind_param(1, "1.5", column)
|
233
274
|
cursor.exec
|
@@ -11,7 +11,7 @@ describe "OracleEnhancedAdapter context index" do
|
|
11
11
|
t.string :title
|
12
12
|
t.text :body
|
13
13
|
t.integer :comments_count
|
14
|
-
t.timestamps
|
14
|
+
t.timestamps null: true
|
15
15
|
t.string :all_text, limit: 2 # will be used for multi-column index
|
16
16
|
end
|
17
17
|
end
|
@@ -23,7 +23,7 @@ describe "OracleEnhancedAdapter context index" do
|
|
23
23
|
t.integer :post_id
|
24
24
|
t.string :author
|
25
25
|
t.text :body
|
26
|
-
t.timestamps
|
26
|
+
t.timestamps null: true
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -103,7 +103,7 @@ describe "OracleEnhancedAdapter context index" do
|
|
103
103
|
|
104
104
|
it "should not include text index secondary tables in user tables list" do
|
105
105
|
@conn.add_context_index :posts, :title
|
106
|
-
@conn.tables.any?{|t| t =~ /^dr\$/i}.should
|
106
|
+
@conn.tables.any?{|t| t =~ /^dr\$/i}.should be false
|
107
107
|
@conn.remove_context_index :posts, :title
|
108
108
|
end
|
109
109
|
|
@@ -169,6 +169,14 @@ describe "OracleEnhancedAdapter context index" do
|
|
169
169
|
end
|
170
170
|
@conn.remove_context_index :posts, :title
|
171
171
|
end
|
172
|
+
|
173
|
+
it "should use index when contains has schema_name.table_name syntax" do
|
174
|
+
@conn.add_context_index :posts, :title
|
175
|
+
@title_words.each do |word|
|
176
|
+
Post.contains('posts.title', word).to_a.should == [@post2, @post1]
|
177
|
+
end
|
178
|
+
@conn.remove_context_index :posts, :title
|
179
|
+
end
|
172
180
|
end
|
173
181
|
|
174
182
|
describe "on multiple tables" do
|
@@ -52,7 +52,7 @@ describe "OracleEnhancedAdapter composite_primary_keys support" do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should tell ActiveRecord that count distinct is not supported" do
|
55
|
-
ActiveRecord::Base.connection.supports_count_distinct?.should
|
55
|
+
ActiveRecord::Base.connection.supports_count_distinct?.should be false
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should execute correct SQL COUNT DISTINCT statement on table with composite primary keys" do
|
@@ -67,12 +67,12 @@ describe "OracleEnhancedAdapter composite_primary_keys support" do
|
|
67
67
|
t.string :type_category, :limit => 15, :null => false
|
68
68
|
t.date :date_value, :null => false
|
69
69
|
t.text :results, :null => false
|
70
|
-
t.timestamps
|
70
|
+
t.timestamps null: true
|
71
71
|
end
|
72
72
|
create_table :non_cpk_write_lobs_test, :force => true do |t|
|
73
73
|
t.date :date_value, :null => false
|
74
74
|
t.text :results, :null => false
|
75
|
-
t.timestamps
|
75
|
+
t.timestamps null: true
|
76
76
|
end
|
77
77
|
end
|
78
78
|
class ::CpkWriteLobsTest < ActiveRecord::Base
|