activerecord-oracle_enhanced-adapter 1.1.8 → 1.1.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.
- data/History.txt +10 -0
- data/README.txt +7 -66
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +84 -12
- data/lib/active_record/connection_adapters/oracle_enhanced_dirty.rb +39 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_version.rb +1 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +149 -798
- data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +1 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +826 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +85 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +4 -9
- data/spec/spec_helper.rb +31 -6
- metadata +7 -4
@@ -0,0 +1,85 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
+
|
3
|
+
if ActiveRecord::Base.instance_methods.include?('changed?')
|
4
|
+
|
5
|
+
describe "OracleEnhancedAdapter dirty object tracking" do
|
6
|
+
|
7
|
+
before(:all) do
|
8
|
+
ActiveRecord::Base.establish_connection(:adapter => "oracle_enhanced",
|
9
|
+
:database => "xe",
|
10
|
+
:username => "hr",
|
11
|
+
:password => "hr")
|
12
|
+
@conn = ActiveRecord::Base.connection
|
13
|
+
@conn.execute <<-SQL
|
14
|
+
CREATE TABLE test_employees (
|
15
|
+
id NUMBER,
|
16
|
+
first_name VARCHAR2(20),
|
17
|
+
last_name VARCHAR2(25),
|
18
|
+
job_id NUMBER(6,0),
|
19
|
+
salary NUMBER(8,2),
|
20
|
+
comments CLOB,
|
21
|
+
hire_date DATE
|
22
|
+
)
|
23
|
+
SQL
|
24
|
+
@conn.execute <<-SQL
|
25
|
+
CREATE SEQUENCE test_employees_seq MINVALUE 1
|
26
|
+
INCREMENT BY 1 CACHE 20 NOORDER NOCYCLE
|
27
|
+
SQL
|
28
|
+
class TestEmployee < ActiveRecord::Base
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
after(:all) do
|
33
|
+
Object.send(:remove_const, "TestEmployee")
|
34
|
+
@conn.execute "DROP TABLE test_employees"
|
35
|
+
@conn.execute "DROP SEQUENCE test_employees_seq"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should not mark empty string (stored as NULL) as changed when reassigning it" do
|
39
|
+
@employee = TestEmployee.create!(:first_name => '')
|
40
|
+
@employee.first_name = ''
|
41
|
+
@employee.should_not be_changed
|
42
|
+
@employee.reload
|
43
|
+
@employee.first_name = ''
|
44
|
+
@employee.should_not be_changed
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should not mark empty integer (stored as NULL) as changed when reassigning it" do
|
48
|
+
@employee = TestEmployee.create!(:job_id => '')
|
49
|
+
@employee.job_id = ''
|
50
|
+
@employee.should_not be_changed
|
51
|
+
@employee.reload
|
52
|
+
@employee.job_id = ''
|
53
|
+
@employee.should_not be_changed
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should not mark empty decimal (stored as NULL) as changed when reassigning it" do
|
57
|
+
@employee = TestEmployee.create!(:salary => '')
|
58
|
+
@employee.salary = ''
|
59
|
+
@employee.should_not be_changed
|
60
|
+
@employee.reload
|
61
|
+
@employee.salary = ''
|
62
|
+
@employee.should_not be_changed
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should not mark empty text (stored as NULL) as changed when reassigning it" do
|
66
|
+
@employee = TestEmployee.create!(:comments => '')
|
67
|
+
@employee.comments = ''
|
68
|
+
@employee.should_not be_changed
|
69
|
+
@employee.reload
|
70
|
+
@employee.comments = ''
|
71
|
+
@employee.should_not be_changed
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should not mark empty date (stored as NULL) as changed when reassigning it" do
|
75
|
+
@employee = TestEmployee.create!(:hire_date => '')
|
76
|
+
@employee.hire_date = ''
|
77
|
+
@employee.should_not be_changed
|
78
|
+
@employee.reload
|
79
|
+
@employee.hire_date = ''
|
80
|
+
@employee.should_not be_changed
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -1,12 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
2
|
|
3
3
|
describe "OracleEnhancedAdapter custom methods for create, update and destroy" do
|
4
|
-
|
5
|
-
ActiveRecord::Base.logger = Logger.new(stream)
|
6
|
-
ActiveRecord::Base.clear_active_connections!
|
7
|
-
ActiveRecord::Base.colorize_logging = false
|
8
|
-
ActiveRecord::Base.logger.level = Logger::DEBUG
|
9
|
-
end
|
4
|
+
include LoggerSpecHelper
|
10
5
|
|
11
6
|
before(:all) do
|
12
7
|
ActiveRecord::Base.establish_connection(:adapter => "oracle_enhanced",
|
@@ -228,7 +223,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
228
223
|
:last_name => "Last",
|
229
224
|
:hire_date => @today
|
230
225
|
)
|
231
|
-
@buffer.string.should match(/^TestEmployee Create \(\d+\.\d
|
226
|
+
@buffer.string.should match(/^TestEmployee Create \(\d+\.\d+(ms)?\) custom create method$/)
|
232
227
|
end
|
233
228
|
|
234
229
|
it "should log update record" do
|
@@ -240,7 +235,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
240
235
|
)
|
241
236
|
log_to @buffer
|
242
237
|
@employee.save!
|
243
|
-
@buffer.string.should match(/^TestEmployee Update \(\d+\.\d
|
238
|
+
@buffer.string.should match(/^TestEmployee Update \(\d+\.\d+(ms)?\) custom update method with employee_id=#{@employee.id}$/)
|
244
239
|
end
|
245
240
|
|
246
241
|
it "should log delete record" do
|
@@ -251,7 +246,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
251
246
|
)
|
252
247
|
log_to @buffer
|
253
248
|
@employee.destroy
|
254
|
-
@buffer.string.should match(/^TestEmployee Destroy \(\d+\.\d
|
249
|
+
@buffer.string.should match(/^TestEmployee Destroy \(\d+\.\d+(ms)?\) custom delete method with employee_id=#{@employee.id}$/)
|
255
250
|
end
|
256
251
|
|
257
252
|
it "should validate new record before creation" do
|
data/spec/spec_helper.rb
CHANGED
@@ -3,15 +3,40 @@ gem 'rspec'
|
|
3
3
|
require 'spec'
|
4
4
|
|
5
5
|
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
gem '
|
10
|
-
gem '
|
11
|
-
gem '
|
6
|
+
|
7
|
+
if ENV['RAILS_GEM_VERSION'] =~ /^2.0/
|
8
|
+
gem 'activerecord', '=2.0.2'
|
9
|
+
gem 'actionpack', '=2.0.2'
|
10
|
+
gem 'activesupport', '=2.0.2'
|
11
|
+
gem 'composite_primary_keys', '=0.9.93'
|
12
|
+
elsif ENV['RAILS_GEM_VERSION'] =~ /^2.1/
|
13
|
+
gem 'activerecord', '=2.1.2'
|
14
|
+
gem 'actionpack', '=2.1.2'
|
15
|
+
gem 'activesupport', '=2.1.2'
|
16
|
+
gem 'composite_primary_keys', '=1.0.8'
|
17
|
+
else
|
18
|
+
gem 'activerecord', '=2.2.2'
|
19
|
+
gem 'actionpack', '=2.2.2'
|
20
|
+
gem 'activesupport', '=2.2.2'
|
21
|
+
gem 'composite_primary_keys', '=2.2.0'
|
22
|
+
end
|
23
|
+
|
12
24
|
require 'activerecord'
|
13
25
|
require 'actionpack'
|
14
26
|
require 'action_controller/session/active_record_store'
|
15
27
|
require 'active_record/connection_adapters/oracle_enhanced_adapter'
|
16
28
|
gem "activerecord-oracle-adapter"
|
17
29
|
require 'active_record/connection_adapters/oracle_adapter'
|
30
|
+
|
31
|
+
module LoggerSpecHelper
|
32
|
+
def log_to(stream)
|
33
|
+
ActiveRecord::Base.logger = Logger.new(stream)
|
34
|
+
if ActiveRecord::Base.respond_to?(:connection_pool)
|
35
|
+
ActiveRecord::Base.connection_pool.clear_reloadable_connections!
|
36
|
+
else
|
37
|
+
ActiveRecord::Base.clear_active_connections!
|
38
|
+
end
|
39
|
+
ActiveRecord::Base.colorize_logging = false
|
40
|
+
ActiveRecord::Base.logger.level = Logger::DEBUG
|
41
|
+
end
|
42
|
+
end
|
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.1.
|
4
|
+
version: 1.1.9
|
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: 2009-01-03 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.
|
23
|
+
version: 1.8.2
|
24
24
|
version:
|
25
25
|
description: Oracle enhaced adapter for Active Record
|
26
26
|
email:
|
@@ -40,11 +40,14 @@ files:
|
|
40
40
|
- lib/active_record/connection_adapters/oracle_enhanced.rake
|
41
41
|
- lib/active_record/connection_adapters/oracle_enhanced_adapter.rb
|
42
42
|
- lib/active_record/connection_adapters/oracle_enhanced_cpk.rb
|
43
|
+
- lib/active_record/connection_adapters/oracle_enhanced_dirty.rb
|
43
44
|
- lib/active_record/connection_adapters/oracle_enhanced_procedures.rb
|
44
45
|
- lib/active_record/connection_adapters/oracle_enhanced_tasks.rb
|
45
46
|
- lib/active_record/connection_adapters/oracle_enhanced_version.rb
|
46
47
|
- spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb
|
47
48
|
- spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb
|
49
|
+
- spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb
|
50
|
+
- spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb
|
48
51
|
- spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb
|
49
52
|
- spec/spec.opts
|
50
53
|
- spec/spec_helper.rb
|
@@ -71,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
74
|
requirements: []
|
72
75
|
|
73
76
|
rubyforge_project: oracle-enhanced
|
74
|
-
rubygems_version: 1.
|
77
|
+
rubygems_version: 1.3.1
|
75
78
|
signing_key:
|
76
79
|
specification_version: 2
|
77
80
|
summary: Oracle enhaced adapter for Active Record
|