activerecord-oracle_enhanced-adapter 7.0.0 → 7.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +56 -0
- data/README.md +0 -1
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/column.rb +5 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/database_limits.rb +2 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +35 -27
- data/lib/active_record/connection_adapters/oracle_enhanced/dbms_output.rb +15 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +9 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +3 -3
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +24 -15
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_quoting.rb +3 -3
- data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +7 -5
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +5 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +24 -22
- data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +17 -17
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +72 -29
- data/lib/activerecord-oracle_enhanced-adapter.rb +8 -0
- data/lib/arel/visitors/oracle.rb +6 -3
- data/lib/arel/visitors/oracle12.rb +6 -5
- data/lib/arel/visitors/oracle_common.rb +46 -0
- data/spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb +24 -5
- data/spec/active_record/connection_adapters/oracle_enhanced/database_tasks_spec.rb +7 -2
- data/spec/active_record/connection_adapters/oracle_enhanced/dbms_output_spec.rb +2 -2
- data/spec/active_record/connection_adapters/oracle_enhanced/schema_dumper_spec.rb +3 -0
- data/spec/active_record/connection_adapters/oracle_enhanced/schema_statements_spec.rb +25 -15
- data/spec/active_record/connection_adapters/oracle_enhanced/structure_dump_spec.rb +15 -18
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +14 -10
- data/spec/active_record/oracle_enhanced/type/boolean_spec.rb +2 -2
- data/spec/active_record/oracle_enhanced/type/character_string_spec.rb +24 -0
- data/spec/active_record/oracle_enhanced/type/custom_spec.rb +90 -0
- data/spec/active_record/oracle_enhanced/type/dirty_spec.rb +4 -2
- data/spec/active_record/oracle_enhanced/type/integer_spec.rb +8 -0
- data/spec/active_record/oracle_enhanced/type/national_character_text_spec.rb +3 -3
- data/spec/active_record/oracle_enhanced/type/raw_spec.rb +15 -0
- data/spec/active_record/oracle_enhanced/type/text_spec.rb +18 -3
- data/spec/active_record/oracle_enhanced/type/timestamp_spec.rb +5 -1
- data/spec/spec_config.yaml.template +2 -2
- data/spec/spec_helper.rb +14 -3
- metadata +27 -9
@@ -24,6 +24,7 @@ describe "OracleEnhancedAdapter processing CHAR column" do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
after(:each) do
|
27
|
+
TestItem.delete_all
|
27
28
|
Object.send(:remove_const, "TestItem")
|
28
29
|
ActiveRecord::Base.clear_cache!
|
29
30
|
end
|
@@ -40,4 +41,27 @@ describe "OracleEnhancedAdapter processing CHAR column" do
|
|
40
41
|
item_reloaded = TestItem.first
|
41
42
|
expect(item_reloaded.padded).to eq(str)
|
42
43
|
end
|
44
|
+
|
45
|
+
it "should support case sensitive matching" do
|
46
|
+
TestItem.create!(
|
47
|
+
padded: "First",
|
48
|
+
)
|
49
|
+
TestItem.create!(
|
50
|
+
padded: "first",
|
51
|
+
)
|
52
|
+
|
53
|
+
expect(TestItem.where(TestItem.arel_table[:padded].matches("first%", "\\", true))).to have_attributes(count: 1)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should support case insensitive matching" do
|
57
|
+
TestItem.create!(
|
58
|
+
padded: "First",
|
59
|
+
)
|
60
|
+
TestItem.create!(
|
61
|
+
padded: "first",
|
62
|
+
)
|
63
|
+
|
64
|
+
expect(TestItem.where(TestItem.arel_table[:padded].matches("first%", "\\", false))).to have_attributes(count: 2)
|
65
|
+
expect(TestItem.where(TestItem.arel_table[:padded].matches("first%"))).to have_attributes(count: 2)
|
66
|
+
end
|
43
67
|
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "base64"
|
4
|
+
|
5
|
+
describe "OracleEnhancedAdapter custom types handling" do
|
6
|
+
include SchemaSpecHelper
|
7
|
+
|
8
|
+
before(:all) do
|
9
|
+
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
10
|
+
schema_define do
|
11
|
+
create_table :test_employees, force: true do |t|
|
12
|
+
t.string :first_name, limit: 20
|
13
|
+
t.string :last_name, limit: 25
|
14
|
+
t.text :signature
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class TestEmployee < ActiveRecord::Base
|
19
|
+
class AttributeSignature < ActiveRecord::Type::Text
|
20
|
+
def cast(value)
|
21
|
+
case value
|
22
|
+
when Signature
|
23
|
+
value
|
24
|
+
when nil
|
25
|
+
nil
|
26
|
+
else
|
27
|
+
Signature.new(Base64.decode64 value)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def serialize(value)
|
32
|
+
Base64.encode64 value.raw
|
33
|
+
end
|
34
|
+
|
35
|
+
def changed_in_place?(raw_old_value, new_value)
|
36
|
+
new_value != cast(raw_old_value)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class Signature
|
41
|
+
attr_reader :raw
|
42
|
+
|
43
|
+
def initialize(raw_value)
|
44
|
+
@raw = raw_value
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_s
|
48
|
+
"Signature nice string #{raw[0..5]}"
|
49
|
+
end
|
50
|
+
|
51
|
+
def ==(object)
|
52
|
+
raw == object&.raw
|
53
|
+
end
|
54
|
+
alias eql? ==
|
55
|
+
end
|
56
|
+
|
57
|
+
attribute :signature, AttributeSignature.new
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
after(:all) do
|
62
|
+
schema_define do
|
63
|
+
drop_table :test_employees
|
64
|
+
end
|
65
|
+
Object.send(:remove_const, "TestEmployee")
|
66
|
+
ActiveRecord::Base.clear_cache!
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should serialize LOBs when creating a record" do
|
70
|
+
raw_signature = "peter'ssignature"
|
71
|
+
signature = TestEmployee::Signature.new(raw_signature)
|
72
|
+
@employee = TestEmployee.create!(first_name: "Peter", last_name: "Doe", signature: signature)
|
73
|
+
@employee.reload
|
74
|
+
expect(@employee.signature).to eql(signature)
|
75
|
+
expect(@employee.signature).to_not be(signature)
|
76
|
+
expect(TestEmployee.first.read_attribute_before_type_cast(:signature)).to eq(Base64.encode64 raw_signature)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should serialize LOBs when updating a record" do
|
80
|
+
raw_signature = "peter'ssignature"
|
81
|
+
signature = TestEmployee::Signature.new(raw_signature)
|
82
|
+
@employee = TestEmployee.create!(first_name: "Peter", last_name: "Doe", signature: TestEmployee::Signature.new("old signature"))
|
83
|
+
@employee.signature = signature
|
84
|
+
@employee.save!
|
85
|
+
@employee.reload
|
86
|
+
expect(@employee.signature).to eql(signature)
|
87
|
+
expect(@employee.signature).to_not be(signature)
|
88
|
+
expect(TestEmployee.first.read_attribute_before_type_cast(:signature)).to eq(Base64.encode64 raw_signature)
|
89
|
+
end
|
90
|
+
end
|
@@ -113,7 +113,7 @@ describe "OracleEnhancedAdapter dirty object tracking" do
|
|
113
113
|
|
114
114
|
it "should not update unchanged CLOBs" do
|
115
115
|
@conn = nil
|
116
|
-
@
|
116
|
+
@raw_connection = nil
|
117
117
|
@employee = TestEmployee.create!(
|
118
118
|
comments: "initial"
|
119
119
|
)
|
@@ -121,10 +121,12 @@ describe "OracleEnhancedAdapter dirty object tracking" do
|
|
121
121
|
@employee.reload
|
122
122
|
expect(@employee.comments).to eq("initial")
|
123
123
|
|
124
|
-
oci_conn = @conn.instance_variable_get("@
|
124
|
+
oci_conn = @conn.instance_variable_get("@raw_connection")
|
125
125
|
class << oci_conn
|
126
126
|
def write_lob(lob, value, is_binary = false); raise "don't do this'"; end
|
127
127
|
end
|
128
|
+
@employee.comments = +"initial"
|
129
|
+
expect(@employee.comments_changed?).to be false
|
128
130
|
expect { @employee.save! }.not_to raise_error
|
129
131
|
class << oci_conn
|
130
132
|
remove_method :write_lob
|
@@ -87,5 +87,13 @@ describe "OracleEnhancedAdapter integer type detection based on attribute settin
|
|
87
87
|
create_employee2
|
88
88
|
expect(@employee2.is_manager).to be_a(Integer)
|
89
89
|
end
|
90
|
+
|
91
|
+
it "should return Integer value from NUMBER(1) column if emulate_booleans is set to false" do
|
92
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans = false
|
93
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.clear_type_map!
|
94
|
+
ActiveRecord::Base.clear_cache!
|
95
|
+
create_employee2
|
96
|
+
expect(@employee2.is_manager).to be_a(Integer)
|
97
|
+
end
|
90
98
|
end
|
91
99
|
end
|
@@ -79,7 +79,7 @@ describe "OracleEnhancedAdapter handling of NCLOB columns" do
|
|
79
79
|
@employee.reload
|
80
80
|
expect(@employee.comments).to eq(@nclob_data)
|
81
81
|
@employee.comments = @nclob_data2
|
82
|
-
expect(@employee.save).to
|
82
|
+
expect(@employee.save).to be(true)
|
83
83
|
@employee.reload
|
84
84
|
expect(@employee.comments).to eq(@nclob_data)
|
85
85
|
end
|
@@ -90,12 +90,12 @@ describe "OracleEnhancedAdapter handling of NCLOB columns" do
|
|
90
90
|
comments: nil
|
91
91
|
)
|
92
92
|
expect(@employee.comments).to be_nil
|
93
|
-
expect(@employee.save).to
|
93
|
+
expect(@employee.save).to be(true)
|
94
94
|
expect(@employee).to be_valid
|
95
95
|
@employee.reload
|
96
96
|
expect(@employee.comments).to be_nil
|
97
97
|
@employee.comments = {}
|
98
|
-
expect(@employee.save).to
|
98
|
+
expect(@employee.save).to be(true)
|
99
99
|
@employee.reload
|
100
100
|
# should not set readonly
|
101
101
|
expect(@employee.comments).to be_nil
|
@@ -119,4 +119,19 @@ describe "OracleEnhancedAdapter handling of RAW columns" do
|
|
119
119
|
@employee.reload
|
120
120
|
expect(@employee.binary_data).to eq(@binary_data)
|
121
121
|
end
|
122
|
+
|
123
|
+
it "should allow equality on select" do
|
124
|
+
TestEmployee.delete_all
|
125
|
+
TestEmployee.create!(
|
126
|
+
first_name: "First",
|
127
|
+
last_name: "Last",
|
128
|
+
binary_data: @binary_data,
|
129
|
+
)
|
130
|
+
TestEmployee.create!(
|
131
|
+
first_name: "First1",
|
132
|
+
last_name: "Last1",
|
133
|
+
binary_data: @binary_data2,
|
134
|
+
)
|
135
|
+
expect(TestEmployee.where(binary_data: @binary_data)).to have_attributes(count: 1)
|
136
|
+
end
|
122
137
|
end
|
@@ -78,7 +78,7 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
|
|
78
78
|
@employee.reload
|
79
79
|
expect(@employee.comments).to eq("initial")
|
80
80
|
@employee.comments = "changed"
|
81
|
-
expect(@employee.save).to
|
81
|
+
expect(@employee.save).to be(true)
|
82
82
|
@employee.reload
|
83
83
|
expect(@employee.comments).to eq("initial")
|
84
84
|
end
|
@@ -89,12 +89,12 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
|
|
89
89
|
comments: nil
|
90
90
|
)
|
91
91
|
expect(@employee.comments).to be_nil
|
92
|
-
expect(@employee.save).to
|
92
|
+
expect(@employee.save).to be(true)
|
93
93
|
expect(@employee).to be_valid
|
94
94
|
@employee.reload
|
95
95
|
expect(@employee.comments).to be_nil
|
96
96
|
@employee.comments = {}
|
97
|
-
expect(@employee.save).to
|
97
|
+
expect(@employee.save).to be(true)
|
98
98
|
@employee.reload
|
99
99
|
# should not set readonly
|
100
100
|
expect(@employee.comments).to be_nil
|
@@ -226,4 +226,19 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
|
|
226
226
|
@employee.reload
|
227
227
|
expect(@employee.comments).to eq(length: { is: 2 })
|
228
228
|
end
|
229
|
+
|
230
|
+
it "should allow equality on select" do
|
231
|
+
search_data = "text search CLOB"
|
232
|
+
Test2Employee.create!(
|
233
|
+
first_name: "First",
|
234
|
+
last_name: "Last",
|
235
|
+
comments: search_data,
|
236
|
+
)
|
237
|
+
Test2Employee.create!(
|
238
|
+
first_name: "First1",
|
239
|
+
last_name: "Last1",
|
240
|
+
comments: "other data",
|
241
|
+
)
|
242
|
+
expect(Test2Employee.where(comments: search_data)).to have_attributes(count: 1)
|
243
|
+
end
|
229
244
|
end
|
@@ -4,6 +4,10 @@ describe "OracleEnhancedAdapter timestamp with timezone support" do
|
|
4
4
|
include SchemaSpecHelper
|
5
5
|
|
6
6
|
before(:all) do
|
7
|
+
skip if ENV["DATABASE_SERVER_AND_CLIENT_VERSION_DO_NOT_MATCH"] == "true"
|
8
|
+
if ENV["DATABASE_VERSION"] == "11.2.0.2" && ENV["ORACLE_HOME"] == "/usr/lib/oracle/21/client64"
|
9
|
+
skip
|
10
|
+
end
|
7
11
|
ActiveRecord.default_timezone = :local
|
8
12
|
ActiveRecord::Base.establish_connection(CONNECTION_WITH_TIMEZONE_PARAMS)
|
9
13
|
@conn = ActiveRecord::Base.connection
|
@@ -27,7 +31,7 @@ describe "OracleEnhancedAdapter timestamp with timezone support" do
|
|
27
31
|
end
|
28
32
|
|
29
33
|
after(:all) do
|
30
|
-
@conn.drop_table :test_employees, if_exists: true
|
34
|
+
@conn.drop_table :test_employees, if_exists: true rescue nil
|
31
35
|
ActiveRecord.default_timezone = :utc
|
32
36
|
end
|
33
37
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# copy this file to spec/spec_config.yaml and set appropriate values
|
2
2
|
# you can also use environment variables, see spec_helper.rb
|
3
3
|
database:
|
4
|
-
name: '
|
4
|
+
name: 'FREEPDB1'
|
5
5
|
host: '127.0.0.1'
|
6
6
|
port: 1521
|
7
7
|
user: 'oracle_enhanced'
|
8
8
|
password: 'oracle_enhanced'
|
9
|
-
sys_password: '
|
9
|
+
sys_password: 'oracle'
|
10
10
|
non_default_tablespace: 'SYSTEM'
|
11
11
|
timezone: 'Europe/Riga'
|
data/spec/spec_helper.rb
CHANGED
@@ -57,6 +57,8 @@ module LoggerSpecHelper
|
|
57
57
|
end
|
58
58
|
|
59
59
|
class MockLogger
|
60
|
+
LEVELS = %i[debug info warn error fatal unknown]
|
61
|
+
|
60
62
|
attr_reader :flush_count
|
61
63
|
|
62
64
|
def initialize
|
@@ -64,13 +66,22 @@ module LoggerSpecHelper
|
|
64
66
|
@logged = Hash.new { |h, k| h[k] = [] }
|
65
67
|
end
|
66
68
|
|
67
|
-
# used in
|
69
|
+
# used in ActiveRecord 2.x
|
68
70
|
def debug?
|
69
71
|
true
|
70
72
|
end
|
71
73
|
|
72
|
-
def
|
73
|
-
|
74
|
+
def level
|
75
|
+
0
|
76
|
+
end
|
77
|
+
|
78
|
+
def method_missing(*args)
|
79
|
+
if LEVELS.include?(args[0])
|
80
|
+
level, message = args
|
81
|
+
@logged[level] << message
|
82
|
+
else
|
83
|
+
super
|
84
|
+
end
|
74
85
|
end
|
75
86
|
|
76
87
|
def logged(level)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-oracle_enhanced-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raimonds Simanovskis
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 7.
|
19
|
+
version: 7.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 7.
|
26
|
+
version: 7.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: ruby-plsql
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.6.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ruby-oci8
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: |
|
42
56
|
Oracle "enhanced" ActiveRecord adapter contains useful additional methods for working with new and legacy Oracle databases.
|
43
57
|
This adapter is superset of original ActiveRecord Oracle adapter.
|
@@ -88,6 +102,7 @@ files:
|
|
88
102
|
- lib/activerecord-oracle_enhanced-adapter.rb
|
89
103
|
- lib/arel/visitors/oracle.rb
|
90
104
|
- lib/arel/visitors/oracle12.rb
|
105
|
+
- lib/arel/visitors/oracle_common.rb
|
91
106
|
- spec/active_record/connection_adapters/emulation/oracle_adapter_spec.rb
|
92
107
|
- spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb
|
93
108
|
- spec/active_record/connection_adapters/oracle_enhanced/context_index_spec.rb
|
@@ -103,6 +118,7 @@ files:
|
|
103
118
|
- spec/active_record/oracle_enhanced/type/binary_spec.rb
|
104
119
|
- spec/active_record/oracle_enhanced/type/boolean_spec.rb
|
105
120
|
- spec/active_record/oracle_enhanced/type/character_string_spec.rb
|
121
|
+
- spec/active_record/oracle_enhanced/type/custom_spec.rb
|
106
122
|
- spec/active_record/oracle_enhanced/type/decimal_spec.rb
|
107
123
|
- spec/active_record/oracle_enhanced/type/dirty_spec.rb
|
108
124
|
- spec/active_record/oracle_enhanced/type/float_spec.rb
|
@@ -121,8 +137,9 @@ files:
|
|
121
137
|
homepage: http://github.com/rsim/oracle-enhanced
|
122
138
|
licenses:
|
123
139
|
- MIT
|
124
|
-
metadata:
|
125
|
-
|
140
|
+
metadata:
|
141
|
+
rubygems_mfa_required: 'true'
|
142
|
+
post_install_message:
|
126
143
|
rdoc_options: []
|
127
144
|
require_paths:
|
128
145
|
- lib
|
@@ -137,8 +154,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
154
|
- !ruby/object:Gem::Version
|
138
155
|
version: 1.8.11
|
139
156
|
requirements: []
|
140
|
-
rubygems_version: 3.
|
141
|
-
signing_key:
|
157
|
+
rubygems_version: 3.5.16
|
158
|
+
signing_key:
|
142
159
|
specification_version: 4
|
143
160
|
summary: Oracle enhanced adapter for ActiveRecord
|
144
161
|
test_files:
|
@@ -157,6 +174,7 @@ test_files:
|
|
157
174
|
- spec/active_record/oracle_enhanced/type/binary_spec.rb
|
158
175
|
- spec/active_record/oracle_enhanced/type/boolean_spec.rb
|
159
176
|
- spec/active_record/oracle_enhanced/type/character_string_spec.rb
|
177
|
+
- spec/active_record/oracle_enhanced/type/custom_spec.rb
|
160
178
|
- spec/active_record/oracle_enhanced/type/decimal_spec.rb
|
161
179
|
- spec/active_record/oracle_enhanced/type/dirty_spec.rb
|
162
180
|
- spec/active_record/oracle_enhanced/type/float_spec.rb
|