activerecord-oracle_enhanced-adapter 6.1.5 → 7.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +56 -0
  3. data/README.md +1 -1
  4. data/VERSION +1 -1
  5. data/lib/active_record/connection_adapters/emulation/oracle_adapter.rb +1 -1
  6. data/lib/active_record/connection_adapters/oracle_enhanced/column.rb +2 -2
  7. data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +22 -13
  8. data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +3 -3
  9. data/lib/active_record/connection_adapters/oracle_enhanced/database_limits.rb +1 -1
  10. data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +16 -17
  11. data/lib/active_record/connection_adapters/oracle_enhanced/dbms_output.rb +1 -1
  12. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +12 -6
  13. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +1 -1
  14. data/lib/active_record/connection_adapters/oracle_enhanced/lob.rb +4 -4
  15. data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +18 -18
  16. data/lib/active_record/connection_adapters/oracle_enhanced/oci_quoting.rb +1 -1
  17. data/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb +6 -6
  18. data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +16 -16
  19. data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +1 -1
  20. data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +1 -1
  21. data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +6 -6
  22. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +35 -27
  23. data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +30 -29
  24. data/lib/active_record/connection_adapters/oracle_enhanced/type_metadata.rb +1 -1
  25. data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +123 -98
  26. data/lib/arel/visitors/oracle.rb +6 -2
  27. data/lib/arel/visitors/oracle12.rb +4 -0
  28. data/spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb +18 -1
  29. data/spec/active_record/connection_adapters/oracle_enhanced/context_index_spec.rb +2 -2
  30. data/spec/active_record/connection_adapters/oracle_enhanced/procedures_spec.rb +5 -5
  31. data/spec/active_record/connection_adapters/oracle_enhanced/schema_dumper_spec.rb +3 -3
  32. data/spec/active_record/connection_adapters/oracle_enhanced/schema_statements_spec.rb +5 -5
  33. data/spec/active_record/connection_adapters/oracle_enhanced/structure_dump_spec.rb +10 -10
  34. data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +34 -7
  35. data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +5 -5
  36. data/spec/active_record/oracle_enhanced/type/timestamp_spec.rb +2 -2
  37. metadata +4 -4
@@ -68,7 +68,7 @@ describe "OracleEnhancedAdapter structure dump" do
68
68
  SQL
69
69
  dump = ActiveRecord::Base.connection.structure_dump
70
70
  expect(dump.split('\n').length).to eq(1)
71
- expect(dump).to match(/ALTER TABLE \"?TEST_POSTS\"? ADD CONSTRAINT \"?FK_TEST_POST_FOO\"? FOREIGN KEY \(\"?FOO_ID\"?\) REFERENCES \"?FOOS\"?\(\"?ID\"?\)/i)
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
73
73
 
74
74
  it "should dump foreign keys when reference column name is not 'id'" do
@@ -88,7 +88,7 @@ describe "OracleEnhancedAdapter structure dump" do
88
88
 
89
89
  dump = ActiveRecord::Base.connection.structure_dump
90
90
  expect(dump.split('\n').length).to eq(1)
91
- expect(dump).to match(/ALTER TABLE \"?TEST_POSTS\"? ADD CONSTRAINT \"?FK_TEST_POST_BAZ\"? FOREIGN KEY \(\"?BAZ_ID\"?\) REFERENCES \"?FOOS\"?\(\"?BAZ_ID\"?\)/i)
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
93
93
 
94
94
  it "should not error when no foreign keys are present" do
@@ -136,7 +136,7 @@ describe "OracleEnhancedAdapter structure dump" do
136
136
  )
137
137
  SQL
138
138
  dump = ActiveRecord::Base.connection.structure_dump
139
- expect(dump).to match(/\"?ID_PLUS\"? NUMBER GENERATED ALWAYS AS \(ID\+2\) VIRTUAL/)
139
+ expect(dump).to match(/"?ID_PLUS"? NUMBER GENERATED ALWAYS AS \(ID\+2\) VIRTUAL/)
140
140
  end
141
141
 
142
142
  it "should dump RAW virtual columns" do
@@ -149,7 +149,7 @@ describe "OracleEnhancedAdapter structure dump" do
149
149
  )
150
150
  SQL
151
151
  dump = ActiveRecord::Base.connection.structure_dump
152
- expect(dump).to match(/CREATE TABLE \"BARS\" \(\n \"ID\" NUMBER\(38,0\) NOT NULL,\n \"SUPER\" RAW\(255\) GENERATED ALWAYS AS \(HEXTORAW\(TO_CHAR\(ID\)\)\) VIRTUAL/)
152
+ expect(dump).to match(/CREATE TABLE "BARS" \(\n "ID" NUMBER\(38,0\) NOT NULL,\n "SUPER" RAW\(255\) GENERATED ALWAYS AS \(HEXTORAW\(TO_CHAR\(ID\)\)\) VIRTUAL/)
153
153
  end
154
154
 
155
155
  it "should dump NCLOB columns" do
@@ -161,7 +161,7 @@ describe "OracleEnhancedAdapter structure dump" do
161
161
  )
162
162
  SQL
163
163
  dump = ActiveRecord::Base.connection.structure_dump
164
- expect(dump).to match(/CREATE TABLE \"BARS\" \(\n \"ID\" NUMBER\(38,0\) NOT NULL,\n \"NCLOB_TEXT\" NCLOB/)
164
+ expect(dump).to match(/CREATE TABLE "BARS" \(\n "ID" NUMBER\(38,0\) NOT NULL,\n "NCLOB_TEXT" NCLOB/)
165
165
  end
166
166
 
167
167
  it "should dump unique keys" do
@@ -187,7 +187,7 @@ describe "OracleEnhancedAdapter structure dump" do
187
187
 
188
188
  dump = ActiveRecord::Base.connection.structure_dump
189
189
  expect(dump).to match(/CREATE UNIQUE INDEX "?IX_TEST_POSTS_FOO_ID"? ON "?TEST_POSTS"? \("?FOO_ID"?\)/i)
190
- expect(dump).to match(/CREATE INDEX "?IX_TEST_POSTS_FOO\"? ON "?TEST_POSTS"? \("?FOO"?\)/i)
190
+ expect(dump).to match(/CREATE INDEX "?IX_TEST_POSTS_FOO"? ON "?TEST_POSTS"? \("?FOO"?\)/i)
191
191
  expect(dump).not_to match(/CREATE UNIQUE INDEX "?UK_TEST_POSTS_/i)
192
192
  end
193
193
 
@@ -199,8 +199,8 @@ describe "OracleEnhancedAdapter structure dump" do
199
199
  SQL
200
200
 
201
201
  dump = ActiveRecord::Base.connection.structure_dump
202
- expect(dump).to match(/CREATE INDEX "?IX_TEST_POSTS_FOO_FOO_ID\"? ON "?TEST_POSTS"? \("?FOO"?, "?FOO_ID"?\)/i)
203
- expect(dump).to match(/CREATE INDEX "?IX_TEST_POSTS_FUNCTION\"? ON "?TEST_POSTS"? \(TO_CHAR\(LENGTH\("?FOO"?\)\)\|\|"?FOO"?\)/i)
202
+ expect(dump).to match(/CREATE INDEX "?IX_TEST_POSTS_FOO_FOO_ID"? ON "?TEST_POSTS"? \("?FOO"?, "?FOO_ID"?\)/i)
203
+ expect(dump).to match(/CREATE INDEX "?IX_TEST_POSTS_FUNCTION"? ON "?TEST_POSTS"? \(TO_CHAR\(LENGTH\("?FOO"?\)\)\|\|"?FOO"?\)/i)
204
204
  end
205
205
 
206
206
  it "should dump RAW columns" do
@@ -212,7 +212,7 @@ describe "OracleEnhancedAdapter structure dump" do
212
212
  )
213
213
  SQL
214
214
  dump = ActiveRecord::Base.connection.structure_dump
215
- expect(dump).to match(/CREATE TABLE \"BARS\" \(\n \"ID\" NUMBER\(38,0\) NOT NULL,\n \"SUPER\" RAW\(255\)/)
215
+ expect(dump).to match(/CREATE TABLE "BARS" \(\n "ID" NUMBER\(38,0\) NOT NULL,\n "SUPER" RAW\(255\)/)
216
216
  end
217
217
 
218
218
  it "should dump table comments" do
@@ -269,7 +269,7 @@ describe "OracleEnhancedAdapter structure dump" do
269
269
  end
270
270
  context "default sequence" do
271
271
  let(:sql) { "CREATE SEQUENCE \"#{sequence_name}\"" }
272
- it { is_expected.to_not match(%r{CREATE SEQUENCE \"#{sequence_name}" MAXVALUE \d+ MINVALUE \d+ NOORDER NOCYCLE}) }
272
+ it { is_expected.to_not match(%r{CREATE SEQUENCE "#{sequence_name}" MAXVALUE \d+ MINVALUE \d+ NOORDER NOCYCLE}) }
273
273
  end
274
274
  context "noorder" do
275
275
  let(:sql) { "CREATE SEQUENCE \"#{sequence_name}\" NOORDER" }
@@ -99,10 +99,10 @@ describe "OracleEnhancedAdapter" do
99
99
 
100
100
  it "should get sequence value at next time" do
101
101
  TestEmployee.create!
102
- expect(@logger.logged(:debug).first).not_to match(/SELECT \"TEST_EMPLOYEES_SEQ\".NEXTVAL FROM dual/im)
102
+ expect(@logger.logged(:debug).first).not_to match(/SELECT "TEST_EMPLOYEES_SEQ".NEXTVAL FROM dual/im)
103
103
  @logger.clear(:debug)
104
104
  TestEmployee.create!
105
- expect(@logger.logged(:debug).first).to match(/SELECT \"TEST_EMPLOYEES_SEQ\".NEXTVAL FROM dual/im)
105
+ expect(@logger.logged(:debug).first).to match(/SELECT "TEST_EMPLOYEES_SEQ".NEXTVAL FROM dual/im)
106
106
  end
107
107
  end
108
108
  end
@@ -577,9 +577,29 @@ describe "OracleEnhancedAdapter" do
577
577
  schema_define do
578
578
  drop_table :test_posts, if_exists: true
579
579
  create_table :test_posts
580
+
581
+ drop_table :users, if_exists: true
582
+ create_table :users, force: true do |t|
583
+ t.string :name
584
+ t.integer :group_id
585
+ end
586
+
587
+ drop_table :groups, if_exists: true
588
+ create_table :groups, force: true do |t|
589
+ t.string :name
590
+ end
580
591
  end
592
+
581
593
  class ::TestPost < ActiveRecord::Base
582
594
  end
595
+
596
+ class User < ActiveRecord::Base
597
+ belongs_to :group
598
+ end
599
+
600
+ class Group < ActiveRecord::Base
601
+ has_one :user
602
+ end
583
603
  end
584
604
 
585
605
  before(:each) do
@@ -594,6 +614,8 @@ describe "OracleEnhancedAdapter" do
594
614
  after(:all) do
595
615
  schema_define do
596
616
  drop_table :test_posts
617
+ drop_table :users
618
+ drop_table :groups
597
619
  end
598
620
  Object.send(:remove_const, "TestPost")
599
621
  ActiveRecord::Base.clear_cache!
@@ -610,15 +632,15 @@ describe "OracleEnhancedAdapter" do
610
632
  expect(@logger.logged(:debug).last).to match(/\["table_name", "TEST_POSTS"\]/)
611
633
  end
612
634
 
613
- it "should return content from columns without bind usage" do
635
+ it "should return content from columns witt bind usage" do
614
636
  expect(@conn.columns("TEST_POSTS").length).to be > 0
615
- expect(@logger.logged(:debug).last).not_to match(/:table_name/)
616
- expect(@logger.logged(:debug).last).not_to match(/\["table_name", "TEST_POSTS"\]/)
637
+ expect(@logger.logged(:debug).last).to match(/:table_name/)
638
+ expect(@logger.logged(:debug).last).to match(/\["table_name", "TEST_POSTS"\]/)
617
639
  end
618
640
 
619
- it "should return pk and sequence from pk_and_sequence_for without bind usage" do
641
+ it "should return pk and sequence from pk_and_sequence_for with bind usage" do
620
642
  expect(@conn.pk_and_sequence_for("TEST_POSTS").length).to eq 2
621
- expect(@logger.logged(:debug).last).not_to match(/\["table_name", "TEST_POSTS"\]/)
643
+ expect(@logger.logged(:debug).last).to match(/\["table_name", "TEST_POSTS"\]/)
622
644
  end
623
645
 
624
646
  it "should return pk from primary_keys with bind usage" do
@@ -626,6 +648,11 @@ describe "OracleEnhancedAdapter" do
626
648
  expect(@logger.logged(:debug).last).to match(/\["table_name", "TEST_POSTS"\]/)
627
649
  end
628
650
 
651
+ it "should not raise missing IN/OUT parameter like issue 1687 " do
652
+ # "to_sql" enforces unprepared_statement including dictionary access SQLs
653
+ expect { User.joins(:group).to_sql }.not_to raise_exception
654
+ end
655
+
629
656
  it "should return false from temporary_table? with bind usage" do
630
657
  expect(@conn.temporary_table?("TEST_POSTS")).to eq false
631
658
  expect(@logger.logged(:debug).last).to match(/:table_name/)
@@ -122,7 +122,7 @@ describe "OracleEnhancedAdapter assign string to :date and :datetime columns" do
122
122
  end
123
123
 
124
124
  after(:each) do
125
- ActiveRecord::Base.default_timezone = :utc
125
+ ActiveRecord.default_timezone = :utc
126
126
  end
127
127
 
128
128
  it "should assign ISO string to date column" do
@@ -170,7 +170,7 @@ describe "OracleEnhancedAdapter assign string to :date and :datetime columns" do
170
170
  end
171
171
 
172
172
  it "should assign ISO time string to datetime column" do
173
- ActiveRecord::Base.default_timezone = :local
173
+ ActiveRecord.default_timezone = :local
174
174
  @employee = TestEmployee.create(
175
175
  first_name: "First",
176
176
  last_name: "Last",
@@ -182,7 +182,7 @@ describe "OracleEnhancedAdapter assign string to :date and :datetime columns" do
182
182
  end
183
183
 
184
184
  it "should assign NLS time string to datetime column" do
185
- ActiveRecord::Base.default_timezone = :local
185
+ ActiveRecord.default_timezone = :local
186
186
  @employee = TestEmployee.create(
187
187
  first_name: "First",
188
188
  last_name: "Last",
@@ -205,7 +205,7 @@ describe "OracleEnhancedAdapter assign string to :date and :datetime columns" do
205
205
  end
206
206
 
207
207
  it "should assign ISO date string to datetime column" do
208
- ActiveRecord::Base.default_timezone = :local
208
+ ActiveRecord.default_timezone = :local
209
209
  @employee = TestEmployee.create(
210
210
  first_name: "First",
211
211
  last_name: "Last",
@@ -217,7 +217,7 @@ describe "OracleEnhancedAdapter assign string to :date and :datetime columns" do
217
217
  end
218
218
 
219
219
  it "should assign NLS date string to datetime column" do
220
- ActiveRecord::Base.default_timezone = :local
220
+ ActiveRecord.default_timezone = :local
221
221
  @employee = TestEmployee.create(
222
222
  first_name: "First",
223
223
  last_name: "Last",
@@ -4,7 +4,7 @@ describe "OracleEnhancedAdapter timestamp with timezone support" do
4
4
  include SchemaSpecHelper
5
5
 
6
6
  before(:all) do
7
- ActiveRecord::Base.default_timezone = :local
7
+ ActiveRecord.default_timezone = :local
8
8
  ActiveRecord::Base.establish_connection(CONNECTION_WITH_TIMEZONE_PARAMS)
9
9
  @conn = ActiveRecord::Base.connection
10
10
  schema_define do
@@ -28,7 +28,7 @@ describe "OracleEnhancedAdapter timestamp with timezone support" do
28
28
 
29
29
  after(:all) do
30
30
  @conn.drop_table :test_employees, if_exists: true
31
- ActiveRecord::Base.default_timezone = :utc
31
+ ActiveRecord.default_timezone = :utc
32
32
  end
33
33
 
34
34
  describe "/ TIMESTAMP WITH TIME ZONE values from ActiveRecord model" do
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: 6.1.5
4
+ version: 7.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raimonds Simanovskis
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 6.1.0
19
+ version: 7.0.0.rc1
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.1.0
26
+ version: 7.0.0.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ruby-plsql
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
130
  requirements:
131
131
  - - ">="
132
132
  - !ruby/object:Gem::Version
133
- version: 2.5.0
133
+ version: 2.7.0
134
134
  required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - ">="