activerecord-oracle_enhanced-adapter 1.7.3 → 1.8.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.
- checksums.yaml +4 -4
- data/History.md +288 -0
- data/README.md +44 -0
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/emulation/oracle_adapter.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/column.rb +7 -63
- data/lib/active_record/connection_adapters/oracle_enhanced/column_dumper.rb +6 -52
- data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +13 -16
- data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +117 -119
- data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +33 -27
- data/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb +10 -10
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +59 -77
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +0 -4
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +56 -82
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_quoting.rb +4 -4
- data/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb +77 -77
- data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +16 -45
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +60 -65
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +33 -51
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +149 -162
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +119 -122
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +3 -4
- data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +69 -107
- data/lib/active_record/connection_adapters/oracle_enhanced/version.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +315 -538
- data/lib/active_record/oracle_enhanced/type/boolean.rb +7 -11
- data/lib/active_record/oracle_enhanced/type/integer.rb +4 -5
- data/lib/active_record/oracle_enhanced/type/json.rb +8 -0
- data/lib/active_record/oracle_enhanced/type/national_character_string.rb +1 -2
- data/lib/active_record/oracle_enhanced/type/raw.rb +2 -4
- data/lib/active_record/oracle_enhanced/type/string.rb +2 -3
- data/lib/active_record/oracle_enhanced/type/text.rb +2 -4
- data/lib/active_record/oracle_enhanced/type/timestamptz.rb +23 -0
- data/lib/activerecord-oracle_enhanced-adapter.rb +14 -13
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +129 -166
- data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +50 -33
- data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +44 -42
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +283 -378
- data/spec/active_record/connection_adapters/oracle_enhanced_database_tasks_spec.rb +14 -7
- data/spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb +5 -7
- data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +118 -127
- data/spec/active_record/connection_adapters/oracle_enhanced_emulate_oracle_adapter_spec.rb +2 -3
- data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +74 -78
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +68 -83
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +308 -321
- data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +103 -48
- data/spec/spec_config.yaml.template +11 -0
- data/spec/spec_helper.rb +59 -60
- data/spec/support/alter_system_user_password.sql +2 -0
- data/spec/support/create_oracle_enhanced_users.sql +31 -0
- metadata +25 -25
- data/.rspec +0 -2
- data/Gemfile +0 -22
- data/RUNNING_TESTS.md +0 -50
- data/Rakefile +0 -45
- data/activerecord-oracle_enhanced-adapter.gemspec +0 -95
- data/lib/active_record/connection_adapters/oracle_enhanced/cpk.rb +0 -21
- data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +0 -113
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
3
|
-
require
|
|
4
|
-
require 'tempfile'
|
|
1
|
+
require "active_record/connection_adapters/oracle_enhanced/database_tasks"
|
|
2
|
+
require "stringio"
|
|
3
|
+
require "tempfile"
|
|
5
4
|
|
|
6
5
|
describe "Oracle Enhanced adapter database tasks" do
|
|
7
6
|
let(:config) { CONNECTION_PARAMS.with_indifferent_access }
|
|
8
7
|
|
|
9
8
|
describe "create" do
|
|
10
|
-
let(:new_user_config) { config.merge(
|
|
9
|
+
let(:new_user_config) { config.merge(username: "oracle_enhanced_test_user") }
|
|
11
10
|
before do
|
|
12
11
|
fake_terminal(SYSTEM_CONNECTION_PARAMS[:password]) do
|
|
13
12
|
ActiveRecord::Tasks::DatabaseTasks.create(new_user_config)
|
|
@@ -34,6 +33,15 @@ describe "Oracle Enhanced adapter database tasks" do
|
|
|
34
33
|
end
|
|
35
34
|
|
|
36
35
|
context "with test table" do
|
|
36
|
+
before(:all) do
|
|
37
|
+
$stdout, @original_stdout = StringIO.new, $stdout
|
|
38
|
+
$stderr, @original_stderr = StringIO.new, $stderr
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
after(:all) do
|
|
42
|
+
$stdout, $stderr = @original_stdout, @original_stderr
|
|
43
|
+
end
|
|
44
|
+
|
|
37
45
|
before do
|
|
38
46
|
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
|
39
47
|
ActiveRecord::Base.connection.execute "CREATE TABLE test_posts (name VARCHAR2(20))"
|
|
@@ -66,7 +74,7 @@ describe "Oracle Enhanced adapter database tasks" do
|
|
|
66
74
|
it "dumps the database structure to a file without the schema information" do
|
|
67
75
|
contents = File.read(temp_file)
|
|
68
76
|
expect(contents).to include('CREATE TABLE "TEST_POSTS"')
|
|
69
|
-
expect(contents).not_to include(
|
|
77
|
+
expect(contents).not_to include("INSERT INTO schema_migrations")
|
|
70
78
|
end
|
|
71
79
|
end
|
|
72
80
|
|
|
@@ -90,4 +98,3 @@ describe "Oracle Enhanced adapter database tasks" do
|
|
|
90
98
|
after { ActiveRecord::Base.connection.execute "DROP TABLE test_posts" rescue nil }
|
|
91
99
|
end
|
|
92
100
|
end
|
|
93
|
-
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
1
|
describe "OracleEnhancedAdapter logging dbms_output from plsql" do
|
|
4
2
|
include LoggerSpecHelper
|
|
5
3
|
|
|
@@ -42,7 +40,7 @@ describe "OracleEnhancedAdapter logging dbms_output from plsql" do
|
|
|
42
40
|
it "should NOT log dbms output when dbms output is disabled" do
|
|
43
41
|
@conn.disable_dbms_output
|
|
44
42
|
|
|
45
|
-
expect(@conn.select_all("select more_than_five_characters_long('hi there') is_it_long from dual").to_a).to eq([{
|
|
43
|
+
expect(@conn.select_all("select more_than_five_characters_long('hi there') is_it_long from dual").to_a).to eq([{ "is_it_long" => 1 }])
|
|
46
44
|
|
|
47
45
|
expect(@logger.output(:debug)).not_to match(/^DBMS_OUTPUT/)
|
|
48
46
|
end
|
|
@@ -50,8 +48,8 @@ describe "OracleEnhancedAdapter logging dbms_output from plsql" do
|
|
|
50
48
|
it "should log dbms output lines to the rails log" do
|
|
51
49
|
@conn.enable_dbms_output
|
|
52
50
|
|
|
53
|
-
expect(@conn.select_all("select more_than_five_characters_long('hi there') is_it_long from dual").to_a).to eq([{
|
|
54
|
-
|
|
51
|
+
expect(@conn.select_all("select more_than_five_characters_long('hi there') is_it_long from dual").to_a).to eq([{ "is_it_long" => 1 }])
|
|
52
|
+
|
|
55
53
|
expect(@logger.output(:debug)).to match(/^DBMS_OUTPUT: before the if -hi there-$/)
|
|
56
54
|
expect(@logger.output(:debug)).to match(/^DBMS_OUTPUT: it is longer than 5$/)
|
|
57
55
|
expect(@logger.output(:debug)).to match(/^DBMS_OUTPUT: about to return: 1$/)
|
|
@@ -60,8 +58,8 @@ describe "OracleEnhancedAdapter logging dbms_output from plsql" do
|
|
|
60
58
|
it "should log dbms output lines to the rails log" do
|
|
61
59
|
@conn.enable_dbms_output
|
|
62
60
|
|
|
63
|
-
expect(@conn.select_all("select more_than_five_characters_long('short') is_it_long from dual").to_a).to eq([{
|
|
64
|
-
|
|
61
|
+
expect(@conn.select_all("select more_than_five_characters_long('short') is_it_long from dual").to_a).to eq([{ "is_it_long" => 0 }])
|
|
62
|
+
|
|
65
63
|
expect(@logger.output(:debug)).to match(/^DBMS_OUTPUT: before the if -short-$/)
|
|
66
64
|
expect(@logger.output(:debug)).to match(/^DBMS_OUTPUT: it is 5 or shorter$/)
|
|
67
65
|
expect(@logger.output(:debug)).to match(/^DBMS_OUTPUT: about to return: 0$/)
|
|
@@ -1,146 +1,137 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
id NUMBER PRIMARY KEY,
|
|
15
|
-
first_name VARCHAR2(20),
|
|
16
|
-
last_name VARCHAR2(25),
|
|
17
|
-
job_id NUMBER(6,0) NULL,
|
|
18
|
-
salary NUMBER(8,2),
|
|
19
|
-
comments CLOB,
|
|
20
|
-
hire_date DATE
|
|
21
|
-
)
|
|
22
|
-
SQL
|
|
23
|
-
@conn.execute <<-SQL
|
|
24
|
-
CREATE SEQUENCE test_employees_seq MINVALUE 1
|
|
25
|
-
INCREMENT BY 1 CACHE 20 NOORDER NOCYCLE
|
|
26
|
-
SQL
|
|
27
|
-
class TestEmployee < ActiveRecord::Base
|
|
1
|
+
describe "OracleEnhancedAdapter dirty object tracking" do
|
|
2
|
+
include SchemaSpecHelper
|
|
3
|
+
|
|
4
|
+
before(:all) do
|
|
5
|
+
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
|
6
|
+
schema_define do
|
|
7
|
+
create_table :test_employees, force: true do |t|
|
|
8
|
+
t.string :first_name, limit: 20
|
|
9
|
+
t.string :last_name, limit: 25
|
|
10
|
+
t.integer :job_id, limit: 6, null: true
|
|
11
|
+
t.decimal :salary, precision: 8, scale: 2
|
|
12
|
+
t.text :comments
|
|
13
|
+
t.date :hire_date
|
|
28
14
|
end
|
|
29
15
|
end
|
|
30
|
-
|
|
31
|
-
after(:all) do
|
|
32
|
-
Object.send(:remove_const, "TestEmployee")
|
|
33
|
-
@conn.execute "DROP TABLE test_employees"
|
|
34
|
-
@conn.execute "DROP SEQUENCE test_employees_seq"
|
|
35
|
-
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
|
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
|
-
expect(@employee).not_to be_changed
|
|
42
|
-
@employee.reload
|
|
43
|
-
@employee.first_name = ''
|
|
44
|
-
expect(@employee).not_to be_changed
|
|
45
|
-
end
|
|
46
16
|
|
|
47
|
-
|
|
48
|
-
@employee = TestEmployee.create!(:job_id => '')
|
|
49
|
-
@employee.job_id = ''
|
|
50
|
-
expect(@employee).not_to be_changed
|
|
51
|
-
@employee.reload
|
|
52
|
-
@employee.job_id = ''
|
|
53
|
-
expect(@employee).not_to be_changed
|
|
17
|
+
class TestEmployee < ActiveRecord::Base
|
|
54
18
|
end
|
|
19
|
+
end
|
|
55
20
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
expect(@employee).not_to be_changed
|
|
60
|
-
@employee.reload
|
|
61
|
-
@employee.salary = ''
|
|
62
|
-
expect(@employee).not_to be_changed
|
|
21
|
+
after(:all) do
|
|
22
|
+
schema_define do
|
|
23
|
+
drop_table :test_employees
|
|
63
24
|
end
|
|
25
|
+
Object.send(:remove_const, "TestEmployee")
|
|
26
|
+
ActiveRecord::Base.clear_cache!
|
|
27
|
+
end
|
|
64
28
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
29
|
+
it "should not mark empty string (stored as NULL) as changed when reassigning it" do
|
|
30
|
+
@employee = TestEmployee.create!(first_name: "")
|
|
31
|
+
@employee.first_name = ""
|
|
32
|
+
expect(@employee).not_to be_changed
|
|
33
|
+
@employee.reload
|
|
34
|
+
@employee.first_name = ""
|
|
35
|
+
expect(@employee).not_to be_changed
|
|
36
|
+
end
|
|
73
37
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
38
|
+
it "should not mark empty integer (stored as NULL) as changed when reassigning it" do
|
|
39
|
+
@employee = TestEmployee.create!(job_id: "")
|
|
40
|
+
@employee.job_id = ""
|
|
41
|
+
expect(@employee).not_to be_changed
|
|
42
|
+
@employee.reload
|
|
43
|
+
@employee.job_id = ""
|
|
44
|
+
expect(@employee).not_to be_changed
|
|
45
|
+
end
|
|
82
46
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
47
|
+
it "should not mark empty decimal (stored as NULL) as changed when reassigning it" do
|
|
48
|
+
@employee = TestEmployee.create!(salary: "")
|
|
49
|
+
@employee.salary = ""
|
|
50
|
+
expect(@employee).not_to be_changed
|
|
51
|
+
@employee.reload
|
|
52
|
+
@employee.salary = ""
|
|
53
|
+
expect(@employee).not_to be_changed
|
|
54
|
+
end
|
|
91
55
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
56
|
+
it "should not mark empty text (stored as NULL) as changed when reassigning it" do
|
|
57
|
+
@employee = TestEmployee.create!(comments: nil)
|
|
58
|
+
@employee.comments = nil
|
|
59
|
+
expect(@employee).not_to be_changed
|
|
60
|
+
@employee.reload
|
|
61
|
+
@employee.comments = nil
|
|
62
|
+
expect(@employee).not_to be_changed
|
|
63
|
+
end
|
|
100
64
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
65
|
+
it "should not mark empty text (stored as empty_clob()) as changed when reassigning it" do
|
|
66
|
+
@employee = TestEmployee.create!(comments: "")
|
|
67
|
+
@employee.comments = ""
|
|
68
|
+
expect(@employee).not_to be_changed
|
|
69
|
+
@employee.reload
|
|
70
|
+
@employee.comments = ""
|
|
71
|
+
expect(@employee).not_to be_changed
|
|
72
|
+
end
|
|
109
73
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
74
|
+
it "should mark empty text (stored as empty_clob()) as changed when assigning nil to it" do
|
|
75
|
+
@employee = TestEmployee.create!(comments: "")
|
|
76
|
+
@employee.comments = nil
|
|
77
|
+
expect(@employee).to be_changed
|
|
78
|
+
@employee.reload
|
|
79
|
+
@employee.comments = nil
|
|
80
|
+
expect(@employee).to be_changed
|
|
81
|
+
end
|
|
116
82
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
83
|
+
it "should mark empty text (stored as NULL) as changed when assigning '' to it" do
|
|
84
|
+
@employee = TestEmployee.create!(comments: nil)
|
|
85
|
+
@employee.comments = ""
|
|
86
|
+
expect(@employee).to be_changed
|
|
87
|
+
@employee.reload
|
|
88
|
+
@employee.comments = ""
|
|
89
|
+
expect(@employee).to be_changed
|
|
90
|
+
end
|
|
120
91
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
oci_conn = @conn.instance_variable_get('@connection')
|
|
130
|
-
class << oci_conn
|
|
131
|
-
def write_lob(lob, value, is_binary = false); raise "don't do this'"; end
|
|
132
|
-
end
|
|
133
|
-
expect{@employee.save!}.not_to raise_exception(RuntimeError, "don't do this'")
|
|
134
|
-
class << oci_conn
|
|
135
|
-
remove_method :write_lob
|
|
136
|
-
end
|
|
137
|
-
end
|
|
92
|
+
it "should not mark empty date (stored as NULL) as changed when reassigning it" do
|
|
93
|
+
@employee = TestEmployee.create!(hire_date: "")
|
|
94
|
+
@employee.hire_date = ""
|
|
95
|
+
expect(@employee).not_to be_changed
|
|
96
|
+
@employee.reload
|
|
97
|
+
@employee.hire_date = ""
|
|
98
|
+
expect(@employee).not_to be_changed
|
|
99
|
+
end
|
|
138
100
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
101
|
+
it "should not mark integer as changed when reassigning it" do
|
|
102
|
+
@employee = TestEmployee.new
|
|
103
|
+
@employee.job_id = 0
|
|
104
|
+
expect(@employee.save!).to be_truthy
|
|
105
|
+
|
|
106
|
+
expect(@employee).not_to be_changed
|
|
107
|
+
|
|
108
|
+
@employee.job_id = "0"
|
|
109
|
+
expect(@employee).not_to be_changed
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "should not update unchanged CLOBs" do
|
|
113
|
+
@conn = nil
|
|
114
|
+
@connection = nil
|
|
115
|
+
@employee = TestEmployee.create!(
|
|
116
|
+
comments: "initial"
|
|
117
|
+
)
|
|
118
|
+
expect(@employee.save!).to be_truthy
|
|
119
|
+
@employee.reload
|
|
120
|
+
expect(@employee.comments).to eq("initial")
|
|
121
|
+
|
|
122
|
+
oci_conn = @conn.instance_variable_get("@connection")
|
|
123
|
+
class << oci_conn
|
|
124
|
+
def write_lob(lob, value, is_binary = false); raise "don't do this'"; end
|
|
125
|
+
end
|
|
126
|
+
expect { @employee.save! }.not_to raise_error
|
|
127
|
+
class << oci_conn
|
|
128
|
+
remove_method :write_lob
|
|
143
129
|
end
|
|
144
130
|
end
|
|
145
131
|
|
|
132
|
+
it "should be able to handle attributes which are not backed by a column" do
|
|
133
|
+
TestEmployee.create!(comments: "initial")
|
|
134
|
+
@employee = TestEmployee.select("#{TestEmployee.quoted_table_name}.*, 24 ranking").first
|
|
135
|
+
expect { @employee.ranking = 25 }.to_not raise_error
|
|
136
|
+
end
|
|
146
137
|
end
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
1
|
describe "OracleEnhancedAdapter emulate OracleAdapter" do
|
|
4
2
|
|
|
5
3
|
before(:all) do
|
|
4
|
+
@old_oracle_adapter = nil
|
|
6
5
|
if defined?(ActiveRecord::ConnectionAdapters::OracleAdapter)
|
|
7
6
|
@old_oracle_adapter = ActiveRecord::ConnectionAdapters::OracleAdapter
|
|
8
7
|
ActiveRecord::ConnectionAdapters.send(:remove_const, :OracleAdapter)
|
|
@@ -10,7 +9,7 @@ describe "OracleEnhancedAdapter emulate OracleAdapter" do
|
|
|
10
9
|
end
|
|
11
10
|
|
|
12
11
|
it "should be an OracleAdapter" do
|
|
13
|
-
@conn = ActiveRecord::Base.establish_connection(CONNECTION_PARAMS.merge(:
|
|
12
|
+
@conn = ActiveRecord::Base.establish_connection(CONNECTION_PARAMS.merge(emulate_oracle_adapter: true))
|
|
14
13
|
expect(ActiveRecord::Base.connection).not_to be_nil
|
|
15
14
|
expect(ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::OracleAdapter)).to be_truthy
|
|
16
15
|
end
|