activerecord-oracle_enhanced-adapter 1.7.11 → 1.8.2

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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +206 -4
  3. data/README.md +37 -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 +7 -59
  7. data/lib/active_record/connection_adapters/oracle_enhanced/column_dumper.rb +6 -50
  8. data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +11 -11
  9. data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +117 -117
  10. data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +37 -27
  11. data/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb +10 -10
  12. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +56 -71
  13. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +0 -7
  14. data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +51 -69
  15. data/lib/active_record/connection_adapters/oracle_enhanced/oci_quoting.rb +4 -4
  16. data/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb +76 -76
  17. data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +14 -43
  18. data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +60 -64
  19. data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +33 -47
  20. data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +150 -160
  21. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +95 -133
  22. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +3 -3
  23. data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +66 -101
  24. data/lib/active_record/connection_adapters/oracle_enhanced/version.rb +1 -1
  25. data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +290 -533
  26. data/lib/active_record/oracle_enhanced/type/boolean.rb +7 -10
  27. data/lib/active_record/oracle_enhanced/type/integer.rb +3 -4
  28. data/lib/active_record/oracle_enhanced/type/json.rb +8 -0
  29. data/lib/active_record/oracle_enhanced/type/national_character_string.rb +1 -1
  30. data/lib/active_record/oracle_enhanced/type/raw.rb +2 -3
  31. data/lib/active_record/oracle_enhanced/type/string.rb +2 -2
  32. data/lib/active_record/oracle_enhanced/type/text.rb +2 -2
  33. data/lib/active_record/oracle_enhanced/type/timestamptz.rb +23 -0
  34. data/lib/activerecord-oracle_enhanced-adapter.rb +2 -2
  35. data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +55 -162
  36. data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +32 -34
  37. data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +44 -42
  38. data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +250 -357
  39. data/spec/active_record/connection_adapters/oracle_enhanced_database_tasks_spec.rb +14 -6
  40. data/spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb +3 -5
  41. data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +115 -124
  42. data/spec/active_record/connection_adapters/oracle_enhanced_emulate_oracle_adapter_spec.rb +2 -3
  43. data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +68 -72
  44. data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +64 -80
  45. data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +223 -329
  46. data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +18 -20
  47. data/spec/spec_config.yaml.template +11 -0
  48. data/spec/spec_helper.rb +59 -59
  49. data/spec/support/alter_system_user_password.sql +2 -0
  50. data/spec/support/create_oracle_enhanced_users.sql +31 -0
  51. metadata +25 -25
  52. data/.rspec +0 -2
  53. data/Gemfile +0 -22
  54. data/RUNNING_TESTS.md +0 -83
  55. data/Rakefile +0 -45
  56. data/activerecord-oracle_enhanced-adapter.gemspec +0 -94
  57. data/lib/active_record/connection_adapters/oracle_enhanced/cpk.rb +0 -19
  58. data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +0 -113
@@ -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
- def cast_value(value)
11
- # Not calling super to use its own `FALSE_VALUES`
12
- if value == ''
13
- nil
14
- else
15
- !FALSE_VALUES.include?(value)
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
- def max_value
9
- ("9"*38).to_i
10
- end
7
+ def max_value
8
+ ("9" * 38).to_i
9
+ end
11
10
  end
12
11
  end
13
12
  end
@@ -0,0 +1,8 @@
1
+ module ActiveRecord
2
+ module OracleEnhanced
3
+ module Type
4
+ class Json < ActiveRecord::Type::Internal::AbstractJson
5
+ end
6
+ end
7
+ end
8
+ end
@@ -1,4 +1,4 @@
1
- require 'active_model/type/string'
1
+ require "active_model/type/string"
2
2
 
3
3
  module ActiveRecord
4
4
  module OracleEnhanced
@@ -1,6 +1,5 @@
1
- require 'active_model/type/string'
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('C*')
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 'active_model/type/string'
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 'active_model/type/string'
1
+ require "active_model/type/string"
2
2
 
3
3
  module ActiveRecord
4
4
  module OracleEnhanced
5
5
  module Type
6
- class Text < ActiveModel::Type::Text # :nodoc:
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)
@@ -0,0 +1,23 @@
1
+ module ActiveRecord
2
+ module OracleEnhanced
3
+ module Type
4
+ class TimestampTz < ActiveRecord::Type::DateTime
5
+ def type
6
+ :timestamptz
7
+ end
8
+
9
+ class Data < DelegateClass(::Time) # :nodoc:
10
+ end
11
+
12
+ def serialize(value)
13
+ case value = super
14
+ when ::Time
15
+ Data.new(value)
16
+ else
17
+ value
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -3,11 +3,11 @@ if defined?(Rails)
3
3
  module ConnectionAdapters
4
4
  class OracleEnhancedRailtie < ::Rails::Railtie
5
5
  rake_tasks do
6
- load 'active_record/connection_adapters/oracle_enhanced/database_tasks.rb'
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 'active_record/connection_adapters/oracle_enhanced_adapter'
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 = ['id', 'first_name', 'last_name', 'full_name', 'hire_date']
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! if ActiveRecord::Base.respond_to?(:"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 'should identify virtual columns as such' do
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('test_employees').detect(&:virtual?)
176
- expect(te.name).to eq('full_name')
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('test_employees').map(&:name)).to eq(@column_names)
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('test_employees')
112
+ TestEmployee.connection.columns("test_employees")
186
113
  @logger.clear(:debug)
187
- expect(TestEmployee.connection.columns('test_employees').map(&:name)).to eq(@column_names)
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('test_employees')).to eq(['id', nil])
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('test_employees')).to eq(['id', nil])
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('test_employees')).to eq(['id', nil])
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('test_employees').map(&:name)).to eq(@column_names)
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('test_employees')
151
+ TestEmployee.connection.columns("test_employees")
225
152
  @logger.clear(:debug)
226
- expect(TestEmployee.connection.columns('test_employees').map(&:name)).to eq(@column_names)
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('test_employees')).to eq(['id', nil])
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('test_employees')).to eq(['id', nil])
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('test_employees')).to eq(['id', nil])
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('test_employees_without_pk')).to eq(nil)
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('test_employees_without_pk')).to eq(nil)
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
 
@@ -250,39 +177,6 @@ describe "OracleEnhancedAdapter" do
250
177
 
251
178
  end
252
179
 
253
- describe "without composite_primary_keys" do
254
-
255
- before(:all) do
256
- @conn = ActiveRecord::Base.connection
257
- @conn.execute "DROP TABLE test_employees" rescue nil
258
- @conn.execute <<-SQL
259
- CREATE TABLE test_employees (
260
- employee_id NUMBER PRIMARY KEY,
261
- name VARCHAR2(50)
262
- )
263
- SQL
264
- Object.send(:remove_const, 'CompositePrimaryKeys') if defined?(CompositePrimaryKeys)
265
- class ::TestEmployee < ActiveRecord::Base
266
- self.primary_key = :employee_id
267
- end
268
- end
269
-
270
- after(:all) do
271
- Object.send(:remove_const, "TestEmployee")
272
- @conn.execute "DROP TABLE test_employees"
273
- ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
274
- end
275
-
276
- it "should tell ActiveRecord that count distinct is supported" do
277
- expect(ActiveRecord::Base.connection.supports_count_distinct?).to be_truthy
278
- end
279
-
280
- it "should execute correct SQL COUNT DISTINCT statement" do
281
- expect { TestEmployee.distinct.count(:employee_id) }.not_to raise_error
282
- end
283
-
284
- end
285
-
286
180
  describe "reserved words column quoting" do
287
181
 
288
182
  before(:all) do
@@ -302,7 +196,7 @@ describe "OracleEnhancedAdapter" do
302
196
  end
303
197
  Object.send(:remove_const, "TestReservedWord")
304
198
  ActiveRecord::Base.table_name_prefix = nil
305
- ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
199
+ ActiveRecord::Base.clear_cache!
306
200
  end
307
201
 
308
202
  before(:each) do
@@ -321,9 +215,9 @@ describe "OracleEnhancedAdapter" do
321
215
 
322
216
  it "should create record" do
323
217
  attrs = {
324
- :varchar2 => 'dummy',
325
- :integer => 1,
326
- :comment => 'dummy'
218
+ varchar2: "dummy",
219
+ integer: 1,
220
+ comment: "dummy"
327
221
  }
328
222
  record = TestReservedWord.create!(attrs)
329
223
  record.reload
@@ -442,7 +336,7 @@ describe "OracleEnhancedAdapter" do
442
336
  self.table_name = "warehouse-things"
443
337
  end
444
338
 
445
- wh = WarehouseThing.create!(:name => "Foo", :foo => 2)
339
+ wh = WarehouseThing.create!(name: "Foo", foo: 2)
446
340
  expect(wh.id).not_to be_nil
447
341
 
448
342
  expect(@conn.tables).to include("warehouse-things")
@@ -454,14 +348,14 @@ describe "OracleEnhancedAdapter" do
454
348
  self.table_name = "CamelCase"
455
349
  end
456
350
 
457
- cc = CamelCase.create!(:name => "Foo", :foo => 2)
351
+ cc = CamelCase.create!(name: "Foo", foo: 2)
458
352
  expect(cc.id).not_to be_nil
459
353
 
460
354
  expect(@conn.tables).to include("CamelCase")
461
355
  end
462
356
 
463
357
  it "properly quotes database links" do
464
- expect(@conn.quote_table_name('asdf@some.link')).to eq('"ASDF"@"SOME.LINK"')
358
+ expect(@conn.quote_table_name("asdf@some.link")).to eq('"ASDF"@"SOME.LINK"')
465
359
  end
466
360
  end
467
361
 
@@ -495,11 +389,11 @@ describe "OracleEnhancedAdapter" do
495
389
  @conn.execute "DROP DATABASE LINK #{@db_link}" rescue nil
496
390
  @sys_conn.drop_table :test_posts rescue nil
497
391
  Object.send(:remove_const, "TestPost") rescue nil
498
- ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
392
+ ActiveRecord::Base.clear_cache!
499
393
  end
500
394
 
501
395
  it "should verify database link" do
502
- @conn.select_value("select * from dual@#{@db_link}") == 'X'
396
+ @conn.select_value("select * from dual@#{@db_link}") == "X"
503
397
  end
504
398
 
505
399
  it "should get column names" do
@@ -507,7 +401,7 @@ describe "OracleEnhancedAdapter" do
507
401
  end
508
402
 
509
403
  it "should create record" do
510
- p = TestPost.create(:title => "Title", :body => "Body")
404
+ p = TestPost.create(title: "Title", body: "Body")
511
405
  expect(p.id).not_to be_nil
512
406
  expect(TestPost.find(p.id)).not_to be_nil
513
407
  end
@@ -521,7 +415,7 @@ describe "OracleEnhancedAdapter" do
521
415
 
522
416
  it "should get current database name" do
523
417
  # get database name if using //host:port/database connection string
524
- database_name = CONNECTION_PARAMS[:database].split('/').last
418
+ database_name = CONNECTION_PARAMS[:database].split("/").last
525
419
  expect(@conn.current_database.upcase).to eq(database_name.upcase)
526
420
  end
527
421
 
@@ -532,25 +426,25 @@ describe "OracleEnhancedAdapter" do
532
426
 
533
427
  describe "temporary tables" do
534
428
  before(:all) do
535
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:table] = 'UNUSED'
536
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:clob] = 'UNUSED'
429
+ ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:table] = "UNUSED"
430
+ ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:clob] = "UNUSED"
537
431
  @conn = ActiveRecord::Base.connection
538
432
  end
539
433
  after(:all) do
540
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces={}
434
+ ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces = {}
541
435
  end
542
436
 
543
437
  after(:each) do
544
438
  @conn.drop_table :foos rescue nil
545
439
  end
546
440
  it "should create ok" do
547
- @conn.create_table :foos, :temporary => true, :id => false do |t|
441
+ @conn.create_table :foos, temporary: true, id: false do |t|
548
442
  t.integer :id
549
443
  t.text :bar
550
444
  end
551
445
  end
552
446
  it "should show up as temporary" do
553
- @conn.create_table :foos, :temporary => true, :id => false do |t|
447
+ @conn.create_table :foos, temporary: true, id: false do |t|
554
448
  t.integer :id
555
449
  end
556
450
  expect(@conn.temporary_table?("foos")).to be_truthy
@@ -578,8 +472,8 @@ describe "OracleEnhancedAdapter" do
578
472
  @ids = (1..1010).to_a
579
473
  TestPost.transaction do
580
474
  @ids.each do |id|
581
- TestPost.create!(:id => id, :title => "Title #{id}")
582
- TestComment.create!(:test_post_id => id, :description => "Description #{id}")
475
+ TestPost.create!(id: id, title: "Title #{id}")
476
+ TestComment.create!(test_post_id: id, description: "Description #{id}")
583
477
  end
584
478
  end
585
479
  end
@@ -591,7 +485,7 @@ describe "OracleEnhancedAdapter" do
591
485
  end
592
486
  Object.send(:remove_const, "TestPost")
593
487
  Object.send(:remove_const, "TestComment")
594
- ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
488
+ ActiveRecord::Base.clear_cache!
595
489
  end
596
490
 
597
491
  it "should load included association with more than 1000 records" do
@@ -603,7 +497,7 @@ describe "OracleEnhancedAdapter" do
603
497
 
604
498
  describe "with statement pool" do
605
499
  before(:all) do
606
- ActiveRecord::Base.establish_connection(CONNECTION_PARAMS.merge(:statement_limit => 3))
500
+ ActiveRecord::Base.establish_connection(CONNECTION_PARAMS.merge(statement_limit: 3))
607
501
  @conn = ActiveRecord::Base.connection
608
502
  schema_define do
609
503
  drop_table :test_posts rescue nil
@@ -623,7 +517,7 @@ describe "OracleEnhancedAdapter" do
623
517
  drop_table :test_posts
624
518
  end
625
519
  Object.send(:remove_const, "TestPost")
626
- ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
520
+ ActiveRecord::Base.clear_cache!
627
521
  end
628
522
 
629
523
  it "should clear older cursors when statement limit is reached" do
@@ -671,17 +565,17 @@ describe "OracleEnhancedAdapter" do
671
565
  drop_table :test_posts
672
566
  end
673
567
  Object.send(:remove_const, "TestPost")
674
- ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
568
+ ActiveRecord::Base.clear_cache!
675
569
  end
676
570
 
677
571
  it "should explain query" do
678
- explain = TestPost.where(:id => 1).explain
572
+ explain = TestPost.where(id: 1).explain
679
573
  expect(explain).to include("Cost")
680
574
  expect(explain).to include("INDEX UNIQUE SCAN")
681
575
  end
682
576
 
683
577
  it "should explain query with binds" do
684
- pending "Pending until further investigation made for #908" if RUBY_ENGINE == 'jruby'
578
+ pending "Pending until further investigation made for #908" if RUBY_ENGINE == "jruby"
685
579
  pk = TestPost.columns_hash[TestPost.primary_key]
686
580
  sub = Arel::Nodes::BindParam.new.to_sql
687
581
  binds = [ActiveRecord::Relation::QueryAttribute.new(pk, 1, ActiveRecord::Type::Integer.new)]
@@ -714,11 +608,11 @@ describe "OracleEnhancedAdapter" do
714
608
  self.table_name = :test_employees
715
609
  end
716
610
  i = 0
717
- @employee.create!(sort_order: i+=1, first_name: 'Peter', last_name: 'Parker')
718
- @employee.create!(sort_order: i+=1, first_name: 'Tony', last_name: 'Stark')
719
- @employee.create!(sort_order: i+=1, first_name: 'Steven', last_name: 'Rogers')
720
- @employee.create!(sort_order: i+=1, first_name: 'Bruce', last_name: 'Banner')
721
- @employee.create!(sort_order: i+=1, first_name: 'Natasha', last_name: 'Romanova')
611
+ @employee.create!(sort_order: i += 1, first_name: "Peter", last_name: "Parker")
612
+ @employee.create!(sort_order: i += 1, first_name: "Tony", last_name: "Stark")
613
+ @employee.create!(sort_order: i += 1, first_name: "Steven", last_name: "Rogers")
614
+ @employee.create!(sort_order: i += 1, first_name: "Bruce", last_name: "Banner")
615
+ @employee.create!(sort_order: i += 1, first_name: "Natasha", last_name: "Romanova")
722
616
  end
723
617
 
724
618
  after(:all) do
@@ -727,8 +621,7 @@ describe "OracleEnhancedAdapter" do
727
621
  end
728
622
 
729
623
  after(:each) do
730
- ActiveRecord::Base.connection.clear_ignored_table_columns
731
- ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
624
+ ActiveRecord::Base.clear_cache!
732
625
  end
733
626
 
734
627
  it "should return n records with limit(n)" do
@@ -762,7 +655,7 @@ describe "OracleEnhancedAdapter" do
762
655
  end
763
656
 
764
657
  it "returns true when passed a valid type" do
765
- column = @conn.columns('test_employees').find { |col| col.name == 'first_name' }
658
+ column = @conn.columns("test_employees").find { |col| col.name == "first_name" }
766
659
  expect(@conn.valid_type?(column.type)).to be true
767
660
  end
768
661
 
@@ -771,7 +664,7 @@ describe "OracleEnhancedAdapter" do
771
664
  end
772
665
  end
773
666
 
774
- describe 'serialized column' do
667
+ describe "serialized column" do
775
668
  before(:all) do
776
669
  schema_define do
777
670
  create_table :test_serialized_columns do |t|
@@ -787,9 +680,9 @@ describe "OracleEnhancedAdapter" do
787
680
  schema_define do
788
681
  drop_table :test_serialized_columns
789
682
  end
790
- Object.send(:remove_const, 'TestSerializedColumn')
683
+ Object.send(:remove_const, "TestSerializedColumn")
791
684
  ActiveRecord::Base.table_name_prefix = nil
792
- ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
685
+ ActiveRecord::Base.clear_cache!
793
686
  end
794
687
 
795
688
  before(:each) do
@@ -800,8 +693,8 @@ describe "OracleEnhancedAdapter" do
800
693
  clear_logger
801
694
  end
802
695
 
803
- it 'should serialize' do
804
- new_value = 'new_value'
696
+ it "should serialize" do
697
+ new_value = "new_value"
805
698
  serialized_column = TestSerializedColumn.new
806
699
 
807
700
  expect(serialized_column.serialized).to eq([])