activerecord-oracle_enhanced-adapter 1.7.11 → 1.8.0.beta1
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/.rspec +2 -0
- data/Gemfile +20 -11
- data/History.md +123 -4
- data/RUNNING_TESTS.md +79 -55
- data/Rakefile +13 -19
- data/VERSION +1 -1
- data/activerecord-oracle_enhanced-adapter.gemspec +16 -17
- 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 +30 -23
- data/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb +10 -10
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +48 -70
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +1 -4
- 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 +13 -42
- 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 +146 -159
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +94 -132
- 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 +65 -100
- data/lib/active_record/connection_adapters/oracle_enhanced/version.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +250 -487
- 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/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/activerecord-oracle_enhanced-adapter.rb +2 -2
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +57 -131
- 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 +40 -42
- data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +83 -85
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +205 -286
- 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 +42 -49
- data/spec/active_record/connection_adapters/oracle_enhanced_emulate_oracle_adapter_spec.rb +1 -3
- data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +68 -71
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +51 -92
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +221 -327
- data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +16 -18
- data/spec/spec_helper.rb +59 -57
- metadata +10 -10
@@ -2,19 +2,16 @@ module ActiveRecord
|
|
2
2
|
module OracleEnhanced
|
3
3
|
module Type
|
4
4
|
class Boolean < ActiveModel::Type::Boolean # :nodoc:
|
5
|
-
# Add 'N' as FALSE_VALUES
|
6
|
-
FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE', 'off', 'OFF', 'n', 'N'].to_set
|
7
|
-
|
8
5
|
private
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
def cast_value(value)
|
8
|
+
# Kind of adding 'n' and 'N' to `FALSE_VALUES`
|
9
|
+
if ["n", "N"].include?(value)
|
10
|
+
false
|
11
|
+
else
|
12
|
+
super
|
13
|
+
end
|
16
14
|
end
|
17
|
-
end
|
18
15
|
end
|
19
16
|
end
|
20
17
|
end
|
@@ -1,13 +1,12 @@
|
|
1
|
-
#TODO Need to consider namespace change since paremt class moved to ActiveModel
|
2
1
|
module ActiveRecord
|
3
2
|
module OracleEnhanced
|
4
3
|
module Type
|
5
4
|
class Integer < ActiveModel::Type::Integer # :nodoc:
|
6
5
|
private
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
def max_value
|
8
|
+
("9" * 38).to_i
|
9
|
+
end
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
@@ -1,6 +1,5 @@
|
|
1
|
-
require
|
1
|
+
require "active_model/type/string"
|
2
2
|
|
3
|
-
#TODO Need to consider namespace change since paremt class moved to ActiveModel
|
4
3
|
module ActiveRecord
|
5
4
|
module OracleEnhanced
|
6
5
|
module Type
|
@@ -14,7 +13,7 @@ module ActiveRecord
|
|
14
13
|
if value.nil?
|
15
14
|
super
|
16
15
|
else
|
17
|
-
value = value.unpack(
|
16
|
+
value = value.unpack("C*")
|
18
17
|
value.map { |x| "%02X" % x }.join
|
19
18
|
end
|
20
19
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "active_model/type/string"
|
2
2
|
|
3
3
|
module ActiveRecord
|
4
4
|
module OracleEnhanced
|
@@ -15,7 +15,7 @@ module ActiveRecord
|
|
15
15
|
|
16
16
|
def changed_in_place?(raw_old_value, new_value)
|
17
17
|
if raw_old_value.nil?
|
18
|
-
new_value = nil if new_value ==
|
18
|
+
new_value = nil if new_value == ""
|
19
19
|
raw_old_value != new_value
|
20
20
|
else
|
21
21
|
super
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require "active_model/type/string"
|
2
2
|
|
3
3
|
module ActiveRecord
|
4
4
|
module OracleEnhanced
|
5
5
|
module Type
|
6
|
-
class Text <
|
6
|
+
class Text < ActiveRecord::Type::Text # :nodoc:
|
7
7
|
def changed_in_place?(raw_old_value, new_value)
|
8
8
|
#TODO: Needs to find a way not to cast here.
|
9
9
|
raw_old_value = cast(raw_old_value)
|
@@ -3,11 +3,11 @@ if defined?(Rails)
|
|
3
3
|
module ConnectionAdapters
|
4
4
|
class OracleEnhancedRailtie < ::Rails::Railtie
|
5
5
|
rake_tasks do
|
6
|
-
load
|
6
|
+
load "active_record/connection_adapters/oracle_enhanced/database_tasks.rb"
|
7
7
|
end
|
8
8
|
|
9
9
|
ActiveSupport.on_load(:active_record) do
|
10
|
-
require
|
10
|
+
require "active_record/connection_adapters/oracle_enhanced_adapter"
|
11
11
|
|
12
12
|
# Cache column descriptions between requests in test and production environments
|
13
13
|
if Rails.env.test? || Rails.env.production?
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe "OracleEnhancedAdapter establish connection" do
|
4
2
|
|
5
3
|
it "should connect to database" do
|
@@ -41,77 +39,6 @@ describe "OracleEnhancedAdapter" do
|
|
41
39
|
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
42
40
|
end
|
43
41
|
|
44
|
-
describe "ignore specified table columns" do
|
45
|
-
before(:all) do
|
46
|
-
@conn = ActiveRecord::Base.connection
|
47
|
-
@conn.execute "DROP TABLE test_employees" rescue nil
|
48
|
-
@conn.execute <<-SQL
|
49
|
-
CREATE TABLE test_employees (
|
50
|
-
id NUMBER PRIMARY KEY,
|
51
|
-
first_name VARCHAR2(20),
|
52
|
-
last_name VARCHAR2(25),
|
53
|
-
email VARCHAR2(25),
|
54
|
-
phone_number VARCHAR2(20),
|
55
|
-
hire_date DATE,
|
56
|
-
job_id NUMBER,
|
57
|
-
salary NUMBER,
|
58
|
-
commission_pct NUMBER(2,2),
|
59
|
-
manager_id NUMBER(6),
|
60
|
-
department_id NUMBER(4,0),
|
61
|
-
created_at DATE
|
62
|
-
)
|
63
|
-
SQL
|
64
|
-
@conn.execute "DROP SEQUENCE test_employees_seq" rescue nil
|
65
|
-
@conn.execute <<-SQL
|
66
|
-
CREATE SEQUENCE test_employees_seq MINVALUE 1
|
67
|
-
INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE
|
68
|
-
SQL
|
69
|
-
end
|
70
|
-
|
71
|
-
after(:all) do
|
72
|
-
@conn.execute "DROP TABLE test_employees"
|
73
|
-
@conn.execute "DROP SEQUENCE test_employees_seq"
|
74
|
-
end
|
75
|
-
|
76
|
-
after(:each) do
|
77
|
-
Object.send(:remove_const, "TestEmployee")
|
78
|
-
ActiveRecord::Base.connection.clear_ignored_table_columns
|
79
|
-
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should ignore specified table columns" do
|
83
|
-
class ::TestEmployee < ActiveRecord::Base
|
84
|
-
ignore_table_columns :phone_number, :hire_date
|
85
|
-
end
|
86
|
-
expect(TestEmployee.connection.columns('test_employees').select{|c| ['phone_number','hire_date'].include?(c.name) }).to be_empty
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should ignore specified table columns specified in several lines" do
|
90
|
-
class ::TestEmployee < ActiveRecord::Base
|
91
|
-
ignore_table_columns :phone_number
|
92
|
-
ignore_table_columns :hire_date
|
93
|
-
end
|
94
|
-
expect(TestEmployee.connection.columns('test_employees').select{|c| ['phone_number','hire_date'].include?(c.name) }).to be_empty
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should not ignore unspecified table columns" do
|
98
|
-
class ::TestEmployee < ActiveRecord::Base
|
99
|
-
ignore_table_columns :phone_number, :hire_date
|
100
|
-
end
|
101
|
-
expect(TestEmployee.connection.columns('test_employees').select{|c| c.name == 'email' }).not_to be_empty
|
102
|
-
end
|
103
|
-
|
104
|
-
it "should ignore specified table columns in other connection" do
|
105
|
-
class ::TestEmployee < ActiveRecord::Base
|
106
|
-
ignore_table_columns :phone_number, :hire_date
|
107
|
-
end
|
108
|
-
# establish other connection
|
109
|
-
other_conn = ActiveRecord::Base.oracle_enhanced_connection(CONNECTION_PARAMS)
|
110
|
-
expect(other_conn.columns('test_employees').select{|c| ['phone_number','hire_date'].include?(c.name) }).to be_empty
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
42
|
describe "cache table columns" do
|
116
43
|
before(:all) do
|
117
44
|
@conn = ActiveRecord::Base.connection
|
@@ -134,7 +61,7 @@ describe "OracleEnhancedAdapter" do
|
|
134
61
|
hire_date DATE
|
135
62
|
)
|
136
63
|
SQL
|
137
|
-
@column_names = [
|
64
|
+
@column_names = ["id", "first_name", "last_name", "full_name", "hire_date"]
|
138
65
|
@column_sql_types = ["NUMBER", "VARCHAR2(20)", "VARCHAR2(25)", "VARCHAR2(46)", "DATE"]
|
139
66
|
class ::TestEmployee < ActiveRecord::Base
|
140
67
|
end
|
@@ -151,7 +78,7 @@ describe "OracleEnhancedAdapter" do
|
|
151
78
|
@conn.execute "DROP TABLE test_employees"
|
152
79
|
@conn.execute "DROP TABLE test_employees_without_pk"
|
153
80
|
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.cache_columns = nil
|
154
|
-
ActiveRecord::Base.clear_cache!
|
81
|
+
ActiveRecord::Base.clear_cache!
|
155
82
|
end
|
156
83
|
|
157
84
|
before(:each) do
|
@@ -170,33 +97,33 @@ describe "OracleEnhancedAdapter" do
|
|
170
97
|
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.cache_columns = false
|
171
98
|
end
|
172
99
|
|
173
|
-
it
|
100
|
+
it "should identify virtual columns as such" do
|
174
101
|
skip "Not supported in this database version" unless @oracle11g_or_higher
|
175
|
-
te = TestEmployee.connection.columns(
|
176
|
-
expect(te.name).to eq(
|
102
|
+
te = TestEmployee.connection.columns("test_employees").detect(&:virtual?)
|
103
|
+
expect(te.name).to eq("full_name")
|
177
104
|
end
|
178
105
|
|
179
106
|
it "should get columns from database at first time" do
|
180
|
-
expect(TestEmployee.connection.columns(
|
107
|
+
expect(TestEmployee.connection.columns("test_employees").map(&:name)).to eq(@column_names)
|
181
108
|
expect(@logger.logged(:debug).last).to match(/select .* from all_tab_cols/im)
|
182
109
|
end
|
183
110
|
|
184
111
|
it "should get columns from database at second time" do
|
185
|
-
TestEmployee.connection.columns(
|
112
|
+
TestEmployee.connection.columns("test_employees")
|
186
113
|
@logger.clear(:debug)
|
187
|
-
expect(TestEmployee.connection.columns(
|
114
|
+
expect(TestEmployee.connection.columns("test_employees").map(&:name)).to eq(@column_names)
|
188
115
|
expect(@logger.logged(:debug).last).to match(/select .* from all_tab_cols/im)
|
189
116
|
end
|
190
117
|
|
191
118
|
it "should get primary key from database at first time" do
|
192
|
-
expect(TestEmployee.connection.pk_and_sequence_for(
|
119
|
+
expect(TestEmployee.connection.pk_and_sequence_for("test_employees")).to eq(["id", nil])
|
193
120
|
expect(@logger.logged(:debug).last).to match(/select .* from all_constraints/im)
|
194
121
|
end
|
195
122
|
|
196
123
|
it "should get primary key from database at first time" do
|
197
|
-
expect(TestEmployee.connection.pk_and_sequence_for(
|
124
|
+
expect(TestEmployee.connection.pk_and_sequence_for("test_employees")).to eq(["id", nil])
|
198
125
|
@logger.clear(:debug)
|
199
|
-
expect(TestEmployee.connection.pk_and_sequence_for(
|
126
|
+
expect(TestEmployee.connection.pk_and_sequence_for("test_employees")).to eq(["id", nil])
|
200
127
|
expect(@logger.logged(:debug).last).to match(/select .* from all_constraints/im)
|
201
128
|
end
|
202
129
|
|
@@ -216,33 +143,33 @@ describe "OracleEnhancedAdapter" do
|
|
216
143
|
end
|
217
144
|
|
218
145
|
it "should get columns from database at first time" do
|
219
|
-
expect(TestEmployee.connection.columns(
|
146
|
+
expect(TestEmployee.connection.columns("test_employees").map(&:name)).to eq(@column_names)
|
220
147
|
expect(@logger.logged(:debug).last).to match(/select .* from all_tab_cols/im)
|
221
148
|
end
|
222
149
|
|
223
150
|
it "should get columns from cache at second time" do
|
224
|
-
TestEmployee.connection.columns(
|
151
|
+
TestEmployee.connection.columns("test_employees")
|
225
152
|
@logger.clear(:debug)
|
226
|
-
expect(TestEmployee.connection.columns(
|
153
|
+
expect(TestEmployee.connection.columns("test_employees").map(&:name)).to eq(@column_names)
|
227
154
|
expect(@logger.logged(:debug).last).to be_blank
|
228
155
|
end
|
229
156
|
|
230
157
|
it "should get primary key from database at first time" do
|
231
|
-
expect(TestEmployee.connection.pk_and_sequence_for(
|
158
|
+
expect(TestEmployee.connection.pk_and_sequence_for("test_employees")).to eq(["id", nil])
|
232
159
|
expect(@logger.logged(:debug).last).to match(/select .* from all_constraints/im)
|
233
160
|
end
|
234
161
|
|
235
162
|
it "should get primary key from cache at first time" do
|
236
|
-
expect(TestEmployee.connection.pk_and_sequence_for(
|
163
|
+
expect(TestEmployee.connection.pk_and_sequence_for("test_employees")).to eq(["id", nil])
|
237
164
|
@logger.clear(:debug)
|
238
|
-
expect(TestEmployee.connection.pk_and_sequence_for(
|
165
|
+
expect(TestEmployee.connection.pk_and_sequence_for("test_employees")).to eq(["id", nil])
|
239
166
|
expect(@logger.logged(:debug).last).to be_blank
|
240
167
|
end
|
241
168
|
|
242
169
|
it "should store primary key as nil in cache at first time for table without primary key" do
|
243
|
-
expect(TestEmployee.connection.pk_and_sequence_for(
|
170
|
+
expect(TestEmployee.connection.pk_and_sequence_for("test_employees_without_pk")).to eq(nil)
|
244
171
|
@logger.clear(:debug)
|
245
|
-
expect(TestEmployee.connection.pk_and_sequence_for(
|
172
|
+
expect(TestEmployee.connection.pk_and_sequence_for("test_employees_without_pk")).to eq(nil)
|
246
173
|
expect(@logger.logged(:debug).last).to be_blank
|
247
174
|
end
|
248
175
|
|
@@ -261,7 +188,7 @@ describe "OracleEnhancedAdapter" do
|
|
261
188
|
name VARCHAR2(50)
|
262
189
|
)
|
263
190
|
SQL
|
264
|
-
Object.send(:remove_const,
|
191
|
+
Object.send(:remove_const, "CompositePrimaryKeys") if defined?(CompositePrimaryKeys)
|
265
192
|
class ::TestEmployee < ActiveRecord::Base
|
266
193
|
self.primary_key = :employee_id
|
267
194
|
end
|
@@ -270,7 +197,7 @@ describe "OracleEnhancedAdapter" do
|
|
270
197
|
after(:all) do
|
271
198
|
Object.send(:remove_const, "TestEmployee")
|
272
199
|
@conn.execute "DROP TABLE test_employees"
|
273
|
-
ActiveRecord::Base.clear_cache!
|
200
|
+
ActiveRecord::Base.clear_cache!
|
274
201
|
end
|
275
202
|
|
276
203
|
it "should tell ActiveRecord that count distinct is supported" do
|
@@ -302,7 +229,7 @@ describe "OracleEnhancedAdapter" do
|
|
302
229
|
end
|
303
230
|
Object.send(:remove_const, "TestReservedWord")
|
304
231
|
ActiveRecord::Base.table_name_prefix = nil
|
305
|
-
ActiveRecord::Base.clear_cache!
|
232
|
+
ActiveRecord::Base.clear_cache!
|
306
233
|
end
|
307
234
|
|
308
235
|
before(:each) do
|
@@ -321,9 +248,9 @@ describe "OracleEnhancedAdapter" do
|
|
321
248
|
|
322
249
|
it "should create record" do
|
323
250
|
attrs = {
|
324
|
-
:
|
325
|
-
:
|
326
|
-
:
|
251
|
+
varchar2: "dummy",
|
252
|
+
integer: 1,
|
253
|
+
comment: "dummy"
|
327
254
|
}
|
328
255
|
record = TestReservedWord.create!(attrs)
|
329
256
|
record.reload
|
@@ -442,7 +369,7 @@ describe "OracleEnhancedAdapter" do
|
|
442
369
|
self.table_name = "warehouse-things"
|
443
370
|
end
|
444
371
|
|
445
|
-
wh = WarehouseThing.create!(:
|
372
|
+
wh = WarehouseThing.create!(name: "Foo", foo: 2)
|
446
373
|
expect(wh.id).not_to be_nil
|
447
374
|
|
448
375
|
expect(@conn.tables).to include("warehouse-things")
|
@@ -454,14 +381,14 @@ describe "OracleEnhancedAdapter" do
|
|
454
381
|
self.table_name = "CamelCase"
|
455
382
|
end
|
456
383
|
|
457
|
-
cc = CamelCase.create!(:
|
384
|
+
cc = CamelCase.create!(name: "Foo", foo: 2)
|
458
385
|
expect(cc.id).not_to be_nil
|
459
386
|
|
460
387
|
expect(@conn.tables).to include("CamelCase")
|
461
388
|
end
|
462
389
|
|
463
390
|
it "properly quotes database links" do
|
464
|
-
expect(@conn.quote_table_name(
|
391
|
+
expect(@conn.quote_table_name("asdf@some.link")).to eq('"ASDF"@"SOME.LINK"')
|
465
392
|
end
|
466
393
|
end
|
467
394
|
|
@@ -495,11 +422,11 @@ describe "OracleEnhancedAdapter" do
|
|
495
422
|
@conn.execute "DROP DATABASE LINK #{@db_link}" rescue nil
|
496
423
|
@sys_conn.drop_table :test_posts rescue nil
|
497
424
|
Object.send(:remove_const, "TestPost") rescue nil
|
498
|
-
ActiveRecord::Base.clear_cache!
|
425
|
+
ActiveRecord::Base.clear_cache!
|
499
426
|
end
|
500
427
|
|
501
428
|
it "should verify database link" do
|
502
|
-
@conn.select_value("select * from dual@#{@db_link}") ==
|
429
|
+
@conn.select_value("select * from dual@#{@db_link}") == "X"
|
503
430
|
end
|
504
431
|
|
505
432
|
it "should get column names" do
|
@@ -507,7 +434,7 @@ describe "OracleEnhancedAdapter" do
|
|
507
434
|
end
|
508
435
|
|
509
436
|
it "should create record" do
|
510
|
-
p = TestPost.create(:
|
437
|
+
p = TestPost.create(title: "Title", body: "Body")
|
511
438
|
expect(p.id).not_to be_nil
|
512
439
|
expect(TestPost.find(p.id)).not_to be_nil
|
513
440
|
end
|
@@ -521,7 +448,7 @@ describe "OracleEnhancedAdapter" do
|
|
521
448
|
|
522
449
|
it "should get current database name" do
|
523
450
|
# get database name if using //host:port/database connection string
|
524
|
-
database_name = CONNECTION_PARAMS[:database].split(
|
451
|
+
database_name = CONNECTION_PARAMS[:database].split("/").last
|
525
452
|
expect(@conn.current_database.upcase).to eq(database_name.upcase)
|
526
453
|
end
|
527
454
|
|
@@ -532,25 +459,25 @@ describe "OracleEnhancedAdapter" do
|
|
532
459
|
|
533
460
|
describe "temporary tables" do
|
534
461
|
before(:all) do
|
535
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:table] =
|
536
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:clob] =
|
462
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:table] = "UNUSED"
|
463
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:clob] = "UNUSED"
|
537
464
|
@conn = ActiveRecord::Base.connection
|
538
465
|
end
|
539
466
|
after(:all) do
|
540
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces={}
|
467
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces = {}
|
541
468
|
end
|
542
469
|
|
543
470
|
after(:each) do
|
544
471
|
@conn.drop_table :foos rescue nil
|
545
472
|
end
|
546
473
|
it "should create ok" do
|
547
|
-
@conn.create_table :foos, :
|
474
|
+
@conn.create_table :foos, temporary: true, id: false do |t|
|
548
475
|
t.integer :id
|
549
476
|
t.text :bar
|
550
477
|
end
|
551
478
|
end
|
552
479
|
it "should show up as temporary" do
|
553
|
-
@conn.create_table :foos, :
|
480
|
+
@conn.create_table :foos, temporary: true, id: false do |t|
|
554
481
|
t.integer :id
|
555
482
|
end
|
556
483
|
expect(@conn.temporary_table?("foos")).to be_truthy
|
@@ -578,8 +505,8 @@ describe "OracleEnhancedAdapter" do
|
|
578
505
|
@ids = (1..1010).to_a
|
579
506
|
TestPost.transaction do
|
580
507
|
@ids.each do |id|
|
581
|
-
TestPost.create!(:
|
582
|
-
TestComment.create!(:
|
508
|
+
TestPost.create!(id: id, title: "Title #{id}")
|
509
|
+
TestComment.create!(test_post_id: id, description: "Description #{id}")
|
583
510
|
end
|
584
511
|
end
|
585
512
|
end
|
@@ -591,7 +518,7 @@ describe "OracleEnhancedAdapter" do
|
|
591
518
|
end
|
592
519
|
Object.send(:remove_const, "TestPost")
|
593
520
|
Object.send(:remove_const, "TestComment")
|
594
|
-
ActiveRecord::Base.clear_cache!
|
521
|
+
ActiveRecord::Base.clear_cache!
|
595
522
|
end
|
596
523
|
|
597
524
|
it "should load included association with more than 1000 records" do
|
@@ -603,7 +530,7 @@ describe "OracleEnhancedAdapter" do
|
|
603
530
|
|
604
531
|
describe "with statement pool" do
|
605
532
|
before(:all) do
|
606
|
-
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS.merge(:
|
533
|
+
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS.merge(statement_limit: 3))
|
607
534
|
@conn = ActiveRecord::Base.connection
|
608
535
|
schema_define do
|
609
536
|
drop_table :test_posts rescue nil
|
@@ -623,7 +550,7 @@ describe "OracleEnhancedAdapter" do
|
|
623
550
|
drop_table :test_posts
|
624
551
|
end
|
625
552
|
Object.send(:remove_const, "TestPost")
|
626
|
-
ActiveRecord::Base.clear_cache!
|
553
|
+
ActiveRecord::Base.clear_cache!
|
627
554
|
end
|
628
555
|
|
629
556
|
it "should clear older cursors when statement limit is reached" do
|
@@ -671,17 +598,17 @@ describe "OracleEnhancedAdapter" do
|
|
671
598
|
drop_table :test_posts
|
672
599
|
end
|
673
600
|
Object.send(:remove_const, "TestPost")
|
674
|
-
ActiveRecord::Base.clear_cache!
|
601
|
+
ActiveRecord::Base.clear_cache!
|
675
602
|
end
|
676
603
|
|
677
604
|
it "should explain query" do
|
678
|
-
explain = TestPost.where(:
|
605
|
+
explain = TestPost.where(id: 1).explain
|
679
606
|
expect(explain).to include("Cost")
|
680
607
|
expect(explain).to include("INDEX UNIQUE SCAN")
|
681
608
|
end
|
682
609
|
|
683
610
|
it "should explain query with binds" do
|
684
|
-
pending "Pending until further investigation made for #908" if RUBY_ENGINE ==
|
611
|
+
pending "Pending until further investigation made for #908" if RUBY_ENGINE == "jruby"
|
685
612
|
pk = TestPost.columns_hash[TestPost.primary_key]
|
686
613
|
sub = Arel::Nodes::BindParam.new.to_sql
|
687
614
|
binds = [ActiveRecord::Relation::QueryAttribute.new(pk, 1, ActiveRecord::Type::Integer.new)]
|
@@ -714,11 +641,11 @@ describe "OracleEnhancedAdapter" do
|
|
714
641
|
self.table_name = :test_employees
|
715
642
|
end
|
716
643
|
i = 0
|
717
|
-
@employee.create!(sort_order: i+=1, first_name:
|
718
|
-
@employee.create!(sort_order: i+=1, first_name:
|
719
|
-
@employee.create!(sort_order: i+=1, first_name:
|
720
|
-
@employee.create!(sort_order: i+=1, first_name:
|
721
|
-
@employee.create!(sort_order: i+=1, first_name:
|
644
|
+
@employee.create!(sort_order: i += 1, first_name: "Peter", last_name: "Parker")
|
645
|
+
@employee.create!(sort_order: i += 1, first_name: "Tony", last_name: "Stark")
|
646
|
+
@employee.create!(sort_order: i += 1, first_name: "Steven", last_name: "Rogers")
|
647
|
+
@employee.create!(sort_order: i += 1, first_name: "Bruce", last_name: "Banner")
|
648
|
+
@employee.create!(sort_order: i += 1, first_name: "Natasha", last_name: "Romanova")
|
722
649
|
end
|
723
650
|
|
724
651
|
after(:all) do
|
@@ -727,8 +654,7 @@ describe "OracleEnhancedAdapter" do
|
|
727
654
|
end
|
728
655
|
|
729
656
|
after(:each) do
|
730
|
-
ActiveRecord::Base.
|
731
|
-
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
657
|
+
ActiveRecord::Base.clear_cache!
|
732
658
|
end
|
733
659
|
|
734
660
|
it "should return n records with limit(n)" do
|
@@ -762,7 +688,7 @@ describe "OracleEnhancedAdapter" do
|
|
762
688
|
end
|
763
689
|
|
764
690
|
it "returns true when passed a valid type" do
|
765
|
-
column = @conn.columns(
|
691
|
+
column = @conn.columns("test_employees").find { |col| col.name == "first_name" }
|
766
692
|
expect(@conn.valid_type?(column.type)).to be true
|
767
693
|
end
|
768
694
|
|
@@ -771,7 +697,7 @@ describe "OracleEnhancedAdapter" do
|
|
771
697
|
end
|
772
698
|
end
|
773
699
|
|
774
|
-
describe
|
700
|
+
describe "serialized column" do
|
775
701
|
before(:all) do
|
776
702
|
schema_define do
|
777
703
|
create_table :test_serialized_columns do |t|
|
@@ -787,9 +713,9 @@ describe "OracleEnhancedAdapter" do
|
|
787
713
|
schema_define do
|
788
714
|
drop_table :test_serialized_columns
|
789
715
|
end
|
790
|
-
Object.send(:remove_const,
|
716
|
+
Object.send(:remove_const, "TestSerializedColumn")
|
791
717
|
ActiveRecord::Base.table_name_prefix = nil
|
792
|
-
ActiveRecord::Base.clear_cache!
|
718
|
+
ActiveRecord::Base.clear_cache!
|
793
719
|
end
|
794
720
|
|
795
721
|
before(:each) do
|
@@ -800,8 +726,8 @@ describe "OracleEnhancedAdapter" do
|
|
800
726
|
clear_logger
|
801
727
|
end
|
802
728
|
|
803
|
-
it
|
804
|
-
new_value =
|
729
|
+
it "should serialize" do
|
730
|
+
new_value = "new_value"
|
805
731
|
serialized_column = TestSerializedColumn.new
|
806
732
|
|
807
733
|
expect(serialized_column.serialized).to eq([])
|