activerecord-oracle_enhanced-adapter 1.7.11 → 1.8.2
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 +206 -4
- data/README.md +37 -1
- 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 -59
- data/lib/active_record/connection_adapters/oracle_enhanced/column_dumper.rb +6 -50
- data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +11 -11
- data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +117 -117
- data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +37 -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 +56 -71
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +0 -7
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +51 -69
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_quoting.rb +4 -4
- data/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb +76 -76
- data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +14 -43
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +60 -64
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +33 -47
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +150 -160
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +95 -133
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +3 -3
- data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +66 -101
- data/lib/active_record/connection_adapters/oracle_enhanced/version.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +290 -533
- data/lib/active_record/oracle_enhanced/type/boolean.rb +7 -10
- data/lib/active_record/oracle_enhanced/type/integer.rb +3 -4
- data/lib/active_record/oracle_enhanced/type/json.rb +8 -0
- data/lib/active_record/oracle_enhanced/type/national_character_string.rb +1 -1
- data/lib/active_record/oracle_enhanced/type/raw.rb +2 -3
- data/lib/active_record/oracle_enhanced/type/string.rb +2 -2
- data/lib/active_record/oracle_enhanced/type/text.rb +2 -2
- data/lib/active_record/oracle_enhanced/type/timestamptz.rb +23 -0
- data/lib/activerecord-oracle_enhanced-adapter.rb +2 -2
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +55 -162
- data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +32 -34
- 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 +250 -357
- data/spec/active_record/connection_adapters/oracle_enhanced_database_tasks_spec.rb +14 -6
- data/spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb +3 -5
- data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +115 -124
- 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 +68 -72
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +64 -80
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +223 -329
- data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +18 -20
- data/spec/spec_config.yaml.template +11 -0
- data/spec/spec_helper.rb +59 -59
- 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 -83
- data/Rakefile +0 -45
- data/activerecord-oracle_enhanced-adapter.gemspec +0 -94
- data/lib/active_record/connection_adapters/oracle_enhanced/cpk.rb +0 -19
- 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
|
|
@@ -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,7 +48,7 @@ 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([{
|
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 }])
|
54
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$/)
|
@@ -60,7 +58,7 @@ 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([{
|
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 }])
|
64
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$/)
|
@@ -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
16
|
|
31
|
-
|
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!")
|
17
|
+
class TestEmployee < ActiveRecord::Base
|
36
18
|
end
|
19
|
+
end
|
37
20
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
expect(@employee).not_to be_changed
|
42
|
-
@employee.reload
|
43
|
-
@employee.first_name = ''
|
44
|
-
expect(@employee).not_to be_changed
|
21
|
+
after(:all) do
|
22
|
+
schema_define do
|
23
|
+
drop_table :test_employees
|
45
24
|
end
|
25
|
+
Object.send(:remove_const, "TestEmployee")
|
26
|
+
ActiveRecord::Base.clear_cache!
|
27
|
+
end
|
46
28
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
55
37
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
64
46
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
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
|
73
55
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
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
|
82
64
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
91
73
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
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
|
100
82
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
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
|
109
91
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
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
|
114
100
|
|
115
|
-
|
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
|
116
105
|
|
117
|
-
|
118
|
-
expect(@employee).not_to be_changed
|
119
|
-
end
|
106
|
+
expect(@employee).not_to be_changed
|
120
107
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
)
|
125
|
-
expect(@employee.save!).to be_truthy
|
126
|
-
@employee.reload
|
127
|
-
expect(@employee.comments).to eq('initial')
|
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
|
108
|
+
@employee.job_id = "0"
|
109
|
+
expect(@employee).not_to be_changed
|
110
|
+
end
|
138
111
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
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
|
@@ -1,6 +1,4 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
require 'ruby-plsql'
|
1
|
+
require "ruby-plsql"
|
4
2
|
|
5
3
|
describe "OracleEnhancedAdapter custom methods for create, update and destroy" do
|
6
4
|
include LoggerSpecHelper
|
@@ -95,7 +93,6 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
95
93
|
END;
|
96
94
|
SQL
|
97
95
|
|
98
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
|
99
96
|
end
|
100
97
|
|
101
98
|
after(:all) do
|
@@ -115,55 +112,55 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
115
112
|
# should return ID of new record
|
116
113
|
set_create_method do
|
117
114
|
plsql.test_employees_pkg.create_employee(
|
118
|
-
:
|
119
|
-
:
|
120
|
-
:
|
121
|
-
:
|
122
|
-
:
|
123
|
-
:
|
115
|
+
p_first_name: first_name,
|
116
|
+
p_last_name: last_name,
|
117
|
+
p_hire_date: hire_date,
|
118
|
+
p_salary: salary,
|
119
|
+
p_description: "#{first_name} #{last_name}",
|
120
|
+
p_employee_id: nil
|
124
121
|
)[:p_employee_id]
|
125
122
|
end
|
126
123
|
|
127
124
|
# return value is ignored
|
128
125
|
set_update_method do
|
129
126
|
plsql.test_employees_pkg.update_employee(
|
130
|
-
:
|
131
|
-
:
|
132
|
-
:
|
133
|
-
:
|
134
|
-
:
|
135
|
-
:
|
127
|
+
p_employee_id: id,
|
128
|
+
p_first_name: first_name,
|
129
|
+
p_last_name: last_name,
|
130
|
+
p_hire_date: hire_date,
|
131
|
+
p_salary: salary,
|
132
|
+
p_description: "#{first_name} #{last_name}"
|
136
133
|
)
|
137
134
|
end
|
138
135
|
|
139
136
|
# return value is ignored
|
140
137
|
set_delete_method do
|
141
138
|
plsql.test_employees_pkg.delete_employee(
|
142
|
-
:
|
139
|
+
p_employee_id: id
|
143
140
|
)
|
144
141
|
end
|
145
142
|
|
146
143
|
private
|
147
144
|
|
148
|
-
|
149
|
-
|
150
|
-
|
145
|
+
def raise_make_transaction_rollback
|
146
|
+
raise "Make the transaction rollback"
|
147
|
+
end
|
151
148
|
end
|
152
149
|
|
153
|
-
@today = Date.new(2008,6,28)
|
150
|
+
@today = Date.new(2008, 6, 28)
|
154
151
|
@buffer = StringIO.new
|
155
152
|
end
|
156
153
|
|
157
154
|
after(:each) do
|
158
155
|
Object.send(:remove_const, "TestEmployee")
|
159
|
-
ActiveRecord::Base.clear_cache!
|
156
|
+
ActiveRecord::Base.clear_cache!
|
160
157
|
end
|
161
158
|
|
162
159
|
it "should create record" do
|
163
160
|
@employee = TestEmployee.create(
|
164
|
-
:
|
165
|
-
:
|
166
|
-
:
|
161
|
+
first_name: "First",
|
162
|
+
last_name: "Last",
|
163
|
+
hire_date: @today
|
167
164
|
)
|
168
165
|
@employee.reload
|
169
166
|
expect(@employee.first_name).to eq("First")
|
@@ -178,9 +175,9 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
178
175
|
TestEmployee.after_create :raise_make_transaction_rollback
|
179
176
|
|
180
177
|
@employee = TestEmployee.new(
|
181
|
-
:
|
182
|
-
:
|
183
|
-
:
|
178
|
+
first_name: "First",
|
179
|
+
last_name: "Last",
|
180
|
+
hire_date: @today
|
184
181
|
)
|
185
182
|
employees_count = TestEmployee.count
|
186
183
|
expect {
|
@@ -192,10 +189,10 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
192
189
|
|
193
190
|
it "should update record" do
|
194
191
|
@employee = TestEmployee.create(
|
195
|
-
:
|
196
|
-
:
|
197
|
-
:
|
198
|
-
:
|
192
|
+
first_name: "First",
|
193
|
+
last_name: "Last",
|
194
|
+
hire_date: @today,
|
195
|
+
description: "description"
|
199
196
|
)
|
200
197
|
@employee.reload
|
201
198
|
@employee.first_name = "Second"
|
@@ -208,12 +205,11 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
208
205
|
TestEmployee.after_update :raise_make_transaction_rollback
|
209
206
|
|
210
207
|
@employee = TestEmployee.create(
|
211
|
-
:
|
212
|
-
:
|
213
|
-
:
|
214
|
-
:
|
208
|
+
first_name: "First",
|
209
|
+
last_name: "Last",
|
210
|
+
hire_date: @today,
|
211
|
+
description: "description"
|
215
212
|
)
|
216
|
-
empl_id = @employee.id
|
217
213
|
@employee.reload
|
218
214
|
@employee.first_name = "Second"
|
219
215
|
expect {
|
@@ -226,9 +222,9 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
226
222
|
it "should not update record if nothing is changed and partial writes are enabled" do
|
227
223
|
TestEmployee.partial_writes = true
|
228
224
|
@employee = TestEmployee.create(
|
229
|
-
:
|
230
|
-
:
|
231
|
-
:
|
225
|
+
first_name: "First",
|
226
|
+
last_name: "Last",
|
227
|
+
hire_date: @today
|
232
228
|
)
|
233
229
|
@employee.reload
|
234
230
|
@employee.save!
|
@@ -239,9 +235,9 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
239
235
|
it "should update record if nothing is changed and partial writes are disabled" do
|
240
236
|
TestEmployee.partial_writes = false
|
241
237
|
@employee = TestEmployee.create(
|
242
|
-
:
|
243
|
-
:
|
244
|
-
:
|
238
|
+
first_name: "First",
|
239
|
+
last_name: "Last",
|
240
|
+
hire_date: @today
|
245
241
|
)
|
246
242
|
@employee.reload
|
247
243
|
@employee.save!
|
@@ -251,9 +247,9 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
251
247
|
|
252
248
|
it "should delete record" do
|
253
249
|
@employee = TestEmployee.create(
|
254
|
-
:
|
255
|
-
:
|
256
|
-
:
|
250
|
+
first_name: "First",
|
251
|
+
last_name: "Last",
|
252
|
+
hire_date: @today
|
257
253
|
)
|
258
254
|
@employee.reload
|
259
255
|
empl_id = @employee.id
|
@@ -264,9 +260,9 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
264
260
|
|
265
261
|
it "should delete record and set destroyed flag" do
|
266
262
|
@employee = TestEmployee.create(
|
267
|
-
:
|
268
|
-
:
|
269
|
-
:
|
263
|
+
first_name: "First",
|
264
|
+
last_name: "Last",
|
265
|
+
hire_date: @today
|
270
266
|
)
|
271
267
|
@employee.reload
|
272
268
|
@employee.destroy
|
@@ -278,9 +274,9 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
278
274
|
TestEmployee.after_destroy :raise_make_transaction_rollback
|
279
275
|
|
280
276
|
@employee = TestEmployee.create(
|
281
|
-
:
|
282
|
-
:
|
283
|
-
:
|
277
|
+
first_name: "First",
|
278
|
+
last_name: "Last",
|
279
|
+
hire_date: @today
|
284
280
|
)
|
285
281
|
@employee.reload
|
286
282
|
empl_id = @employee.id
|
@@ -294,9 +290,9 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
294
290
|
|
295
291
|
it "should set timestamps when creating record" do
|
296
292
|
@employee = TestEmployee.create(
|
297
|
-
:
|
298
|
-
:
|
299
|
-
:
|
293
|
+
first_name: "First",
|
294
|
+
last_name: "Last",
|
295
|
+
hire_date: @today
|
300
296
|
)
|
301
297
|
expect(@employee.created_at).not_to be_nil
|
302
298
|
expect(@employee.updated_at).not_to be_nil
|
@@ -304,9 +300,9 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
304
300
|
|
305
301
|
it "should set timestamps when updating record" do
|
306
302
|
@employee = TestEmployee.create(
|
307
|
-
:
|
308
|
-
:
|
309
|
-
:
|
303
|
+
first_name: "First",
|
304
|
+
last_name: "Last",
|
305
|
+
hire_date: @today
|
310
306
|
)
|
311
307
|
@employee.reload
|
312
308
|
expect(@employee.created_at).to be_nil
|
@@ -320,9 +316,9 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
320
316
|
it "should log create record" do
|
321
317
|
set_logger
|
322
318
|
@employee = TestEmployee.create(
|
323
|
-
:
|
324
|
-
:
|
325
|
-
:
|
319
|
+
first_name: "First",
|
320
|
+
last_name: "Last",
|
321
|
+
hire_date: @today
|
326
322
|
)
|
327
323
|
expect(@logger.logged(:debug).last).to match(/^TestEmployee Create \(\d+\.\d+(ms)?\) custom create method$/)
|
328
324
|
clear_logger
|
@@ -331,9 +327,9 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
331
327
|
it "should log update record" do
|
332
328
|
(TestEmployee.partial_writes = false) rescue nil
|
333
329
|
@employee = TestEmployee.create(
|
334
|
-
:
|
335
|
-
:
|
336
|
-
:
|
330
|
+
first_name: "First",
|
331
|
+
last_name: "Last",
|
332
|
+
hire_date: @today
|
337
333
|
)
|
338
334
|
set_logger
|
339
335
|
@employee.save!
|
@@ -343,9 +339,9 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
343
339
|
|
344
340
|
it "should log delete record" do
|
345
341
|
@employee = TestEmployee.create(
|
346
|
-
:
|
347
|
-
:
|
348
|
-
:
|
342
|
+
first_name: "First",
|
343
|
+
last_name: "Last",
|
344
|
+
hire_date: @today
|
349
345
|
)
|
350
346
|
set_logger
|
351
347
|
@employee.destroy
|
@@ -355,8 +351,8 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
355
351
|
|
356
352
|
it "should validate new record before creation" do
|
357
353
|
@employee = TestEmployee.new(
|
358
|
-
:
|
359
|
-
:
|
354
|
+
last_name: "Last",
|
355
|
+
hire_date: @today
|
360
356
|
)
|
361
357
|
expect(@employee.save).to be_falsey
|
362
358
|
expect(@employee.errors[:first_name]).not_to be_blank
|
@@ -364,9 +360,9 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
364
360
|
|
365
361
|
it "should validate existing record before update" do
|
366
362
|
@employee = TestEmployee.create(
|
367
|
-
:
|
368
|
-
:
|
369
|
-
:
|
363
|
+
first_name: "First",
|
364
|
+
last_name: "Last",
|
365
|
+
hire_date: @today
|
370
366
|
)
|
371
367
|
@employee.first_name = nil
|
372
368
|
expect(@employee.save).to be_falsey
|