activerecord-oracle_enhanced-adapter 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +17 -0
- data/License.txt +1 -1
- data/README.rdoc +3 -1
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced.rake +6 -3
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +333 -109
- data/lib/active_record/connection_adapters/oracle_enhanced_jdbc_connection.rb +60 -36
- data/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb +13 -18
- data/lib/active_record/connection_adapters/oracle_enhanced_procedures.rb +3 -4
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_definitions.rb +3 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_dumper.rb +86 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +31 -2
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_structure_dumper_spec.rb +267 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +6 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +22 -75
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_spec.rb +61 -0
- data/spec/spec_helper.rb +3 -15
- metadata +4 -2
@@ -290,6 +290,12 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
|
|
290
290
|
@employee2.job_id.class.should == Fixnum
|
291
291
|
end
|
292
292
|
|
293
|
+
it "should return Fixnum value from NUMBER column with integer value using _before_type_cast method" do
|
294
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
|
295
|
+
create_employee2
|
296
|
+
@employee2.job_id_before_type_cast.class.should == Fixnum
|
297
|
+
end
|
298
|
+
|
293
299
|
it "should return BigDecimal value from NUMBER column if column name does not contain 'id' and emulate_integers_by_column_name is true" do
|
294
300
|
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
|
295
301
|
create_employee2
|
@@ -1,61 +1,5 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
|
-
describe "OracleEnhancedAdapter original schema dump" do
|
4
|
-
|
5
|
-
before(:all) do
|
6
|
-
if !defined?(RUBY_ENGINE)
|
7
|
-
if ActiveRecord::Base.respond_to?(:oracle_connection)
|
8
|
-
@old_conn = ActiveRecord::Base.oracle_connection(CONNECTION_PARAMS)
|
9
|
-
@old_conn.class.should == ActiveRecord::ConnectionAdapters::OracleAdapter
|
10
|
-
end
|
11
|
-
elsif RUBY_ENGINE == 'jruby'
|
12
|
-
@old_conn = ActiveRecord::Base.jdbc_connection(JDBC_CONNECTION_PARAMS)
|
13
|
-
@old_conn.class.should == ActiveRecord::ConnectionAdapters::JdbcAdapter
|
14
|
-
end
|
15
|
-
|
16
|
-
@new_conn = ActiveRecord::Base.oracle_enhanced_connection(CONNECTION_PARAMS)
|
17
|
-
@new_conn.class.should == ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter
|
18
|
-
end
|
19
|
-
|
20
|
-
after(:all) do
|
21
|
-
# Workaround for undefining callback that was defined by JDBC adapter
|
22
|
-
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
23
|
-
ActiveRecord::Base.class_eval do
|
24
|
-
def after_save_with_oracle_lob
|
25
|
-
nil
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
if !defined?(RUBY_ENGINE) && ActiveRecord::Base.respond_to?(:oracle_connection) || defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
32
|
-
it "should return the same tables list as original oracle adapter" do
|
33
|
-
@new_conn.tables.sort.should == @old_conn.tables.sort
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should return the same index list as original oracle adapter" do
|
37
|
-
@new_conn.indexes('employees').sort_by(&:name).should == @old_conn.indexes('employees').sort_by(&:name)
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should return the same pk_and_sequence_for as original oracle adapter" do
|
41
|
-
if @old_conn.respond_to?(:pk_and_sequence_for)
|
42
|
-
@new_conn.tables.each do |t|
|
43
|
-
@new_conn.pk_and_sequence_for(t).should == @old_conn.pk_and_sequence_for(t)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should return the same structure dump as original oracle adapter" do
|
49
|
-
@new_conn.structure_dump.split(";\n\n").sort.should == @old_conn.structure_dump.split(";\n\n").sort
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should return the same structure drop as original oracle adapter" do
|
53
|
-
@new_conn.structure_drop.split(";\n\n").sort.should == @old_conn.structure_drop.split(";\n\n").sort
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
3
|
describe "OracleEnhancedAdapter schema dump" do
|
60
4
|
include SchemaSpecHelper
|
61
5
|
|
@@ -225,32 +169,35 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
225
169
|
|
226
170
|
end
|
227
171
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
172
|
+
describe "temporary tables" do
|
173
|
+
after(:each) do
|
174
|
+
drop_test_posts_table
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should include temporary options" do
|
178
|
+
create_test_posts_table(:temporary => true)
|
179
|
+
standard_dump.should =~ /create_table "test_posts", :temporary => true/
|
180
|
+
end
|
234
181
|
end
|
235
182
|
|
236
|
-
describe "
|
237
|
-
|
238
|
-
|
239
|
-
CREATE TABLE nvarchartable (
|
240
|
-
unq_nvarchar NVARCHAR2(255) DEFAULT NULL
|
241
|
-
)
|
242
|
-
SQL
|
183
|
+
describe "indexes" do
|
184
|
+
after(:each) do
|
185
|
+
drop_test_posts_table
|
243
186
|
end
|
244
187
|
|
245
|
-
|
246
|
-
|
188
|
+
it "should not specify default tablespace in add index" do
|
189
|
+
create_test_posts_table
|
190
|
+
standard_dump.should =~ /add_index \"test_posts\", \[\"title\"\], :name => \"index_test_posts_on_title\"$/
|
247
191
|
end
|
248
192
|
|
249
|
-
it "should
|
250
|
-
|
251
|
-
|
252
|
-
|
193
|
+
it "should not specify default tablespace in add index" do
|
194
|
+
tablespace_name = @conn.default_tablespace
|
195
|
+
@conn.stub!(:default_tablespace).and_return('dummy')
|
196
|
+
create_test_posts_table
|
197
|
+
standard_dump.should =~ /add_index \"test_posts\", \[\"title\"\], :name => \"index_test_posts_on_title\", :tablespace => \"#{tablespace_name}\"$/
|
253
198
|
end
|
199
|
+
|
254
200
|
end
|
255
201
|
|
256
202
|
end
|
203
|
+
|
@@ -720,4 +720,65 @@ describe "OracleEnhancedAdapter schema definition" do
|
|
720
720
|
|
721
721
|
end
|
722
722
|
|
723
|
+
describe "alter columns with column cache" do
|
724
|
+
include LoggerSpecHelper
|
725
|
+
|
726
|
+
before(:all) do
|
727
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.cache_columns = true
|
728
|
+
end
|
729
|
+
|
730
|
+
after(:all) do
|
731
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.cache_columns = nil
|
732
|
+
end
|
733
|
+
|
734
|
+
before(:each) do
|
735
|
+
schema_define do
|
736
|
+
create_table :test_posts, :force => true do |t|
|
737
|
+
t.string :title, :null => false
|
738
|
+
end
|
739
|
+
end
|
740
|
+
class ::TestPost < ActiveRecord::Base; end
|
741
|
+
TestPost.columns_hash['title'].null.should be_false
|
742
|
+
end
|
743
|
+
|
744
|
+
after(:each) do
|
745
|
+
Object.send(:remove_const, "TestPost")
|
746
|
+
schema_define { drop_table :test_posts }
|
747
|
+
end
|
748
|
+
|
749
|
+
it "should change column to nullable" do
|
750
|
+
schema_define do
|
751
|
+
change_column :test_posts, :title, :string, :null => true
|
752
|
+
end
|
753
|
+
TestPost.reset_column_information
|
754
|
+
TestPost.columns_hash['title'].null.should be_true
|
755
|
+
end
|
756
|
+
|
757
|
+
it "should add column" do
|
758
|
+
schema_define do
|
759
|
+
add_column :test_posts, :body, :string
|
760
|
+
end
|
761
|
+
TestPost.reset_column_information
|
762
|
+
TestPost.columns_hash['body'].should_not be_nil
|
763
|
+
end
|
764
|
+
|
765
|
+
it "should rename column" do
|
766
|
+
schema_define do
|
767
|
+
rename_column :test_posts, :title, :subject
|
768
|
+
end
|
769
|
+
TestPost.reset_column_information
|
770
|
+
TestPost.columns_hash['subject'].should_not be_nil
|
771
|
+
TestPost.columns_hash['title'].should be_nil
|
772
|
+
end
|
773
|
+
|
774
|
+
it "should remove column" do
|
775
|
+
schema_define do
|
776
|
+
remove_column :test_posts, :title
|
777
|
+
end
|
778
|
+
TestPost.reset_column_information
|
779
|
+
TestPost.columns_hash['title'].should be_nil
|
780
|
+
end
|
781
|
+
|
782
|
+
end
|
783
|
+
|
723
784
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -41,13 +41,8 @@ else
|
|
41
41
|
require 'action_controller/session/active_record_store'
|
42
42
|
end
|
43
43
|
if !defined?(RUBY_ENGINE)
|
44
|
-
# change version to 1.0.6 to test with old oracle_adapter
|
45
44
|
gem 'ruby-oci8', '=2.0.3'
|
46
45
|
require 'oci8'
|
47
|
-
if OCI8::VERSION =~ /^1\./
|
48
|
-
gem "activerecord-oracle-adapter"
|
49
|
-
require 'active_record/connection_adapters/oracle_adapter'
|
50
|
-
end
|
51
46
|
elsif RUBY_ENGINE == 'ruby'
|
52
47
|
gem 'ruby-oci8', '=2.0.3'
|
53
48
|
require 'oci8'
|
@@ -57,6 +52,7 @@ elsif RUBY_ENGINE == 'jruby'
|
|
57
52
|
end
|
58
53
|
|
59
54
|
require 'active_record/connection_adapters/oracle_enhanced_adapter'
|
55
|
+
require 'ruby-plsql'
|
60
56
|
|
61
57
|
module LoggerSpecHelper
|
62
58
|
def log_to(stream)
|
@@ -84,8 +80,8 @@ end
|
|
84
80
|
DATABASE_NAME = ENV['DATABASE_NAME'] || 'orcl'
|
85
81
|
DATABASE_HOST = ENV['DATABASE_HOST'] || 'localhost'
|
86
82
|
DATABASE_PORT = ENV['DATABASE_PORT'] || 1521
|
87
|
-
DATABASE_USER = ENV['DATABASE_USER'] || '
|
88
|
-
DATABASE_PASSWORD = ENV['DATABASE_PASSWORD'] || '
|
83
|
+
DATABASE_USER = ENV['DATABASE_USER'] || 'oracle_enhanced'
|
84
|
+
DATABASE_PASSWORD = ENV['DATABASE_PASSWORD'] || 'oracle_enhanced'
|
89
85
|
DATABASE_SYS_PASSWORD = ENV['DATABASE_SYS_PASSWORD'] || 'admin'
|
90
86
|
|
91
87
|
CONNECTION_PARAMS = {
|
@@ -96,14 +92,6 @@ CONNECTION_PARAMS = {
|
|
96
92
|
:password => DATABASE_PASSWORD
|
97
93
|
}
|
98
94
|
|
99
|
-
JDBC_CONNECTION_PARAMS = {
|
100
|
-
:adapter => "jdbc",
|
101
|
-
:driver => "oracle.jdbc.driver.OracleDriver",
|
102
|
-
:url => "jdbc:oracle:thin:@#{DATABASE_HOST}:#{DATABASE_PORT}:#{DATABASE_NAME}",
|
103
|
-
:username => DATABASE_USER,
|
104
|
-
:password => DATABASE_PASSWORD
|
105
|
-
}
|
106
|
-
|
107
95
|
SYS_CONNECTION_PARAMS = {
|
108
96
|
:adapter => "oracle_enhanced",
|
109
97
|
:database => DATABASE_NAME,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-oracle_enhanced-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raimonds Simanovskis
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-02-24 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- lib/active_record/connection_adapters/oracle_enhanced_tasks.rb
|
69
69
|
- lib/active_record/connection_adapters/oracle_enhanced_version.rb
|
70
70
|
- spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb
|
71
|
+
- spec/active_record/connection_adapters/oracle_enhanced_adapter_structure_dumper_spec.rb
|
71
72
|
- spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb
|
72
73
|
- spec/active_record/connection_adapters/oracle_enhanced_core_ext_spec.rb
|
73
74
|
- spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb
|
@@ -110,6 +111,7 @@ specification_version: 3
|
|
110
111
|
summary: Oracle enhanced adapter for ActiveRecord
|
111
112
|
test_files:
|
112
113
|
- spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb
|
114
|
+
- spec/active_record/connection_adapters/oracle_enhanced_adapter_structure_dumper_spec.rb
|
113
115
|
- spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb
|
114
116
|
- spec/active_record/connection_adapters/oracle_enhanced_core_ext_spec.rb
|
115
117
|
- spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb
|