activerecord-oracle_enhanced-adapter 6.0.5 → 6.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +109 -4
- data/README.md +12 -1
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +3 -4
- data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +0 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/database_limits.rb +0 -9
- data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +9 -7
- data/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb +8 -9
- data/lib/active_record/connection_adapters/oracle_enhanced/dbms_output.rb +0 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +3 -4
- data/lib/active_record/connection_adapters/oracle_enhanced/lob.rb +1 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +2 -3
- data/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb +0 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +2 -3
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +2 -3
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +15 -3
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +43 -40
- data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +19 -19
- data/lib/active_record/connection_adapters/oracle_enhanced/type_metadata.rb +2 -1
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +52 -33
- data/lib/active_record/type/oracle_enhanced/boolean.rb +0 -1
- data/lib/active_record/type/oracle_enhanced/integer.rb +0 -1
- data/lib/arel/visitors/oracle.rb +217 -0
- data/lib/arel/visitors/oracle12.rb +124 -0
- data/spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb +9 -3
- data/spec/active_record/connection_adapters/oracle_enhanced/database_tasks_spec.rb +5 -0
- data/spec/active_record/connection_adapters/oracle_enhanced/procedures_spec.rb +0 -1
- data/spec/active_record/connection_adapters/oracle_enhanced/schema_dumper_spec.rb +27 -0
- data/spec/active_record/connection_adapters/oracle_enhanced/structure_dump_spec.rb +2 -2
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +122 -0
- data/spec/active_record/oracle_enhanced/type/national_character_string_spec.rb +4 -2
- data/spec/spec_config.yaml.template +2 -2
- data/spec/spec_helper.rb +13 -2
- metadata +22 -20
@@ -66,7 +66,7 @@ describe "OracleEnhancedAdapter structure dump" do
|
|
66
66
|
ALTER TABLE TEST_POSTS
|
67
67
|
ADD CONSTRAINT fk_test_post_foo FOREIGN KEY (foo_id) REFERENCES foos(id)
|
68
68
|
SQL
|
69
|
-
dump = ActiveRecord::Base.connection.
|
69
|
+
dump = ActiveRecord::Base.connection.structure_dump
|
70
70
|
expect(dump.split('\n').length).to eq(1)
|
71
71
|
expect(dump).to match(/ALTER TABLE \"?TEST_POSTS\"? ADD CONSTRAINT \"?FK_TEST_POST_FOO\"? FOREIGN KEY \(\"?FOO_ID\"?\) REFERENCES \"?FOOS\"?\(\"?ID\"?\)/i)
|
72
72
|
end
|
@@ -86,7 +86,7 @@ describe "OracleEnhancedAdapter structure dump" do
|
|
86
86
|
ADD CONSTRAINT fk_test_post_baz FOREIGN KEY (baz_id) REFERENCES foos(baz_id)
|
87
87
|
SQL
|
88
88
|
|
89
|
-
dump = ActiveRecord::Base.connection.
|
89
|
+
dump = ActiveRecord::Base.connection.structure_dump
|
90
90
|
expect(dump.split('\n').length).to eq(1)
|
91
91
|
expect(dump).to match(/ALTER TABLE \"?TEST_POSTS\"? ADD CONSTRAINT \"?FK_TEST_POST_BAZ\"? FOREIGN KEY \(\"?BAZ_ID\"?\) REFERENCES \"?FOOS\"?\(\"?BAZ_ID\"?\)/i)
|
92
92
|
end
|
@@ -232,6 +232,46 @@ describe "OracleEnhancedAdapter" do
|
|
232
232
|
end
|
233
233
|
end
|
234
234
|
|
235
|
+
describe "lists" do
|
236
|
+
before(:all) do
|
237
|
+
schema_define do
|
238
|
+
create_table :test_posts do |t|
|
239
|
+
t.string :title
|
240
|
+
end
|
241
|
+
end
|
242
|
+
class ::TestPost < ActiveRecord::Base
|
243
|
+
has_many :test_comments
|
244
|
+
end
|
245
|
+
@ids = (1..1010).to_a
|
246
|
+
TestPost.transaction do
|
247
|
+
@ids.each do |id|
|
248
|
+
TestPost.create!(id: id, title: "Title #{id}")
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
after(:all) do
|
254
|
+
schema_define do
|
255
|
+
drop_table :test_posts
|
256
|
+
end
|
257
|
+
Object.send(:remove_const, "TestPost")
|
258
|
+
ActiveRecord::Base.clear_cache!
|
259
|
+
end
|
260
|
+
|
261
|
+
##
|
262
|
+
# See this GitHub issue for an explanation of homogenous lists.
|
263
|
+
# https://github.com/rails/rails/commit/72fd0bae5948c1169411941aeea6fef4c58f34a9
|
264
|
+
it "should allow more than 1000 items in a list where the list is homogenous" do
|
265
|
+
posts = TestPost.where(id: @ids).to_a
|
266
|
+
expect(posts.size).to eq(@ids.size)
|
267
|
+
end
|
268
|
+
|
269
|
+
it "should allow more than 1000 items in a list where the list is non-homogenous" do
|
270
|
+
posts = TestPost.where(id: [*@ids, nil]).to_a
|
271
|
+
expect(posts.size).to eq(@ids.size)
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
235
275
|
describe "with statement pool" do
|
236
276
|
before(:all) do
|
237
277
|
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS.merge(statement_limit: 3))
|
@@ -283,6 +323,14 @@ describe "OracleEnhancedAdapter" do
|
|
283
323
|
end
|
284
324
|
end
|
285
325
|
|
326
|
+
describe "database_exists?" do
|
327
|
+
it "should raise `NotImplementedError`" do
|
328
|
+
expect {
|
329
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.database_exists?(CONNECTION_PARAMS)
|
330
|
+
}.to raise_error(NotImplementedError)
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
286
334
|
describe "explain" do
|
287
335
|
before(:all) do
|
288
336
|
@conn = ActiveRecord::Base.connection
|
@@ -431,6 +479,45 @@ describe "OracleEnhancedAdapter" do
|
|
431
479
|
end
|
432
480
|
end
|
433
481
|
|
482
|
+
describe "Binary lob column" do
|
483
|
+
before(:all) do
|
484
|
+
schema_define do
|
485
|
+
create_table :test_binary_columns do |t|
|
486
|
+
t.binary :attachment
|
487
|
+
end
|
488
|
+
end
|
489
|
+
class ::TestBinaryColumn < ActiveRecord::Base
|
490
|
+
end
|
491
|
+
end
|
492
|
+
|
493
|
+
after(:all) do
|
494
|
+
schema_define do
|
495
|
+
drop_table :test_binary_columns
|
496
|
+
end
|
497
|
+
Object.send(:remove_const, "TestBinaryColumn")
|
498
|
+
ActiveRecord::Base.table_name_prefix = nil
|
499
|
+
ActiveRecord::Base.clear_cache!
|
500
|
+
end
|
501
|
+
|
502
|
+
before(:each) do
|
503
|
+
set_logger
|
504
|
+
end
|
505
|
+
|
506
|
+
after(:each) do
|
507
|
+
clear_logger
|
508
|
+
end
|
509
|
+
|
510
|
+
it "should serialize with non UTF-8 data" do
|
511
|
+
binary_value = +"Hello \x93\xfa\x96\x7b"
|
512
|
+
binary_value.force_encoding "UTF-8"
|
513
|
+
|
514
|
+
binary_column_object = TestBinaryColumn.new
|
515
|
+
binary_column_object.attachment = binary_value
|
516
|
+
|
517
|
+
expect(binary_column_object.save!).to eq(true)
|
518
|
+
end
|
519
|
+
end
|
520
|
+
|
434
521
|
describe "quoting" do
|
435
522
|
before(:all) do
|
436
523
|
schema_define do
|
@@ -659,4 +746,39 @@ describe "OracleEnhancedAdapter" do
|
|
659
746
|
expect(post.explain).to include("| TABLE ACCESS FULL| TEST_POSTS |")
|
660
747
|
end
|
661
748
|
end
|
749
|
+
|
750
|
+
describe "homogeneous in" do
|
751
|
+
before(:all) do
|
752
|
+
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
753
|
+
@conn = ActiveRecord::Base.connection
|
754
|
+
schema_define do
|
755
|
+
create_table :test_posts, force: true
|
756
|
+
create_table :test_comments, force: true do |t|
|
757
|
+
t.integer :test_post_id
|
758
|
+
end
|
759
|
+
end
|
760
|
+
class ::TestPost < ActiveRecord::Base
|
761
|
+
has_many :test_comments
|
762
|
+
end
|
763
|
+
class ::TestComment < ActiveRecord::Base
|
764
|
+
belongs_to :test_post
|
765
|
+
end
|
766
|
+
end
|
767
|
+
|
768
|
+
after(:all) do
|
769
|
+
schema_define do
|
770
|
+
drop_table :test_posts, if_exists: true
|
771
|
+
drop_table :test_comments, if_exists: true
|
772
|
+
end
|
773
|
+
Object.send(:remove_const, "TestPost")
|
774
|
+
Object.send(:remove_const, "TestComment")
|
775
|
+
ActiveRecord::Base.clear_cache!
|
776
|
+
end
|
777
|
+
|
778
|
+
it "should not raise undefined method length" do
|
779
|
+
post = TestPost.create!
|
780
|
+
post.test_comments << TestComment.create!
|
781
|
+
expect(TestComment.where(test_post_id: TestPost.select(:id)).size).to eq(1)
|
782
|
+
end
|
783
|
+
end
|
662
784
|
end
|
@@ -35,9 +35,11 @@ describe "OracleEnhancedAdapter quoting of NCHAR and NVARCHAR2 columns" do
|
|
35
35
|
columns = @conn.columns("test_items")
|
36
36
|
%w(nchar_column nvarchar2_column char_column varchar2_column).each do |col|
|
37
37
|
column = columns.detect { |c| c.name == col }
|
38
|
-
|
38
|
+
type = @conn.lookup_cast_type_from_column(column)
|
39
|
+
value = type.serialize("abc")
|
39
40
|
expect(@conn.quote(value)).to eq(column.sql_type[0, 1] == "N" ? "N'abc'" : "'abc'")
|
40
|
-
|
41
|
+
type = @conn.lookup_cast_type_from_column(column)
|
42
|
+
nilvalue = type.serialize(nil)
|
41
43
|
expect(@conn.quote(nilvalue)).to eq("NULL")
|
42
44
|
end
|
43
45
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# copy this file to spec/
|
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
4
|
name: 'orcl'
|
@@ -8,4 +8,4 @@ database:
|
|
8
8
|
password: 'oracle_enhanced'
|
9
9
|
sys_password: 'admin'
|
10
10
|
non_default_tablespace: 'SYSTEM'
|
11
|
-
timezone: 'Europe/Riga'
|
11
|
+
timezone: 'Europe/Riga'
|
data/spec/spec_helper.rb
CHANGED
@@ -17,8 +17,8 @@ end
|
|
17
17
|
|
18
18
|
require "rspec"
|
19
19
|
|
20
|
-
if !defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby"
|
21
|
-
puts "==> Running specs with
|
20
|
+
if !defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" || RUBY_ENGINE == "truffleruby"
|
21
|
+
puts "==> Running specs with ruby version #{RUBY_VERSION}"
|
22
22
|
require "oci8"
|
23
23
|
elsif RUBY_ENGINE == "jruby"
|
24
24
|
puts "==> Running specs with JRuby version #{JRUBY_VERSION}"
|
@@ -105,6 +105,8 @@ module LoggerSpecHelper
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
+
ActiveRecord::LogSubscriber::IGNORE_PAYLOAD_NAMES.replace(["EXPLAIN"])
|
109
|
+
|
108
110
|
module SchemaSpecHelper
|
109
111
|
def schema_define(&block)
|
110
112
|
ActiveRecord::Schema.define do
|
@@ -183,6 +185,15 @@ SYSTEM_CONNECTION_PARAMS = {
|
|
183
185
|
password: DATABASE_SYS_PASSWORD
|
184
186
|
}
|
185
187
|
|
188
|
+
SERVICE_NAME_CONNECTION_PARAMS = {
|
189
|
+
adapter: "oracle_enhanced",
|
190
|
+
database: "/#{DATABASE_NAME}",
|
191
|
+
host: DATABASE_HOST,
|
192
|
+
port: DATABASE_PORT,
|
193
|
+
username: DATABASE_USER,
|
194
|
+
password: DATABASE_PASSWORD
|
195
|
+
}
|
196
|
+
|
186
197
|
DATABASE_NON_DEFAULT_TABLESPACE = config["database"]["non_default_tablespace"] || ENV["DATABASE_NON_DEFAULT_TABLESPACE"] || "SYSTEM"
|
187
198
|
|
188
199
|
# set default time zone in TZ environment variable
|
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: 6.
|
4
|
+
version: 6.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raimonds Simanovskis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-10 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: 6.
|
19
|
+
version: 6.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: 6.
|
26
|
+
version: 6.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: ruby-plsql
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,6 +86,8 @@ files:
|
|
86
86
|
- lib/active_record/type/oracle_enhanced/timestampltz.rb
|
87
87
|
- lib/active_record/type/oracle_enhanced/timestamptz.rb
|
88
88
|
- lib/activerecord-oracle_enhanced-adapter.rb
|
89
|
+
- lib/arel/visitors/oracle.rb
|
90
|
+
- lib/arel/visitors/oracle12.rb
|
89
91
|
- spec/active_record/connection_adapters/emulation/oracle_adapter_spec.rb
|
90
92
|
- spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb
|
91
93
|
- spec/active_record/connection_adapters/oracle_enhanced/context_index_spec.rb
|
@@ -135,38 +137,38 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
137
|
- !ruby/object:Gem::Version
|
136
138
|
version: 1.8.11
|
137
139
|
requirements: []
|
138
|
-
rubygems_version: 3.
|
140
|
+
rubygems_version: 3.2.3
|
139
141
|
signing_key:
|
140
142
|
specification_version: 4
|
141
143
|
summary: Oracle enhanced adapter for ActiveRecord
|
142
144
|
test_files:
|
143
|
-
- spec/spec_helper.rb
|
144
|
-
- spec/spec_config.yaml.template
|
145
145
|
- spec/active_record/connection_adapters/emulation/oracle_adapter_spec.rb
|
146
|
-
- spec/active_record/connection_adapters/
|
146
|
+
- spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb
|
147
|
+
- spec/active_record/connection_adapters/oracle_enhanced/context_index_spec.rb
|
147
148
|
- spec/active_record/connection_adapters/oracle_enhanced/database_tasks_spec.rb
|
148
|
-
- spec/active_record/connection_adapters/oracle_enhanced/schema_statements_spec.rb
|
149
|
-
- spec/active_record/connection_adapters/oracle_enhanced/quoting_spec.rb
|
150
|
-
- spec/active_record/connection_adapters/oracle_enhanced/schema_dumper_spec.rb
|
151
149
|
- spec/active_record/connection_adapters/oracle_enhanced/dbms_output_spec.rb
|
152
|
-
- spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb
|
153
150
|
- spec/active_record/connection_adapters/oracle_enhanced/procedures_spec.rb
|
151
|
+
- spec/active_record/connection_adapters/oracle_enhanced/quoting_spec.rb
|
152
|
+
- spec/active_record/connection_adapters/oracle_enhanced/schema_dumper_spec.rb
|
153
|
+
- spec/active_record/connection_adapters/oracle_enhanced/schema_statements_spec.rb
|
154
154
|
- spec/active_record/connection_adapters/oracle_enhanced/structure_dump_spec.rb
|
155
|
-
- spec/active_record/connection_adapters/oracle_enhanced/context_index_spec.rb
|
156
155
|
- spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb
|
156
|
+
- spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb
|
157
|
+
- spec/active_record/oracle_enhanced/type/binary_spec.rb
|
158
|
+
- spec/active_record/oracle_enhanced/type/boolean_spec.rb
|
159
|
+
- spec/active_record/oracle_enhanced/type/character_string_spec.rb
|
157
160
|
- spec/active_record/oracle_enhanced/type/decimal_spec.rb
|
158
|
-
- spec/active_record/oracle_enhanced/type/national_character_string_spec.rb
|
159
161
|
- spec/active_record/oracle_enhanced/type/dirty_spec.rb
|
160
|
-
- spec/active_record/oracle_enhanced/type/
|
162
|
+
- spec/active_record/oracle_enhanced/type/float_spec.rb
|
163
|
+
- spec/active_record/oracle_enhanced/type/integer_spec.rb
|
161
164
|
- spec/active_record/oracle_enhanced/type/json_spec.rb
|
165
|
+
- spec/active_record/oracle_enhanced/type/national_character_string_spec.rb
|
166
|
+
- spec/active_record/oracle_enhanced/type/national_character_text_spec.rb
|
162
167
|
- spec/active_record/oracle_enhanced/type/raw_spec.rb
|
163
|
-
- spec/active_record/oracle_enhanced/type/binary_spec.rb
|
164
168
|
- spec/active_record/oracle_enhanced/type/text_spec.rb
|
165
169
|
- spec/active_record/oracle_enhanced/type/timestamp_spec.rb
|
166
|
-
- spec/
|
167
|
-
- spec/
|
168
|
-
- spec/active_record/oracle_enhanced/type/integer_spec.rb
|
169
|
-
- spec/active_record/oracle_enhanced/type/float_spec.rb
|
170
|
+
- spec/spec_config.yaml.template
|
171
|
+
- spec/spec_helper.rb
|
170
172
|
- spec/support/alter_system_set_open_cursors.sql
|
171
173
|
- spec/support/alter_system_user_password.sql
|
172
174
|
- spec/support/create_oracle_enhanced_users.sql
|