activerecord-oracle_enhanced-adapter 1.7.7 → 1.8.0

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 +225 -0
  3. data/README.md +14 -0
  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 -63
  7. data/lib/active_record/connection_adapters/oracle_enhanced/column_dumper.rb +6 -52
  8. data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +13 -16
  9. data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +117 -119
  10. data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +33 -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 +58 -77
  13. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +0 -4
  14. data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +51 -79
  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 +77 -77
  17. data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +16 -45
  18. data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +60 -65
  19. data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +33 -51
  20. data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +149 -162
  21. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +112 -132
  22. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +3 -4
  23. data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +69 -107
  24. data/lib/active_record/connection_adapters/oracle_enhanced/version.rb +1 -1
  25. data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +292 -539
  26. data/lib/active_record/oracle_enhanced/type/boolean.rb +7 -11
  27. data/lib/active_record/oracle_enhanced/type/integer.rb +4 -5
  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 -2
  30. data/lib/active_record/oracle_enhanced/type/raw.rb +2 -4
  31. data/lib/active_record/oracle_enhanced/type/string.rb +2 -3
  32. data/lib/active_record/oracle_enhanced/type/text.rb +2 -4
  33. data/lib/active_record/oracle_enhanced/type/timestamptz.rb +23 -0
  34. data/lib/activerecord-oracle_enhanced-adapter.rb +2 -3
  35. data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +82 -162
  36. data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +35 -35
  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 +270 -365
  39. data/spec/active_record/connection_adapters/oracle_enhanced_database_tasks_spec.rb +14 -7
  40. data/spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb +5 -7
  41. data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +118 -127
  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 +73 -77
  44. data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +68 -83
  45. data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +263 -329
  46. data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +103 -48
  47. data/spec/spec_config.yaml.template +11 -0
  48. data/spec/spec_helper.rb +59 -60
  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 -95
  57. data/lib/active_record/connection_adapters/oracle_enhanced/cpk.rb +0 -21
  58. data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +0 -113
@@ -2,20 +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
-
19
15
  end
20
16
  end
21
17
  end
@@ -1,13 +1,12 @@
1
- #TODO Need to consider namespace change since paremt class moved to ActiveModel
2
- module ActiveRecord
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,10 +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
6
  class NationalCharacterString < ActiveRecord::OracleEnhanced::Type::String # :nodoc:
7
-
8
7
  def serialize(value)
9
8
  return unless value
10
9
  Data.new(super)
@@ -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,11 +13,10 @@ 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
21
-
22
20
  end
23
21
  end
24
22
  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,13 +15,12 @@ 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
22
22
  end
23
23
  end
24
-
25
24
  end
26
25
  end
27
26
  end
@@ -1,10 +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:
7
-
6
+ class Text < ActiveRecord::Type::Text # :nodoc:
8
7
  def changed_in_place?(raw_old_value, new_value)
9
8
  #TODO: Needs to find a way not to cast here.
10
9
  raw_old_value = cast(raw_old_value)
@@ -25,7 +24,6 @@ module ActiveRecord
25
24
  @value
26
25
  end
27
26
  end
28
-
29
27
  end
30
28
  end
31
29
  end
@@ -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?
@@ -15,7 +15,6 @@ if defined?(Rails)
15
15
  end
16
16
 
17
17
  end
18
-
19
18
  end
20
19
  end
21
20
  end
@@ -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,40 +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
-
287
180
  describe "reserved words column quoting" do
288
181
 
289
182
  before(:all) do
@@ -303,7 +196,7 @@ describe "OracleEnhancedAdapter" do
303
196
  end
304
197
  Object.send(:remove_const, "TestReservedWord")
305
198
  ActiveRecord::Base.table_name_prefix = nil
306
- ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
199
+ ActiveRecord::Base.clear_cache!
307
200
  end
308
201
 
309
202
  before(:each) do
@@ -322,9 +215,9 @@ describe "OracleEnhancedAdapter" do
322
215
 
323
216
  it "should create record" do
324
217
  attrs = {
325
- :varchar2 => 'dummy',
326
- :integer => 1,
327
- :comment => 'dummy'
218
+ varchar2: "dummy",
219
+ integer: 1,
220
+ comment: "dummy"
328
221
  }
329
222
  record = TestReservedWord.create!(attrs)
330
223
  record.reload
@@ -443,7 +336,7 @@ describe "OracleEnhancedAdapter" do
443
336
  self.table_name = "warehouse-things"
444
337
  end
445
338
 
446
- wh = WarehouseThing.create!(:name => "Foo", :foo => 2)
339
+ wh = WarehouseThing.create!(name: "Foo", foo: 2)
447
340
  expect(wh.id).not_to be_nil
448
341
 
449
342
  expect(@conn.tables).to include("warehouse-things")
@@ -455,14 +348,14 @@ describe "OracleEnhancedAdapter" do
455
348
  self.table_name = "CamelCase"
456
349
  end
457
350
 
458
- cc = CamelCase.create!(:name => "Foo", :foo => 2)
351
+ cc = CamelCase.create!(name: "Foo", foo: 2)
459
352
  expect(cc.id).not_to be_nil
460
353
 
461
354
  expect(@conn.tables).to include("CamelCase")
462
355
  end
463
356
 
464
357
  it "properly quotes database links" do
465
- 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"')
466
359
  end
467
360
  end
468
361
 
@@ -496,11 +389,11 @@ describe "OracleEnhancedAdapter" do
496
389
  @conn.execute "DROP DATABASE LINK #{@db_link}" rescue nil
497
390
  @sys_conn.drop_table :test_posts rescue nil
498
391
  Object.send(:remove_const, "TestPost") rescue nil
499
- ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
392
+ ActiveRecord::Base.clear_cache!
500
393
  end
501
394
 
502
395
  it "should verify database link" do
503
- @conn.select_value("select * from dual@#{@db_link}") == 'X'
396
+ @conn.select_value("select * from dual@#{@db_link}") == "X"
504
397
  end
505
398
 
506
399
  it "should get column names" do
@@ -508,7 +401,7 @@ describe "OracleEnhancedAdapter" do
508
401
  end
509
402
 
510
403
  it "should create record" do
511
- p = TestPost.create(:title => "Title", :body => "Body")
404
+ p = TestPost.create(title: "Title", body: "Body")
512
405
  expect(p.id).not_to be_nil
513
406
  expect(TestPost.find(p.id)).not_to be_nil
514
407
  end
@@ -522,7 +415,7 @@ describe "OracleEnhancedAdapter" do
522
415
 
523
416
  it "should get current database name" do
524
417
  # get database name if using //host:port/database connection string
525
- database_name = CONNECTION_PARAMS[:database].split('/').last
418
+ database_name = CONNECTION_PARAMS[:database].split("/").last
526
419
  expect(@conn.current_database.upcase).to eq(database_name.upcase)
527
420
  end
528
421
 
@@ -533,25 +426,25 @@ describe "OracleEnhancedAdapter" do
533
426
 
534
427
  describe "temporary tables" do
535
428
  before(:all) do
536
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:table] = 'UNUSED'
537
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:clob] = 'UNUSED'
429
+ ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:table] = "UNUSED"
430
+ ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:clob] = "UNUSED"
538
431
  @conn = ActiveRecord::Base.connection
539
432
  end
540
433
  after(:all) do
541
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces={}
434
+ ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces = {}
542
435
  end
543
436
 
544
437
  after(:each) do
545
438
  @conn.drop_table :foos rescue nil
546
439
  end
547
440
  it "should create ok" do
548
- @conn.create_table :foos, :temporary => true, :id => false do |t|
441
+ @conn.create_table :foos, temporary: true, id: false do |t|
549
442
  t.integer :id
550
443
  t.text :bar
551
444
  end
552
445
  end
553
446
  it "should show up as temporary" do
554
- @conn.create_table :foos, :temporary => true, :id => false do |t|
447
+ @conn.create_table :foos, temporary: true, id: false do |t|
555
448
  t.integer :id
556
449
  end
557
450
  expect(@conn.temporary_table?("foos")).to be_truthy
@@ -579,8 +472,8 @@ describe "OracleEnhancedAdapter" do
579
472
  @ids = (1..1010).to_a
580
473
  TestPost.transaction do
581
474
  @ids.each do |id|
582
- TestPost.create!(:id => id, :title => "Title #{id}")
583
- 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}")
584
477
  end
585
478
  end
586
479
  end
@@ -592,7 +485,7 @@ describe "OracleEnhancedAdapter" do
592
485
  end
593
486
  Object.send(:remove_const, "TestPost")
594
487
  Object.send(:remove_const, "TestComment")
595
- ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
488
+ ActiveRecord::Base.clear_cache!
596
489
  end
597
490
 
598
491
  it "should load included association with more than 1000 records" do
@@ -604,7 +497,7 @@ describe "OracleEnhancedAdapter" do
604
497
 
605
498
  describe "with statement pool" do
606
499
  before(:all) do
607
- ActiveRecord::Base.establish_connection(CONNECTION_PARAMS.merge(:statement_limit => 3))
500
+ ActiveRecord::Base.establish_connection(CONNECTION_PARAMS.merge(statement_limit: 3))
608
501
  @conn = ActiveRecord::Base.connection
609
502
  schema_define do
610
503
  drop_table :test_posts rescue nil
@@ -624,7 +517,7 @@ describe "OracleEnhancedAdapter" do
624
517
  drop_table :test_posts
625
518
  end
626
519
  Object.send(:remove_const, "TestPost")
627
- ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
520
+ ActiveRecord::Base.clear_cache!
628
521
  end
629
522
 
630
523
  it "should clear older cursors when statement limit is reached" do
@@ -672,16 +565,17 @@ describe "OracleEnhancedAdapter" do
672
565
  drop_table :test_posts
673
566
  end
674
567
  Object.send(:remove_const, "TestPost")
675
- ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
568
+ ActiveRecord::Base.clear_cache!
676
569
  end
677
570
 
678
571
  it "should explain query" do
679
- explain = TestPost.where(:id => 1).explain
572
+ explain = TestPost.where(id: 1).explain
680
573
  expect(explain).to include("Cost")
681
574
  expect(explain).to include("INDEX UNIQUE SCAN")
682
575
  end
683
576
 
684
577
  it "should explain query with binds" do
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([])
@@ -816,4 +709,31 @@ describe "OracleEnhancedAdapter" do
816
709
  expect(serialized_column.save!).to eq(true)
817
710
  end
818
711
  end
712
+
713
+ describe "quoting" do
714
+ before(:all) do
715
+ schema_define do
716
+ create_table :test_logs, force: true do |t|
717
+ t.timestamp :send_time
718
+ end
719
+ end
720
+ class TestLog < ActiveRecord::Base
721
+ validates_uniqueness_of :send_time
722
+ end
723
+ end
724
+
725
+ after(:all) do
726
+ schema_define do
727
+ drop_table :test_logs
728
+ end
729
+ Object.send(:remove_const, "TestLog")
730
+ ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
731
+ end
732
+
733
+ it "should create records including Time" do
734
+ TestLog.create! send_time: Time.now + 1.seconds
735
+ TestLog.create! send_time: Time.now + 2.seconds
736
+ expect(TestLog.count).to eq 2
737
+ end
738
+ end
819
739
  end