activerecord-oracle_enhanced-adapter 7.1.1 → 7.2.0.rc1
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 +8 -0
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +46 -48
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +20 -16
- data/lib/arel/visitors/oracle.rb +0 -8
- data/lib/arel/visitors/oracle12.rb +0 -8
- data/lib/arel/visitors/oracle_common.rb +5 -0
- data/spec/active_record/connection_adapters/emulation/oracle_adapter_spec.rb +1 -1
- data/spec/active_record/connection_adapters/oracle_enhanced/database_tasks_spec.rb +2 -2
- data/spec/active_record/connection_adapters/oracle_enhanced/schema_dumper_spec.rb +1 -1
- data/spec/active_record/connection_adapters/oracle_enhanced/schema_statements_spec.rb +2 -3
- data/spec/active_record/connection_adapters/oracle_enhanced/structure_dump_spec.rb +3 -3
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +6 -6
- data/spec/spec_helper.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c92688a843f4614eaa882ff1d56ed98355a231e17910c40c4e987f5ab1e9f6af
|
4
|
+
data.tar.gz: ba50fcb6cf763090ee2738e68b61562b2d6647b19ef50e3686c6c050c2ca3f1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f00d84542ab4c54b6ab9b4af21b2ec48f06f7f2caaefe5a32dcf980e96978714c1d3dfe0b3bf2850d4176cc980fc3c4c832d711bae3b9232c1647dd4314f209
|
7
|
+
data.tar.gz: 9b43052d20dbb1fade82857876130514dc4743f24d798567eea233a7753f2ac27806a7d14356875e3336142880ce9502a2bcc8308117df5ef6cd40ffe9573062
|
data/History.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 7.2.0.rc1 / 2025-06-18
|
2
|
+
|
3
|
+
* Changes and bug fixes
|
4
|
+
* Support Rails 7.2 [#2424]
|
5
|
+
* Bump the minimum Ruby version to 3.1 [#2442]
|
6
|
+
* Use RuboCop Plugin [#2427]
|
7
|
+
* Use Oracle Instant Client Version 23.8
|
8
|
+
|
1
9
|
## 7.1.1 / 2025-06-16
|
2
10
|
|
3
11
|
* Changes and bug fixes
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.
|
1
|
+
7.2.0.rc1
|
@@ -4,19 +4,58 @@ module ActiveRecord
|
|
4
4
|
module ConnectionAdapters
|
5
5
|
module OracleEnhanced
|
6
6
|
module Quoting
|
7
|
+
extend ActiveSupport::Concern
|
7
8
|
# QUOTING ==================================================
|
8
9
|
#
|
9
10
|
# see: abstract/quoting.rb
|
10
11
|
QUOTED_COLUMN_NAMES = Concurrent::Map.new # :nodoc:
|
11
12
|
QUOTED_TABLE_NAMES = Concurrent::Map.new # :nodoc:
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
module ClassMethods # :nodoc:
|
15
|
+
def column_name_matcher
|
16
|
+
/
|
17
|
+
\A
|
18
|
+
(
|
19
|
+
(?:
|
20
|
+
# "table_name"."column_name" | function(one or no argument)
|
21
|
+
((?:\w+\.|"\w+"\.)?(?:\w+|"\w+") | \w+\((?:|\g<2>)\))
|
22
|
+
)
|
23
|
+
(?:(?:\s+AS)?\s+(?:\w+|"\w+"))?
|
24
|
+
)
|
25
|
+
(?:\s*,\s*\g<1>)*
|
26
|
+
\z
|
27
|
+
/ix
|
28
|
+
end
|
29
|
+
|
30
|
+
def column_name_with_order_matcher
|
31
|
+
/
|
32
|
+
\A
|
33
|
+
(
|
34
|
+
(?:
|
35
|
+
# "table_name"."column_name" | function(one or no argument)
|
36
|
+
((?:\w+\.|"\w+"\.)?(?:\w+|"\w+") | \w+\((?:|\g<2>)\))
|
37
|
+
)
|
38
|
+
(?:\s+ASC|\s+DESC)?
|
39
|
+
(?:\s+NULLS\s+(?:FIRST|LAST))?
|
40
|
+
)
|
41
|
+
(?:\s*,\s*\g<1>)*
|
42
|
+
\z
|
43
|
+
/ix
|
44
|
+
end
|
45
|
+
|
46
|
+
def quote_column_name(name) # :nodoc:
|
47
|
+
name = name.to_s
|
48
|
+
QUOTED_COLUMN_NAMES[name] ||= if /\A[a-z][a-z_0-9$#]*\Z/.match?(name)
|
49
|
+
"\"#{name.upcase}\""
|
50
|
+
else
|
51
|
+
# remove double quotes which cannot be used inside quoted identifier
|
52
|
+
"\"#{name.delete('"')}\""
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def quote_table_name(name) # :nodoc:
|
57
|
+
name, _link = name.to_s.split("@")
|
58
|
+
QUOTED_TABLE_NAMES[name] ||= [name.split(".").map { |n| quote_column_name(n) }].join(".")
|
20
59
|
end
|
21
60
|
end
|
22
61
|
|
@@ -67,11 +106,6 @@ module ActiveRecord
|
|
67
106
|
!!(object_name =~ /[A-Z]/ && object_name =~ /[a-z]/)
|
68
107
|
end
|
69
108
|
|
70
|
-
def quote_table_name(name) # :nodoc:
|
71
|
-
name, _link = name.to_s.split("@")
|
72
|
-
QUOTED_TABLE_NAMES[name] ||= [name.split(".").map { |n| quote_column_name(n) }].join(".")
|
73
|
-
end
|
74
|
-
|
75
109
|
def quote_string(s) # :nodoc:
|
76
110
|
s.gsub(/'/, "''")
|
77
111
|
end
|
@@ -131,42 +165,6 @@ module ActiveRecord
|
|
131
165
|
end
|
132
166
|
end
|
133
167
|
|
134
|
-
def column_name_matcher
|
135
|
-
COLUMN_NAME
|
136
|
-
end
|
137
|
-
|
138
|
-
def column_name_with_order_matcher
|
139
|
-
COLUMN_NAME_WITH_ORDER
|
140
|
-
end
|
141
|
-
|
142
|
-
COLUMN_NAME = /
|
143
|
-
\A
|
144
|
-
(
|
145
|
-
(?:
|
146
|
-
# "table_name"."column_name" | function(one or no argument)
|
147
|
-
((?:\w+\.|"\w+"\.)?(?:\w+|"\w+") | \w+\((?:|\g<2>)\))
|
148
|
-
)
|
149
|
-
(?:(?:\s+AS)?\s+(?:\w+|"\w+"))?
|
150
|
-
)
|
151
|
-
(?:\s*,\s*\g<1>)*
|
152
|
-
\z
|
153
|
-
/ix
|
154
|
-
|
155
|
-
COLUMN_NAME_WITH_ORDER = /
|
156
|
-
\A
|
157
|
-
(
|
158
|
-
(?:
|
159
|
-
# "table_name"."column_name" | function(one or no argument)
|
160
|
-
((?:\w+\.|"\w+"\.)?(?:\w+|"\w+") | \w+\((?:|\g<2>)\))
|
161
|
-
)
|
162
|
-
(?:\s+ASC|\s+DESC)?
|
163
|
-
(?:\s+NULLS\s+(?:FIRST|LAST))?
|
164
|
-
)
|
165
|
-
(?:\s*,\s*\g<1>)*
|
166
|
-
\z
|
167
|
-
/ix
|
168
|
-
private_constant :COLUMN_NAME, :COLUMN_NAME_WITH_ORDER
|
169
|
-
|
170
168
|
private
|
171
169
|
def oracle_downcase(column_name)
|
172
170
|
return nil if column_name.nil?
|
@@ -276,7 +276,7 @@ module ActiveRecord
|
|
276
276
|
end
|
277
277
|
|
278
278
|
def insert_versions_sql(versions) # :nodoc:
|
279
|
-
sm_table = quote_table_name(ActiveRecord::
|
279
|
+
sm_table = quote_table_name(ActiveRecord::Tasks::DatabaseTasks.migration_connection_pool.schema_migration.table_name)
|
280
280
|
|
281
281
|
if supports_multi_insert?
|
282
282
|
versions.inject(+"INSERT ALL\n") { |sql, version|
|
@@ -63,22 +63,6 @@ require "active_record/type/oracle_enhanced/timestampltz"
|
|
63
63
|
require "active_record/type/oracle_enhanced/character_string"
|
64
64
|
|
65
65
|
module ActiveRecord
|
66
|
-
module ConnectionHandling # :nodoc:
|
67
|
-
# Establishes a connection to the database that's used by all Active Record objects.
|
68
|
-
def oracle_enhanced_connection(config) # :nodoc:
|
69
|
-
if config[:emulate_oracle_adapter] == true
|
70
|
-
# allows the enhanced adapter to look like the OracleAdapter. Useful to pick up
|
71
|
-
# conditionals in the rails activerecord test suite
|
72
|
-
require "active_record/connection_adapters/emulation/oracle_adapter"
|
73
|
-
ConnectionAdapters::OracleAdapter.new(
|
74
|
-
ConnectionAdapters::OracleEnhanced::Connection.create(config), logger, config)
|
75
|
-
else
|
76
|
-
ConnectionAdapters::OracleEnhancedAdapter.new(
|
77
|
-
ConnectionAdapters::OracleEnhanced::Connection.create(config), logger, config)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
66
|
module ConnectionAdapters # :nodoc:
|
83
67
|
# Oracle enhanced adapter will work with both
|
84
68
|
# CRuby ruby-oci8 gem (which provides interface to Oracle OCI client)
|
@@ -837,6 +821,26 @@ module ActiveRecord
|
|
837
821
|
end
|
838
822
|
end
|
839
823
|
|
824
|
+
## Register OracleEnhancedAdapter as the adapter to use for "oracle_enhanced" connection string
|
825
|
+
if ActiveRecord::ConnectionAdapters.respond_to?(:register)
|
826
|
+
ActiveRecord::ConnectionAdapters.register(
|
827
|
+
"oracle_enhanced",
|
828
|
+
"ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter",
|
829
|
+
"active_record/connection_adapters/oracle_enhanced_adapter"
|
830
|
+
)
|
831
|
+
|
832
|
+
# This is similar to the notion of emulating the original OracleAdapter but
|
833
|
+
# using the OracleEnhancedAdapter instead, but without using the emulate flag.
|
834
|
+
# Instead this will get picked up if you set the adapter to 'oracle' in the database config.
|
835
|
+
#
|
836
|
+
# Register OracleAdapter as the adapter to use for "oracle" connection string
|
837
|
+
ActiveRecord::ConnectionAdapters.register(
|
838
|
+
"oracle",
|
839
|
+
"ActiveRecord::ConnectionAdapters::OracleAdapter",
|
840
|
+
"active_record/connection_adapters/emulation/oracle_adapter"
|
841
|
+
)
|
842
|
+
end
|
843
|
+
|
840
844
|
require "active_record/connection_adapters/oracle_enhanced/version"
|
841
845
|
|
842
846
|
module ActiveRecord
|
data/lib/arel/visitors/oracle.rb
CHANGED
@@ -195,14 +195,6 @@ module Arel # :nodoc: all
|
|
195
195
|
array
|
196
196
|
end
|
197
197
|
|
198
|
-
def visit_ActiveModel_Attribute(o, collector)
|
199
|
-
collector.add_bind(o) { |i| ":a#{i}" }
|
200
|
-
end
|
201
|
-
|
202
|
-
def visit_Arel_Nodes_BindParam(o, collector)
|
203
|
-
collector.add_bind(o.value) { |i| ":a#{i}" }
|
204
|
-
end
|
205
|
-
|
206
198
|
def is_distinct_from(o, collector)
|
207
199
|
collector << "DECODE("
|
208
200
|
collector = visit [o.left, o.right, 0, 1], collector
|
@@ -100,14 +100,6 @@ module Arel # :nodoc: all
|
|
100
100
|
super
|
101
101
|
end
|
102
102
|
|
103
|
-
def visit_ActiveModel_Attribute(o, collector)
|
104
|
-
collector.add_bind(o) { |i| ":a#{i}" }
|
105
|
-
end
|
106
|
-
|
107
|
-
def visit_Arel_Nodes_BindParam(o, collector)
|
108
|
-
collector.add_bind(o.value) { |i| ":a#{i}" }
|
109
|
-
end
|
110
|
-
|
111
103
|
def is_distinct_from(o, collector)
|
112
104
|
collector << "DECODE("
|
113
105
|
collector = visit [o.left, o.right, 0, 1], collector
|
@@ -3,6 +3,11 @@
|
|
3
3
|
module Arel # :nodoc: all
|
4
4
|
module Visitors
|
5
5
|
module OracleCommon
|
6
|
+
BIND_BLOCK = proc { |i| ":a#{i}" }
|
7
|
+
private_constant :BIND_BLOCK
|
8
|
+
|
9
|
+
def bind_block; BIND_BLOCK; end
|
10
|
+
|
6
11
|
private
|
7
12
|
# Oracle can't compare CLOB columns with standard SQL operators for comparison.
|
8
13
|
# We need to replace standard equality for text/binary columns to use DBMS_LOB.COMPARE function.
|
@@ -10,7 +10,7 @@ describe "OracleEnhancedAdapter emulate OracleAdapter" do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should be an OracleAdapter" do
|
13
|
-
@conn = ActiveRecord::Base.establish_connection(CONNECTION_PARAMS.merge(
|
13
|
+
@conn = ActiveRecord::Base.establish_connection(CONNECTION_PARAMS.merge(adapter: "oracle"))
|
14
14
|
expect(ActiveRecord::Base.connection).not_to be_nil
|
15
15
|
expect(ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::OracleAdapter)).to be_truthy
|
16
16
|
end
|
@@ -81,7 +81,7 @@ describe "Oracle Enhanced adapter database tasks" do
|
|
81
81
|
describe "structure" do
|
82
82
|
let(:temp_file) { Tempfile.create(["oracle_enhanced", ".sql"]).path }
|
83
83
|
before do
|
84
|
-
ActiveRecord::Base.
|
84
|
+
ActiveRecord::Base.connection_pool.schema_migration.create_table
|
85
85
|
ActiveRecord::Base.connection.execute "INSERT INTO schema_migrations (version) VALUES ('20150101010000')"
|
86
86
|
end
|
87
87
|
|
@@ -109,7 +109,7 @@ describe "Oracle Enhanced adapter database tasks" do
|
|
109
109
|
|
110
110
|
after do
|
111
111
|
File.unlink(temp_file)
|
112
|
-
ActiveRecord::Base.
|
112
|
+
ActiveRecord::Base.connection_pool.schema_migration.drop_table
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
@@ -14,7 +14,7 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
14
14
|
def standard_dump(options = {})
|
15
15
|
stream = StringIO.new
|
16
16
|
ActiveRecord::SchemaDumper.ignore_tables = options[:ignore_tables] || []
|
17
|
-
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.
|
17
|
+
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection_pool, stream)
|
18
18
|
stream.string
|
19
19
|
end
|
20
20
|
|
@@ -1255,8 +1255,7 @@ end
|
|
1255
1255
|
|
1256
1256
|
before do
|
1257
1257
|
@conn = ActiveRecord::Base.connection
|
1258
|
-
|
1259
|
-
ActiveRecord::Base.connection.schema_migration.create_table
|
1258
|
+
ActiveRecord::Base.connection_pool.schema_migration.create_table
|
1260
1259
|
end
|
1261
1260
|
|
1262
1261
|
context "multi insert is supported" do
|
@@ -1284,7 +1283,7 @@ end
|
|
1284
1283
|
end
|
1285
1284
|
|
1286
1285
|
after do
|
1287
|
-
ActiveRecord::Base.
|
1286
|
+
ActiveRecord::Base.connection_pool.schema_migration.drop_table
|
1288
1287
|
end
|
1289
1288
|
end
|
1290
1289
|
end
|
@@ -334,9 +334,9 @@ describe "OracleEnhancedAdapter structure dump" do
|
|
334
334
|
let(:dump) { ActiveRecord::Base.connection.dump_schema_information }
|
335
335
|
|
336
336
|
before do
|
337
|
-
ActiveRecord::Base.
|
337
|
+
ActiveRecord::Base.connection_pool.schema_migration.create_table
|
338
338
|
versions.each do |i|
|
339
|
-
ActiveRecord::Base.
|
339
|
+
ActiveRecord::Base.connection_pool.schema_migration.create_version(i)
|
340
340
|
end
|
341
341
|
end
|
342
342
|
|
@@ -376,7 +376,7 @@ describe "OracleEnhancedAdapter structure dump" do
|
|
376
376
|
end
|
377
377
|
|
378
378
|
after do
|
379
|
-
ActiveRecord::Base.
|
379
|
+
ActiveRecord::Base.connection_pool.schema_migration.drop_table
|
380
380
|
end
|
381
381
|
end
|
382
382
|
|
@@ -354,15 +354,15 @@ describe "OracleEnhancedAdapter" do
|
|
354
354
|
|
355
355
|
it "should explain query" do
|
356
356
|
explain = TestPost.where(id: 1).explain
|
357
|
-
expect(explain).to include("Cost")
|
358
|
-
expect(explain).to include("INDEX UNIQUE SCAN")
|
357
|
+
expect(explain.inspect).to include("Cost")
|
358
|
+
expect(explain.inspect).to include("INDEX UNIQUE SCAN")
|
359
359
|
end
|
360
360
|
|
361
361
|
it "should explain query with binds" do
|
362
362
|
binds = [ActiveRecord::Relation::QueryAttribute.new("id", 1, ActiveRecord::Type::OracleEnhanced::Integer.new)]
|
363
363
|
explain = TestPost.where(id: binds).explain
|
364
|
-
expect(explain).to include("Cost")
|
365
|
-
expect(explain).to include("INDEX UNIQUE SCAN").or include("TABLE ACCESS FULL")
|
364
|
+
expect(explain.inspect).to include("Cost")
|
365
|
+
expect(explain.inspect).to include("INDEX UNIQUE SCAN").or include("TABLE ACCESS FULL")
|
366
366
|
end
|
367
367
|
end
|
368
368
|
|
@@ -768,13 +768,13 @@ describe "OracleEnhancedAdapter" do
|
|
768
768
|
it "should explain considers hints" do
|
769
769
|
post = TestPost.optimizer_hints("FULL (\"TEST_POSTS\")")
|
770
770
|
post = post.where(id: 1)
|
771
|
-
expect(post.explain).to include("| TABLE ACCESS FULL| TEST_POSTS |")
|
771
|
+
expect(post.explain.inspect).to include("| TABLE ACCESS FULL| TEST_POSTS |")
|
772
772
|
end
|
773
773
|
|
774
774
|
it "should explain considers hints with /*+ */" do
|
775
775
|
post = TestPost.optimizer_hints("/*+ FULL (\"TEST_POSTS\") */")
|
776
776
|
post = post.where(id: 1)
|
777
|
-
expect(post.explain).to include("| TABLE ACCESS FULL| TEST_POSTS |")
|
777
|
+
expect(post.explain.inspect).to include("| TABLE ACCESS FULL| TEST_POSTS |")
|
778
778
|
end
|
779
779
|
end
|
780
780
|
|
data/spec/spec_helper.rb
CHANGED
@@ -33,9 +33,9 @@ require "active_support/log_subscriber"
|
|
33
33
|
require "active_record/log_subscriber"
|
34
34
|
|
35
35
|
require "logger"
|
36
|
+
require "ruby-plsql"
|
36
37
|
|
37
38
|
require "active_record/connection_adapters/oracle_enhanced_adapter"
|
38
|
-
require "ruby-plsql"
|
39
39
|
|
40
40
|
puts "==> Effective ActiveRecord version #{ActiveRecord::VERSION::STRING}"
|
41
41
|
|
@@ -133,7 +133,7 @@ module SchemaDumpingHelper
|
|
133
133
|
old_ignore_tables = ActiveRecord::SchemaDumper.ignore_tables
|
134
134
|
ActiveRecord::SchemaDumper.ignore_tables = connection.data_sources - [table]
|
135
135
|
stream = StringIO.new
|
136
|
-
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.
|
136
|
+
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection_pool, stream)
|
137
137
|
stream.string
|
138
138
|
ensure
|
139
139
|
ActiveRecord::SchemaDumper.ignore_tables = old_ignore_tables
|
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: 7.
|
4
|
+
version: 7.2.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raimonds Simanovskis
|
@@ -15,14 +15,14 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 7.
|
18
|
+
version: 7.2.0
|
19
19
|
type: :runtime
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
23
|
- - "~>"
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: 7.
|
25
|
+
version: 7.2.0
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: ruby-plsql
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
146
|
requirements:
|
147
147
|
- - ">="
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version:
|
149
|
+
version: 3.1.0
|
150
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
151
|
requirements:
|
152
152
|
- - ">="
|