activerecord-oracle_enhanced-adapter 1.6.9 → 1.7.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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -11
  3. data/History.md +126 -14
  4. data/README.md +9 -6
  5. data/RUNNING_TESTS.md +1 -1
  6. data/Rakefile +1 -16
  7. data/VERSION +1 -1
  8. data/activerecord-oracle_enhanced-adapter.gemspec +15 -52
  9. data/lib/active_record/connection_adapters/oracle_enhanced/column.rb +8 -22
  10. data/lib/active_record/connection_adapters/oracle_enhanced/column_dumper.rb +53 -45
  11. data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +6 -1
  12. data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +23 -62
  13. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +46 -56
  14. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +35 -0
  15. data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +34 -21
  16. data/lib/active_record/connection_adapters/oracle_enhanced/oci_quoting.rb +36 -0
  17. data/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb +1 -1
  18. data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +174 -0
  19. data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +17 -8
  20. data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +17 -11
  21. data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +160 -178
  22. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +42 -94
  23. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +50 -54
  24. data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +15 -11
  25. data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +197 -301
  26. data/lib/active_record/oracle_enhanced/type/integer.rb +3 -2
  27. data/lib/active_record/oracle_enhanced/type/national_character_string.rb +25 -0
  28. data/lib/active_record/oracle_enhanced/type/raw.rb +14 -2
  29. data/lib/active_record/oracle_enhanced/type/string.rb +28 -0
  30. data/lib/active_record/oracle_enhanced/type/text.rb +32 -0
  31. data/lib/activerecord-oracle_enhanced-adapter.rb +12 -17
  32. data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +113 -135
  33. data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +51 -59
  34. data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +40 -41
  35. data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +6 -6
  36. data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +281 -233
  37. data/spec/active_record/connection_adapters/oracle_enhanced_database_tasks_spec.rb +7 -7
  38. data/spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb +10 -10
  39. data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +22 -22
  40. data/spec/active_record/connection_adapters/oracle_enhanced_emulate_oracle_adapter_spec.rb +2 -2
  41. data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +36 -37
  42. data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +86 -46
  43. data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +194 -294
  44. data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +53 -39
  45. data/spec/spec_helper.rb +0 -6
  46. metadata +42 -143
  47. data/.travis.yml +0 -39
  48. data/.travis/oracle/download.sh +0 -14
  49. data/.travis/oracle/install.sh +0 -31
  50. data/.travis/setup_accounts.sh +0 -9
  51. data/lib/active_record/connection_adapters/oracle_enhanced/dirty.rb +0 -40
  52. data/lib/active_record/oracle_enhanced/type/timestamp.rb +0 -11
  53. data/spec/spec_config.yaml.template +0 -11
  54. data/spec/support/alter_system_user_password.sql +0 -2
  55. data/spec/support/create_oracle_enhanced_users.sql +0 -31
@@ -52,11 +52,11 @@ describe "OracleEnhancedAdapter composite_primary_keys support" do
52
52
  end
53
53
 
54
54
  it "should tell ActiveRecord that count distinct is not supported" do
55
- ActiveRecord::Base.connection.supports_count_distinct?.should be false
55
+ expect(ActiveRecord::Base.connection.supports_count_distinct?).to be_falsey
56
56
  end
57
57
 
58
58
  it "should execute correct SQL COUNT DISTINCT statement on table with composite primary keys" do
59
- lambda { JobHistory.count(:distinct => true) }.should_not raise_error
59
+ expect { JobHistory.count(:distinct => true) }.not_to raise_error
60
60
  end
61
61
  end
62
62
 
@@ -94,15 +94,15 @@ describe "OracleEnhancedAdapter composite_primary_keys support" do
94
94
  end
95
95
 
96
96
  it "should create new record in table with CPK and LOB" do
97
- lambda {
97
+ expect {
98
98
  CpkWriteLobsTest.create(:type_category => 'AAA', :date_value => Date.today, :results => 'DATA '*10)
99
- }.should_not raise_error
99
+ }.not_to raise_error
100
100
  end
101
101
 
102
102
  it "should create new record in table without CPK and with LOB" do
103
- lambda {
103
+ expect {
104
104
  NonCpkWriteLobsTest.create(:date_value => Date.today, :results => 'DATA '*10)
105
- }.should_not raise_error
105
+ }.not_to raise_error
106
106
  end
107
107
  end
108
108
 
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  require 'spec_helper'
3
2
 
4
3
  describe "OracleEnhancedAdapter date type detection based on column names" do
@@ -35,59 +34,59 @@ describe "OracleEnhancedAdapter date type detection based on column names" do
35
34
  @conn.execute "DROP SEQUENCE test_employees_seq"
36
35
  end
37
36
 
38
- it "should set DATE column type as datetime if emulate_dates_by_column_name is false" do
37
+ xit "should set DATE column type as datetime if emulate_dates_by_column_name is false" do
39
38
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
40
39
  columns = @conn.columns('test_employees')
41
40
  column = columns.detect{|c| c.name == "hire_date"}
42
- column.type.should == :datetime
41
+ expect(column.type).to eq(:datetime)
43
42
  end
44
43
 
45
- it "should set DATE column type as date if column name contains '_date_' and emulate_dates_by_column_name is true" do
44
+ xit "should set DATE column type as date if column name contains '_date_' and emulate_dates_by_column_name is true" do
46
45
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
47
46
  columns = @conn.columns('test_employees')
48
47
  column = columns.detect{|c| c.name == "hire_date"}
49
- column.type.should == :date
48
+ expect(column.type).to eq(:date)
50
49
  end
51
50
 
52
- it "should set DATE column type as datetime if column name does not contain '_date_' and emulate_dates_by_column_name is true" do
51
+ xit "should set DATE column type as datetime if column name does not contain '_date_' and emulate_dates_by_column_name is true" do
53
52
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
54
53
  columns = @conn.columns('test_employees')
55
54
  column = columns.detect{|c| c.name == "created_at"}
56
- column.type.should == :datetime
55
+ expect(column.type).to eq(:datetime)
57
56
  end
58
57
 
59
- it "should set DATE column type as datetime if column name contains 'date' as part of other word and emulate_dates_by_column_name is true" do
58
+ xit "should set DATE column type as datetime if column name contains 'date' as part of other word and emulate_dates_by_column_name is true" do
60
59
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
61
60
  columns = @conn.columns('test_employees')
62
61
  column = columns.detect{|c| c.name == "updated_at"}
63
- column.type.should == :datetime
62
+ expect(column.type).to eq(:datetime)
64
63
  end
65
64
 
66
- it "should return Time value from DATE column if emulate_dates_by_column_name is false" do
65
+ xit "should return Time value from DATE column if emulate_dates_by_column_name is false" do
67
66
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
68
67
  columns = @conn.columns('test_employees')
69
68
  column = columns.detect{|c| c.name == "hire_date"}
70
- column.type_cast_from_database(Time.now).class.should == Time
69
+ expect(@conn.lookup_cast_type_from_column(column).cast(Time.now).class).to eq(Time)
71
70
  end
72
71
 
73
- it "should return Date value from DATE column if column name contains 'date' and emulate_dates_by_column_name is true" do
72
+ xit "should return Date value from DATE column if column name contains 'date' and emulate_dates_by_column_name is true" do
74
73
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
75
74
  columns = @conn.columns('test_employees')
76
75
  column = columns.detect{|c| c.name == "hire_date"}
77
- column.type_cast_from_database(Time.now).class.should == Date
76
+ expect(@conn.lookup_cast_type_from_column(column).cast(Time.now).class).to eq(Date)
78
77
  end
79
78
 
80
- it "should typecast DateTime value to Date value from DATE column if column name contains 'date' and emulate_dates_by_column_name is true" do
79
+ xit "should typecast DateTime value to Date value from DATE column if column name contains 'date' and emulate_dates_by_column_name is true" do
81
80
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
82
81
  columns = @conn.columns('test_employees')
83
82
  column = columns.detect{|c| c.name == "hire_date"}
84
- column.type_cast_from_database(DateTime.new(1900,1,1)).class.should == Date
83
+ expect(@conn.lookup_cast_type_from_column(column).cast(DateTime.new(1900,1,1)).class).to eq(Date)
85
84
  end
86
85
 
87
86
  describe "/ DATE values from ActiveRecord model" do
88
87
  before(:each) do
89
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
90
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates = false
88
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
89
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates = false
91
90
  class ::TestEmployee < ActiveRecord::Base
92
91
  self.primary_key = "employee_id"
93
92
  end
@@ -113,77 +112,91 @@ describe "OracleEnhancedAdapter date type detection based on column names" do
113
112
  end
114
113
 
115
114
  it "should return Time value from DATE column if emulate_dates_by_column_name is false" do
116
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
115
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
116
+ class ::TestEmployee < ActiveRecord::Base
117
+ attribute :hire_date, :datetime
118
+ end
117
119
  create_test_employee
118
- @employee.hire_date.class.should == Time
120
+ expect(@employee.hire_date.class).to eq(Time)
119
121
  end
120
122
 
121
123
  it "should return Date value from DATE column if column name contains 'date' and emulate_dates_by_column_name is true" do
122
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
124
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
123
125
  create_test_employee
124
- @employee.hire_date.class.should == Date
126
+ expect(@employee.hire_date.class).to eq(Date)
125
127
  end
126
128
 
127
129
  it "should return Date value from DATE column with old date value if column name contains 'date' and emulate_dates_by_column_name is true" do
128
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
130
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
129
131
  create_test_employee(:today => Date.new(1900,1,1))
130
- @employee.hire_date.class.should == Date
132
+ expect(@employee.hire_date.class).to eq(Date)
131
133
  end
132
134
 
133
135
  it "should return Time value from DATE column if column name does not contain 'date' and emulate_dates_by_column_name is true" do
134
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
136
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
137
+ class ::TestEmployee < ActiveRecord::Base
138
+ # set_date_columns :created_at
139
+ attribute :created_at, :datetime
140
+ end
135
141
  create_test_employee
136
- @employee.created_at.class.should == Time
142
+ expect(@employee.created_at.class).to eq(Time)
137
143
  end
138
144
 
139
145
  it "should return Date value from DATE column if emulate_dates_by_column_name is false but column is defined as date" do
140
146
  class ::TestEmployee < ActiveRecord::Base
141
- set_date_columns :hire_date
147
+ # set_date_columns :hire_date
148
+ attribute :hire_date, :date
142
149
  end
143
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
150
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
144
151
  create_test_employee
145
- @employee.hire_date.class.should == Date
152
+ expect(@employee.hire_date.class).to eq(Date)
146
153
  end
147
154
 
148
155
  it "should return Date value from DATE column with old date value if emulate_dates_by_column_name is false but column is defined as date" do
149
156
  class ::TestEmployee < ActiveRecord::Base
150
- set_date_columns :hire_date
157
+ # set_date_columns :hire_date
158
+ attribute :hire_date, :date
151
159
  end
152
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
160
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
153
161
  create_test_employee(:today => Date.new(1900,1,1))
154
- @employee.hire_date.class.should == Date
162
+ expect(@employee.hire_date.class).to eq(Date)
155
163
  end
156
164
 
157
- it "should see set_date_columns values in different connection" do
165
+ xit "should see set_date_columns values in different connection" do
158
166
  class ::TestEmployee < ActiveRecord::Base
159
167
  set_date_columns :hire_date
160
168
  end
161
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
169
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
162
170
  # establish other connection
163
171
  other_conn = ActiveRecord::Base.oracle_enhanced_connection(CONNECTION_PARAMS)
164
- other_conn.get_type_for_column('test_employees', 'hire_date').should == :date
172
+ expect(other_conn.get_type_for_column('test_employees', 'hire_date')).to eq(:date)
165
173
  end
166
174
 
167
175
  it "should return Time value from DATE column if emulate_dates_by_column_name is true but column is defined as datetime" do
168
176
  class ::TestEmployee < ActiveRecord::Base
169
- set_datetime_columns :hire_date
177
+ # set_datetime_columns :hire_date
178
+ attribute :hire_date, :datetime
170
179
  end
171
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
180
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
172
181
  create_test_employee
173
- @employee.hire_date.class.should == Time
182
+ expect(@employee.hire_date.class).to eq(Time)
174
183
  # change to current time with hours, minutes and seconds
175
184
  @employee.hire_date = @now
176
185
  @employee.save!
177
186
  @employee.reload
178
- @employee.hire_date.class.should == Time
179
- @employee.hire_date.should == @now
187
+ expect(@employee.hire_date.class).to eq(Time)
188
+ expect(@employee.hire_date).to eq(@now)
180
189
  end
181
190
 
182
191
  it "should guess Date or Time value if emulate_dates is true" do
183
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates = true
192
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates = true
193
+ class ::TestEmployee < ActiveRecord::Base
194
+ attribute :hire_date, :date
195
+ attribute :created_at, :datetime
196
+ end
184
197
  create_test_employee
185
- @employee.hire_date.class.should == Date
186
- @employee.created_at.class.should == Time
198
+ expect(@employee.hire_date.class).to eq(Date)
199
+ expect(@employee.created_at.class).to eq(Time)
187
200
  end
188
201
 
189
202
  end
@@ -224,41 +237,41 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
224
237
  @conn.execute "DROP SEQUENCE test2_employees_seq"
225
238
  end
226
239
 
227
- it "should set NUMBER column type as decimal if emulate_integers_by_column_name is false" do
240
+ xit "should set NUMBER column type as decimal if emulate_integers_by_column_name is false" do
228
241
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = false
229
242
  columns = @conn.columns('test2_employees')
230
243
  column = columns.detect{|c| c.name == "job_id"}
231
- column.type.should == :decimal
244
+ expect(column.type).to eq(:decimal)
232
245
  end
233
246
 
234
- it "should set NUMBER column type as integer if emulate_integers_by_column_name is true" do
247
+ xit "should set NUMBER column type as integer if emulate_integers_by_column_name is true" do
235
248
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
236
249
  columns = @conn.columns('test2_employees')
237
250
  column = columns.detect{|c| c.name == "job_id"}
238
- column.type.should == :integer
251
+ expect(column.type).to eq(:integer)
239
252
  column = columns.detect{|c| c.name == "id"}
240
- column.type.should == :integer
253
+ expect(column.type).to eq(:integer)
241
254
  end
242
255
 
243
- it "should set NUMBER column type as decimal if column name does not contain 'id' and emulate_integers_by_column_name is true" do
256
+ xit "should set NUMBER column type as decimal if column name does not contain 'id' and emulate_integers_by_column_name is true" do
244
257
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
245
258
  columns = @conn.columns('test2_employees')
246
259
  column = columns.detect{|c| c.name == "salary"}
247
- column.type.should == :decimal
260
+ expect(column.type).to eq(:decimal)
248
261
  end
249
262
 
250
- it "should return BigDecimal value from NUMBER column if emulate_integers_by_column_name is false" do
263
+ xit "should return BigDecimal value from NUMBER column if emulate_integers_by_column_name is false" do
251
264
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = false
252
265
  columns = @conn.columns('test2_employees')
253
266
  column = columns.detect{|c| c.name == "job_id"}
254
- column.type_cast_from_database(1.0).class.should == BigDecimal
267
+ expect(@conn.lookup_cast_type_from_column(column).cast(1.0).class).to eq(BigDecimal)
255
268
  end
256
269
 
257
- it "should return Integer value from NUMBER column if column name contains 'id' and emulate_integers_by_column_name is true" do
270
+ xit "should return Fixnum value from NUMBER column if column name contains 'id' and emulate_integers_by_column_name is true" do
258
271
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
259
272
  columns = @conn.columns('test2_employees')
260
273
  column = columns.detect{|c| c.name == "job_id"}
261
- expect(column.type_cast_from_database(1.0)).to be_a(Integer)
274
+ expect(@conn.lookup_cast_type_from_column(column).cast(1.0).class).to eq(Fixnum)
262
275
  end
263
276
 
264
277
  describe "/ NUMBER values from ActiveRecord model" do
@@ -286,53 +299,65 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
286
299
  end
287
300
 
288
301
  it "should return BigDecimal value from NUMBER column if emulate_integers_by_column_name is false" do
289
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = false
302
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = false
290
303
  create_employee2
291
- @employee2.job_id.class.should == BigDecimal
304
+ expect(@employee2.job_id.class).to eq(BigDecimal)
292
305
  end
293
306
 
294
- it "should return Integer value from NUMBER column if column name contains 'id' and emulate_integers_by_column_name is true" do
295
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
307
+ it "should return Fixnum value from NUMBER column if column name contains 'id' and emulate_integers_by_column_name is true" do
308
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
309
+ class ::Test2Employee < ActiveRecord::Base
310
+ attribute :job_id, :integer
311
+ end
296
312
  create_employee2
297
- expect(@employee2.job_id).to be_a(Integer)
313
+ expect(@employee2.job_id.class).to eq(Fixnum)
298
314
  end
299
315
 
300
- it "should return Integer value from NUMBER column with integer value using _before_type_cast method" do
301
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
316
+ it "should return Fixnum value from NUMBER column with integer value using _before_type_cast method" do
317
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
302
318
  create_employee2
303
- expect(@employee2.job_id_before_type_cast).to be_a(Integer)
319
+ expect(@employee2.job_id_before_type_cast.class).to eq(Fixnum)
304
320
  end
305
321
 
306
322
  it "should return BigDecimal value from NUMBER column if column name does not contain 'id' and emulate_integers_by_column_name is true" do
307
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
323
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
308
324
  create_employee2
309
- @employee2.salary.class.should == BigDecimal
325
+ expect(@employee2.salary.class).to eq(BigDecimal)
310
326
  end
311
327
 
312
- it "should return Integer value from NUMBER column if column specified in set_integer_columns" do
313
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = false
314
- Test2Employee.set_integer_columns :job_id
328
+ it "should return Fixnum value from NUMBER column if column specified in set_integer_columns" do
329
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = false
330
+ # Test2Employee.set_integer_columns :job_id
331
+ class ::Test2Employee < ActiveRecord::Base
332
+ attribute :job_id, :integer
333
+ end
315
334
  create_employee2
316
- expect(@employee2.job_id).to be_a(Integer)
335
+ expect(@employee2.job_id.class).to eq(Fixnum)
317
336
  end
318
337
 
319
338
  it "should return Boolean value from NUMBER(1) column if emulate booleans is used" do
320
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans = true
339
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans = true
321
340
  create_employee2
322
- @employee2.is_manager.class.should == TrueClass
341
+ expect(@employee2.is_manager.class).to eq(TrueClass)
323
342
  end
324
343
 
325
- it "should return Integer value from NUMBER(1) column if emulate booleans is not used" do
326
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans = false
344
+ it "should return Fixnum value from NUMBER(1) column if emulate booleans is not used" do
345
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans = false
346
+ class ::Test2Employee < ActiveRecord::Base
347
+ attribute :is_manager, :integer
348
+ end
327
349
  create_employee2
328
- expect(@employee2.is_manager).to be_a(Integer)
350
+ expect(@employee2.is_manager.class).to eq(Fixnum)
329
351
  end
330
352
 
331
- it "should return Integer value from NUMBER(1) column if column specified in set_integer_columns" do
332
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans = true
333
- Test2Employee.set_integer_columns :is_manager
353
+ it "should return Fixnum value from NUMBER(1) column if column specified in set_integer_columns" do
354
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans = true
355
+ # Test2Employee.set_integer_columns :is_manager
356
+ class ::Test2Employee < ActiveRecord::Base
357
+ attribute :is_manager, :integer
358
+ end
334
359
  create_employee2
335
- expect(@employee2.is_manager).to be_a(Integer)
360
+ expect(@employee2.is_manager.class).to eq(Fixnum)
336
361
  end
337
362
 
338
363
  end
@@ -373,7 +398,7 @@ describe "OracleEnhancedAdapter boolean type detection based on string column ty
373
398
  after(:all) do
374
399
  @conn.execute "DROP TABLE test3_employees"
375
400
  @conn.execute "DROP SEQUENCE test3_employees_seq"
376
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
401
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
377
402
  end
378
403
 
379
404
  before(:each) do
@@ -390,7 +415,7 @@ describe "OracleEnhancedAdapter boolean type detection based on string column ty
390
415
  describe "default values in new records" do
391
416
  context "when emulate_booleans_from_strings is false" do
392
417
  before do
393
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
418
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
394
419
  end
395
420
 
396
421
  it "are Y or N" do
@@ -402,10 +427,14 @@ describe "OracleEnhancedAdapter boolean type detection based on string column ty
402
427
 
403
428
  context "when emulate_booleans_from_strings is true" do
404
429
  before do
405
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
430
+ #ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
406
431
  end
407
432
 
408
433
  it "are True or False" do
434
+ class ::Test3Employee < ActiveRecord::Base
435
+ attribute :has_phone, :boolean
436
+ attribute :manager_yn, :boolean, default: false
437
+ end
409
438
  subject = Test3Employee.new
410
439
  expect(subject.has_phone).to be_a(TrueClass)
411
440
  expect(subject.manager_yn).to be_a(FalseClass)
@@ -413,74 +442,74 @@ describe "OracleEnhancedAdapter boolean type detection based on string column ty
413
442
  end
414
443
  end
415
444
 
416
- it "should set CHAR/VARCHAR2 column type as string if emulate_booleans_from_strings is false" do
445
+ xit "should set CHAR/VARCHAR2 column type as string if emulate_booleans_from_strings is false" do
417
446
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
418
447
  columns = @conn.columns('test3_employees')
419
448
  %w(has_email has_phone active_flag manager_yn).each do |col|
420
449
  column = columns.detect{|c| c.name == col}
421
- column.type.should == :string
450
+ expect(column.type).to eq(:string)
422
451
  end
423
452
  end
424
453
 
425
- it "should set CHAR/VARCHAR2 column type as boolean if emulate_booleans_from_strings is true" do
454
+ xit "should set CHAR/VARCHAR2 column type as boolean if emulate_booleans_from_strings is true" do
426
455
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
427
456
  columns = @conn.columns('test3_employees')
428
457
  %w(has_email has_phone active_flag manager_yn).each do |col|
429
458
  column = columns.detect{|c| c.name == col}
430
- column.type.should == :boolean
459
+ expect(column.type).to eq(:boolean)
431
460
  end
432
461
  end
433
462
 
434
- it "should set VARCHAR2 column type as string if column name does not contain 'flag' or 'yn' and emulate_booleans_from_strings is true" do
463
+ xit "should set VARCHAR2 column type as string if column name does not contain 'flag' or 'yn' and emulate_booleans_from_strings is true" do
435
464
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
436
465
  columns = @conn.columns('test3_employees')
437
466
  %w(phone_number email).each do |col|
438
467
  column = columns.detect{|c| c.name == col}
439
- column.type.should == :string
468
+ expect(column.type).to eq(:string)
440
469
  end
441
470
  end
442
471
 
443
- it "should return string value from VARCHAR2 boolean column if emulate_booleans_from_strings is false" do
472
+ xit "should return string value from VARCHAR2 boolean column if emulate_booleans_from_strings is false" do
444
473
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
445
474
  columns = @conn.columns('test3_employees')
446
475
  %w(has_email has_phone active_flag manager_yn).each do |col|
447
476
  column = columns.detect{|c| c.name == col}
448
- column.type_cast_from_database("Y").class.should == String
477
+ expect(@conn.lookup_cast_type_from_column(column).cast("Y").class).to eq(String)
449
478
  end
450
479
  end
451
480
 
452
- it "should return boolean value from VARCHAR2 boolean column if emulate_booleans_from_strings is true" do
481
+ xit "should return boolean value from VARCHAR2 boolean column if emulate_booleans_from_strings is true" do
453
482
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
454
483
  columns = @conn.columns('test3_employees')
455
484
  %w(has_email has_phone active_flag manager_yn).each do |col|
456
485
  column = columns.detect{|c| c.name == col}
457
- column.type_cast_from_database("Y").class.should == TrueClass
458
- column.type_cast_from_database("N").class.should == FalseClass
486
+ expect(@conn.lookup_cast_type_from_column(column).cast("Y").class).to eq(TrueClass)
487
+ expect(@conn.lookup_cast_type_from_column(column).cast("N").class).to eq(FalseClass)
459
488
  end
460
489
  end
461
490
 
462
- it "should translate boolean type to VARCHAR2(1) if emulate_booleans_from_strings is true" do
491
+ xit "should translate boolean type to VARCHAR2(1) if emulate_booleans_from_strings is true" do
463
492
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
464
- ActiveRecord::Base.connection.type_to_sql(
465
- :boolean, nil, nil, nil).should == "VARCHAR2(1)"
493
+ expect(ActiveRecord::Base.connection.type_to_sql(
494
+ :boolean, nil, nil, nil)).to eq("VARCHAR2(1)")
466
495
  end
467
496
 
468
497
  it "should translate boolean type to NUMBER(1) if emulate_booleans_from_strings is false" do
469
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
470
- ActiveRecord::Base.connection.type_to_sql(
471
- :boolean, nil, nil, nil).should == "NUMBER(1)"
498
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
499
+ expect(ActiveRecord::Base.connection.type_to_sql(
500
+ :boolean, nil, nil, nil)).to eq("NUMBER(1)")
472
501
  end
473
502
 
474
- it "should get default value from VARCHAR2 boolean column if emulate_booleans_from_strings is true" do
503
+ xit "should get default value from VARCHAR2 boolean column if emulate_booleans_from_strings is true" do
475
504
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
476
505
  columns = @conn.columns('test3_employees')
477
- columns.detect{|c| c.name == 'has_phone'}.default.should eq 'Y'
478
- columns.detect{|c| c.name == 'manager_yn'}.default.should be false
506
+ expect(columns.detect{|c| c.name == 'has_phone'}.default).to be_truthy
507
+ expect(columns.detect{|c| c.name == 'manager_yn'}.default).to be_falsey
479
508
  end
480
509
 
481
510
  describe "/ VARCHAR2 boolean values from ActiveRecord model" do
482
511
  before(:each) do
483
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
512
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
484
513
  end
485
514
 
486
515
  after(:each) do
@@ -503,54 +532,66 @@ describe "OracleEnhancedAdapter boolean type detection based on string column ty
503
532
  end
504
533
 
505
534
  it "should return String value from VARCHAR2 boolean column if emulate_booleans_from_strings is false" do
506
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
535
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
507
536
  create_employee3
508
537
  %w(has_email has_phone active_flag manager_yn).each do |col|
509
- @employee3.send(col.to_sym).class.should == String
538
+ expect(@employee3.send(col.to_sym).class).to eq(String)
510
539
  end
511
540
  end
512
541
 
513
542
  it "should return boolean value from VARCHAR2 boolean column if emulate_booleans_from_strings is true" do
514
543
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
544
+ class ::Test3Employee < ActiveRecord::Base
545
+ attribute :has_email, :boolean
546
+ attribute :active_flag, :boolean
547
+ attribute :has_phone, :boolean, default: false
548
+ attribute :manager_yn, :boolean, default: false
549
+ end
515
550
  create_employee3
516
551
  %w(has_email active_flag).each do |col|
517
- @employee3.send(col.to_sym).class.should == TrueClass
518
- @employee3.send((col+"_before_type_cast").to_sym).should == "Y"
552
+ expect(@employee3.send(col.to_sym).class).to eq(TrueClass)
553
+ expect(@employee3.send((col+"_before_type_cast").to_sym)).to eq("Y")
519
554
  end
520
555
  %w(has_phone manager_yn).each do |col|
521
- @employee3.send(col.to_sym).class.should == FalseClass
522
- @employee3.send((col+"_before_type_cast").to_sym).should == "N"
556
+ expect(@employee3.send(col.to_sym).class).to eq(FalseClass)
557
+ expect(@employee3.send((col+"_before_type_cast").to_sym)).to eq("N")
523
558
  end
524
559
  end
525
560
 
526
561
  it "should return string value from VARCHAR2 column if it is not boolean column and emulate_booleans_from_strings is true" do
527
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
562
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
528
563
  create_employee3
529
- @employee3.first_name.class.should == String
564
+ expect(@employee3.first_name.class).to eq(String)
530
565
  end
531
566
 
532
567
  it "should return boolean value from VARCHAR2 boolean column if column specified in set_boolean_columns" do
533
568
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
534
- Test3Employee.set_boolean_columns :test_boolean
569
+ # Test3Employee.set_boolean_columns :test_boolean
570
+ class ::Test3Employee < ActiveRecord::Base
571
+ attribute :test_boolean, :boolean
572
+ end
535
573
  create_employee3(:test_boolean => true)
536
- @employee3.test_boolean.class.should == TrueClass
537
- @employee3.test_boolean_before_type_cast.should == "Y"
574
+ expect(@employee3.test_boolean.class).to eq(TrueClass)
575
+ expect(@employee3.test_boolean_before_type_cast).to eq("Y")
538
576
  create_employee3(:test_boolean => false)
539
- @employee3.test_boolean.class.should == FalseClass
540
- @employee3.test_boolean_before_type_cast.should == "N"
577
+ expect(@employee3.test_boolean.class).to eq(FalseClass)
578
+ expect(@employee3.test_boolean_before_type_cast).to eq("N")
541
579
  create_employee3(:test_boolean => nil)
542
- @employee3.test_boolean.class.should == NilClass
543
- @employee3.test_boolean_before_type_cast.should == nil
580
+ expect(@employee3.test_boolean.class).to eq(NilClass)
581
+ expect(@employee3.test_boolean_before_type_cast).to eq(nil)
544
582
  create_employee3(:test_boolean => "")
545
- @employee3.test_boolean.class.should == NilClass
546
- @employee3.test_boolean_before_type_cast.should == nil
583
+ expect(@employee3.test_boolean.class).to eq(NilClass)
584
+ expect(@employee3.test_boolean_before_type_cast).to eq(nil)
547
585
  end
548
586
 
549
587
  it "should return string value from VARCHAR2 column with boolean column name but is specified in set_string_columns" do
550
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
551
- Test3Employee.set_string_columns :active_flag
588
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
589
+ # Test3Employee.set_string_columns :active_flag
590
+ class ::Test3Employee < ActiveRecord::Base
591
+ attribute :active_flag, :string
592
+ end
552
593
  create_employee3
553
- @employee3.active_flag.class.should == String
594
+ expect(@employee3.active_flag.class).to eq(String)
554
595
  end
555
596
 
556
597
  end
@@ -591,9 +632,10 @@ describe "OracleEnhancedAdapter timestamp with timezone support" do
591
632
  end
592
633
 
593
634
  it "should set TIMESTAMP columns type as datetime" do
635
+ skip "TIMESTAMP sql_type should be :datetime in Rails 5"
594
636
  columns = @conn.columns('test_employees')
595
637
  ts_columns = columns.select{|c| c.name =~ /created_at/}
596
- ts_columns.each {|c| c.type.should == :timestamp}
638
+ ts_columns.each {|c| expect(c.type).to eq(:timestamp)}
597
639
  end
598
640
 
599
641
  describe "/ TIMESTAMP WITH TIME ZONE values from ActiveRecord model" do
@@ -601,11 +643,13 @@ describe "OracleEnhancedAdapter timestamp with timezone support" do
601
643
  class ::TestEmployee < ActiveRecord::Base
602
644
  self.primary_key = "employee_id"
603
645
  end
646
+ ActiveRecord::Base.default_timezone = :local
604
647
  end
605
648
 
606
649
  after(:all) do
607
650
  Object.send(:remove_const, "TestEmployee")
608
651
  ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
652
+ ActiveRecord::Base.default_timezone = :utc
609
653
  end
610
654
 
611
655
  it "should return Time value from TIMESTAMP columns" do
@@ -617,8 +661,8 @@ describe "OracleEnhancedAdapter timestamp with timezone support" do
617
661
  )
618
662
  @employee.reload
619
663
  [:created_at, :created_at_tz, :created_at_ltz].each do |c|
620
- @employee.send(c).class.should == Time
621
- @employee.send(c).to_f.should == @now.to_f
664
+ expect(@employee.send(c).class).to eq(Time)
665
+ expect(@employee.send(c).to_f).to eq(@now.to_f)
622
666
  end
623
667
  end
624
668
 
@@ -631,8 +675,8 @@ describe "OracleEnhancedAdapter timestamp with timezone support" do
631
675
  )
632
676
  @employee.reload
633
677
  [:created_at, :created_at_tz, :created_at_ltz].each do |c|
634
- @employee.send(c).class.should == Time
635
- @employee.send(c).to_f.should == @now.to_f
678
+ expect(@employee.send(c).class).to eq(Time)
679
+ expect(@employee.send(c).to_f).to eq(@now.to_f)
636
680
  end
637
681
  end
638
682
 
@@ -678,8 +722,8 @@ describe "OracleEnhancedAdapter date and timestamp with different NLS date forma
678
722
  end
679
723
 
680
724
  before(:each) do
681
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates = false
682
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
725
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates = false
726
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
683
727
  class ::TestEmployee < ActiveRecord::Base
684
728
  self.primary_key = "employee_id"
685
729
  end
@@ -690,6 +734,7 @@ describe "OracleEnhancedAdapter date and timestamp with different NLS date forma
690
734
  after(:each) do
691
735
  Object.send(:remove_const, "TestEmployee")
692
736
  ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
737
+ ActiveRecord::Base.default_timezone = :utc
693
738
  end
694
739
 
695
740
  def create_test_employee
@@ -704,45 +749,52 @@ describe "OracleEnhancedAdapter date and timestamp with different NLS date forma
704
749
  end
705
750
 
706
751
  it "should return Time value from DATE column if emulate_dates_by_column_name is false" do
707
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
752
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
753
+ ActiveRecord::Base.default_timezone = :local
754
+ class ::TestEmployee < ActiveRecord::Base
755
+ attribute :hire_date, :datetime
756
+ end
708
757
  create_test_employee
709
- @employee.hire_date.class.should == Time
710
- @employee.hire_date.should == @today.to_time
758
+ expect(@employee.hire_date.class).to eq(Time)
759
+ expect(@employee.hire_date).to eq(@today.to_time)
711
760
  end
712
761
 
713
762
  it "should return Date value from DATE column if column name contains 'date' and emulate_dates_by_column_name is true" do
714
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
763
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
715
764
  create_test_employee
716
- @employee.hire_date.class.should == Date
717
- @employee.hire_date.should == @today
765
+ expect(@employee.hire_date.class).to eq(Date)
766
+ expect(@employee.hire_date).to eq(@today)
718
767
  end
719
768
 
720
769
  it "should return Time value from DATE column if column name does not contain 'date' and emulate_dates_by_column_name is true" do
721
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
770
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
771
+ class ::TestEmployee < ActiveRecord::Base
772
+ attribute :created_at, :datetime
773
+ end
722
774
  create_test_employee
723
- @employee.created_at.class.should == Time
724
- @employee.created_at.should == @now
775
+ expect(@employee.created_at.class).to eq(Time)
776
+ expect(@employee.created_at).to eq(@now)
725
777
  end
726
778
 
727
779
  it "should return Time value from TIMESTAMP columns" do
728
780
  create_test_employee
729
- @employee.created_at_ts.class.should == Time
730
- @employee.created_at_ts.should == @now
781
+ expect(@employee.created_at_ts.class).to eq(Time)
782
+ expect(@employee.created_at_ts).to eq(@now)
731
783
  end
732
784
 
733
- it "should quote Date values with TO_DATE" do
734
- @conn.quote(@today).should == "TO_DATE('#{@today.year}-#{"%02d" % @today.month}-#{"%02d" % @today.day}','YYYY-MM-DD HH24:MI:SS')"
785
+ xit "should quote Date values with TO_DATE" do
786
+ expect(@conn.quote(@today)).to eq("TO_DATE('#{@today.year}-#{"%02d" % @today.month}-#{"%02d" % @today.day}','YYYY-MM-DD HH24:MI:SS')")
735
787
  end
736
788
 
737
- it "should quote Time values with TO_DATE" do
738
- @conn.quote(@now).should == "TO_DATE('#{@now.year}-#{"%02d" % @now.month}-#{"%02d" % @now.day} "+
739
- "#{"%02d" % @now.hour}:#{"%02d" % @now.min}:#{"%02d" % @now.sec}','YYYY-MM-DD HH24:MI:SS')"
789
+ xit "should quote Time values with TO_DATE" do
790
+ expect(@conn.quote(@now)).to eq("TO_DATE('#{@now.year}-#{"%02d" % @now.month}-#{"%02d" % @now.day} "+
791
+ "#{"%02d" % @now.hour}:#{"%02d" % @now.min}:#{"%02d" % @now.sec}','YYYY-MM-DD HH24:MI:SS')")
740
792
  end
741
793
 
742
- it "should quote Time values with TO_TIMESTAMP" do
794
+ xit "should quote Time values with TO_TIMESTAMP" do
743
795
  @ts = @now + 0.1
744
- @conn.quote(@ts).should == "TO_TIMESTAMP('#{@ts.year}-#{"%02d" % @ts.month}-#{"%02d" % @ts.day} "+
745
- "#{"%02d" % @ts.hour}:#{"%02d" % @ts.min}:#{"%02d" % @ts.sec}:100000','YYYY-MM-DD HH24:MI:SS:FF6')"
796
+ expect(@conn.quote(@ts)).to eq("TO_TIMESTAMP('#{@ts.year}-#{"%02d" % @ts.month}-#{"%02d" % @ts.day} "+
797
+ "#{"%02d" % @ts.hour}:#{"%02d" % @ts.min}:#{"%02d" % @ts.sec}:100000','YYYY-MM-DD HH24:MI:SS:FF6')")
746
798
  end
747
799
 
748
800
  end
@@ -767,6 +819,7 @@ describe "OracleEnhancedAdapter assign string to :date and :datetime columns" do
767
819
  SQL
768
820
  class ::TestEmployee < ActiveRecord::Base
769
821
  self.primary_key = "employee_id"
822
+ attribute :last_login_at, :datetime
770
823
  end
771
824
  @today = Date.new(2008,6,28)
772
825
  @today_iso = "2008-06-28"
@@ -789,7 +842,11 @@ describe "OracleEnhancedAdapter assign string to :date and :datetime columns" do
789
842
  end
790
843
 
791
844
  before(:each) do
792
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
845
+ # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
846
+ end
847
+
848
+ after(:each) do
849
+ ActiveRecord::Base.default_timezone = :utc
793
850
  end
794
851
 
795
852
  it "should assign ISO string to date column" do
@@ -798,9 +855,9 @@ describe "OracleEnhancedAdapter assign string to :date and :datetime columns" do
798
855
  :last_name => "Last",
799
856
  :hire_date => @today_iso
800
857
  )
801
- @employee.hire_date.should == @today
858
+ expect(@employee.hire_date).to eq(@today)
802
859
  @employee.reload
803
- @employee.hire_date.should == @today
860
+ expect(@employee.hire_date).to eq(@today)
804
861
  end
805
862
 
806
863
  it "should assign NLS string to date column" do
@@ -810,9 +867,9 @@ describe "OracleEnhancedAdapter assign string to :date and :datetime columns" do
810
867
  :last_name => "Last",
811
868
  :hire_date => @today_nls
812
869
  )
813
- @employee.hire_date.should == @today
870
+ expect(@employee.hire_date).to eq(@today)
814
871
  @employee.reload
815
- @employee.hire_date.should == @today
872
+ expect(@employee.hire_date).to eq(@today)
816
873
  end
817
874
 
818
875
  it "should assign ISO time string to date column" do
@@ -821,9 +878,9 @@ describe "OracleEnhancedAdapter assign string to :date and :datetime columns" do
821
878
  :last_name => "Last",
822
879
  :hire_date => @now_iso
823
880
  )
824
- @employee.hire_date.should == @today
881
+ expect(@employee.hire_date).to eq(@today)
825
882
  @employee.reload
826
- @employee.hire_date.should == @today
883
+ expect(@employee.hire_date).to eq(@today)
827
884
  end
828
885
 
829
886
  it "should assign NLS time string to date column" do
@@ -834,32 +891,34 @@ describe "OracleEnhancedAdapter assign string to :date and :datetime columns" do
834
891
  :last_name => "Last",
835
892
  :hire_date => @now_nls
836
893
  )
837
- @employee.hire_date.should == @today
894
+ expect(@employee.hire_date).to eq(@today)
838
895
  @employee.reload
839
- @employee.hire_date.should == @today
896
+ expect(@employee.hire_date).to eq(@today)
840
897
  end
841
898
 
842
899
  it "should assign ISO time string to datetime column" do
900
+ ActiveRecord::Base.default_timezone = :local
843
901
  @employee = TestEmployee.create(
844
902
  :first_name => "First",
845
903
  :last_name => "Last",
846
904
  :last_login_at => @now_iso
847
905
  )
848
- @employee.last_login_at.should == @now
906
+ expect(@employee.last_login_at).to eq(@now)
849
907
  @employee.reload
850
- @employee.last_login_at.should == @now
908
+ expect(@employee.last_login_at).to eq(@now)
851
909
  end
852
910
 
853
911
  it "should assign NLS time string to datetime column" do
912
+ ActiveRecord::Base.default_timezone = :local
854
913
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.string_to_time_format = @nls_time_format
855
914
  @employee = TestEmployee.create(
856
915
  :first_name => "First",
857
916
  :last_name => "Last",
858
917
  :last_login_at => @now_nls
859
918
  )
860
- @employee.last_login_at.should == @now
919
+ expect(@employee.last_login_at).to eq(@now)
861
920
  @employee.reload
862
- @employee.last_login_at.should == @now
921
+ expect(@employee.last_login_at).to eq(@now)
863
922
  end
864
923
 
865
924
  it "should assign NLS time string with time zone to datetime column" do
@@ -869,23 +928,25 @@ describe "OracleEnhancedAdapter assign string to :date and :datetime columns" do
869
928
  :last_name => "Last",
870
929
  :last_login_at => @now_nls_with_tz
871
930
  )
872
- @employee.last_login_at.should == @now_with_tz
931
+ expect(@employee.last_login_at).to eq(@now_with_tz)
873
932
  @employee.reload
874
- @employee.last_login_at.should == @now_with_tz
933
+ expect(@employee.last_login_at).to eq(@now_with_tz)
875
934
  end
876
935
 
877
936
  it "should assign ISO date string to datetime column" do
937
+ ActiveRecord::Base.default_timezone = :local
878
938
  @employee = TestEmployee.create(
879
939
  :first_name => "First",
880
940
  :last_name => "Last",
881
941
  :last_login_at => @today_iso
882
942
  )
883
- @employee.last_login_at.should == @today.to_time
943
+ expect(@employee.last_login_at).to eq(@today.to_time)
884
944
  @employee.reload
885
- @employee.last_login_at.should == @today.to_time
945
+ expect(@employee.last_login_at).to eq(@today.to_time)
886
946
  end
887
947
 
888
948
  it "should assign NLS date string to datetime column" do
949
+ ActiveRecord::Base.default_timezone = :local
889
950
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.string_to_date_format = @nls_date_format
890
951
  # ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.string_to_time_format = @nls_time_format
891
952
  @employee = TestEmployee.create(
@@ -893,9 +954,9 @@ describe "OracleEnhancedAdapter assign string to :date and :datetime columns" do
893
954
  :last_name => "Last",
894
955
  :last_login_at => @today_nls
895
956
  )
896
- @employee.last_login_at.should == @today.to_time
957
+ expect(@employee.last_login_at).to eq(@today.to_time)
897
958
  @employee.reload
898
- @employee.last_login_at.should == @today.to_time
959
+ expect(@employee.last_login_at).to eq(@today.to_time)
899
960
  end
900
961
 
901
962
  end
@@ -977,16 +1038,16 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
977
1038
  :first_name => "First",
978
1039
  :last_name => "Last"
979
1040
  )
980
- @employee.should be_valid
1041
+ expect(@employee).to be_valid
981
1042
  @employee.reload
982
- @employee.comments.should be_nil
1043
+ expect(@employee.comments).to be_nil
983
1044
  end
984
1045
 
985
1046
  it "should accept Symbol value for CLOB column" do
986
1047
  @employee = TestEmployee.create!(
987
1048
  :comments => :test_comment
988
1049
  )
989
- @employee.should be_valid
1050
+ expect(@employee).to be_valid
990
1051
  end
991
1052
 
992
1053
  it "should respect attr_readonly setting for CLOB column" do
@@ -994,13 +1055,13 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
994
1055
  :first_name => "First",
995
1056
  :comments => "initial"
996
1057
  )
997
- @employee.should be_valid
1058
+ expect(@employee).to be_valid
998
1059
  @employee.reload
999
- @employee.comments.should == 'initial'
1060
+ expect(@employee.comments).to eq('initial')
1000
1061
  @employee.comments = "changed"
1001
- @employee.save.should == true
1062
+ expect(@employee.save).to eq(true)
1002
1063
  @employee.reload
1003
- @employee.comments.should == 'initial'
1064
+ expect(@employee.comments).to eq('initial')
1004
1065
  end
1005
1066
 
1006
1067
  it "should work for serialized readonly CLOB columns", serialized: true do
@@ -1008,16 +1069,16 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
1008
1069
  :first_name => "First",
1009
1070
  :comments => nil
1010
1071
  )
1011
- @employee.comments.should be_nil
1012
- @employee.save.should == true
1013
- @employee.should be_valid
1072
+ expect(@employee.comments).to be_nil
1073
+ expect(@employee.save).to eq(true)
1074
+ expect(@employee).to be_valid
1014
1075
  @employee.reload
1015
- @employee.comments.should be_nil
1076
+ expect(@employee.comments).to be_nil
1016
1077
  @employee.comments = {}
1017
- @employee.save.should == true
1078
+ expect(@employee.save).to eq(true)
1018
1079
  @employee.reload
1019
1080
  #should not set readonly
1020
- @employee.comments.should be_nil
1081
+ expect(@employee.comments).to be_nil
1021
1082
  end
1022
1083
 
1023
1084
 
@@ -1028,7 +1089,7 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
1028
1089
  :comments => @char_data
1029
1090
  )
1030
1091
  @employee.reload
1031
- @employee.comments.should == @char_data
1092
+ expect(@employee.comments).to eq(@char_data)
1032
1093
  end
1033
1094
 
1034
1095
  it "should update record with CLOB data" do
@@ -1037,11 +1098,11 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
1037
1098
  :last_name => "Last"
1038
1099
  )
1039
1100
  @employee.reload
1040
- @employee.comments.should be_nil
1101
+ expect(@employee.comments).to be_nil
1041
1102
  @employee.comments = @char_data
1042
1103
  @employee.save!
1043
1104
  @employee.reload
1044
- @employee.comments.should == @char_data
1105
+ expect(@employee.comments).to eq(@char_data)
1045
1106
  end
1046
1107
 
1047
1108
  it "should update record with zero-length CLOB data" do
@@ -1050,11 +1111,11 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
1050
1111
  :last_name => "Last"
1051
1112
  )
1052
1113
  @employee.reload
1053
- @employee.comments.should be_nil
1114
+ expect(@employee.comments).to be_nil
1054
1115
  @employee.comments = ''
1055
1116
  @employee.save!
1056
1117
  @employee.reload
1057
- @employee.comments.should == ''
1118
+ expect(@employee.comments).to eq('')
1058
1119
  end
1059
1120
 
1060
1121
  it "should update record that has existing CLOB data with different CLOB data" do
@@ -1067,7 +1128,7 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
1067
1128
  @employee.comments = @char_data2
1068
1129
  @employee.save!
1069
1130
  @employee.reload
1070
- @employee.comments.should == @char_data2
1131
+ expect(@employee.comments).to eq(@char_data2)
1071
1132
  end
1072
1133
 
1073
1134
  it "should update record that has existing CLOB data with nil" do
@@ -1080,7 +1141,7 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
1080
1141
  @employee.comments = nil
1081
1142
  @employee.save!
1082
1143
  @employee.reload
1083
- @employee.comments.should be_nil
1144
+ expect(@employee.comments).to be_nil
1084
1145
  end
1085
1146
 
1086
1147
  it "should update record that has existing CLOB data with zero-length CLOB data" do
@@ -1093,7 +1154,7 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
1093
1154
  @employee.comments = ''
1094
1155
  @employee.save!
1095
1156
  @employee.reload
1096
- @employee.comments.should == ''
1157
+ expect(@employee.comments).to eq('')
1097
1158
  end
1098
1159
 
1099
1160
  it "should update record that has zero-length CLOB data with non-empty CLOB data" do
@@ -1103,11 +1164,11 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
1103
1164
  :comments => ''
1104
1165
  )
1105
1166
  @employee.reload
1106
- @employee.comments.should == ''
1167
+ expect(@employee.comments).to eq('')
1107
1168
  @employee.comments = @char_data
1108
1169
  @employee.save!
1109
1170
  @employee.reload
1110
- @employee.comments.should == @char_data
1171
+ expect(@employee.comments).to eq(@char_data)
1111
1172
  end
1112
1173
 
1113
1174
  it "should store serializable ruby data structures" do
@@ -1117,11 +1178,11 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
1117
1178
  :comments => ruby_data1
1118
1179
  )
1119
1180
  @employee.reload
1120
- @employee.comments.should == ruby_data1
1181
+ expect(@employee.comments).to eq(ruby_data1)
1121
1182
  @employee.comments = ruby_data2
1122
1183
  @employee.save
1123
1184
  @employee.reload
1124
- @employee.comments.should == ruby_data2
1185
+ expect(@employee.comments).to eq(ruby_data2)
1125
1186
  end
1126
1187
 
1127
1188
  it "should keep unchanged serialized data when other columns changed" do
@@ -1133,7 +1194,7 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
1133
1194
  @employee.first_name = "Steve"
1134
1195
  @employee.save
1135
1196
  @employee.reload
1136
- @employee.comments.should == "initial serialized data"
1197
+ expect(@employee.comments).to eq("initial serialized data")
1137
1198
  end
1138
1199
 
1139
1200
  it "should keep serialized data after save" do
@@ -1141,11 +1202,11 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
1141
1202
  @employee.comments = {:length=>{:is=>1}}
1142
1203
  @employee.save
1143
1204
  @employee.reload
1144
- @employee.comments.should == {:length=>{:is=>1}}
1205
+ expect(@employee.comments).to eq({:length=>{:is=>1}})
1145
1206
  @employee.comments = {:length=>{:is=>2}}
1146
1207
  @employee.save
1147
1208
  @employee.reload
1148
- @employee.comments.should == {:length=>{:is=>2}}
1209
+ expect(@employee.comments).to eq({:length=>{:is=>2}})
1149
1210
  end
1150
1211
  end
1151
1212
 
@@ -1192,7 +1253,7 @@ describe "OracleEnhancedAdapter handling of BLOB columns" do
1192
1253
  :binary_data => @binary_data
1193
1254
  )
1194
1255
  @employee.reload
1195
- @employee.binary_data.should == @binary_data
1256
+ expect(@employee.binary_data).to eq(@binary_data)
1196
1257
  end
1197
1258
 
1198
1259
  it "should update record with BLOB data" do
@@ -1201,11 +1262,11 @@ describe "OracleEnhancedAdapter handling of BLOB columns" do
1201
1262
  :last_name => "Last"
1202
1263
  )
1203
1264
  @employee.reload
1204
- @employee.binary_data.should be_nil
1265
+ expect(@employee.binary_data).to be_nil
1205
1266
  @employee.binary_data = @binary_data
1206
1267
  @employee.save!
1207
1268
  @employee.reload
1208
- @employee.binary_data.should == @binary_data
1269
+ expect(@employee.binary_data).to eq(@binary_data)
1209
1270
  end
1210
1271
 
1211
1272
  it "should update record with zero-length BLOB data" do
@@ -1214,11 +1275,11 @@ describe "OracleEnhancedAdapter handling of BLOB columns" do
1214
1275
  :last_name => "Last"
1215
1276
  )
1216
1277
  @employee.reload
1217
- @employee.binary_data.should be_nil
1278
+ expect(@employee.binary_data).to be_nil
1218
1279
  @employee.binary_data = ''
1219
1280
  @employee.save!
1220
1281
  @employee.reload
1221
- @employee.binary_data.should == ''
1282
+ expect(@employee.binary_data).to eq('')
1222
1283
  end
1223
1284
 
1224
1285
  it "should update record that has existing BLOB data with different BLOB data" do
@@ -1231,7 +1292,7 @@ describe "OracleEnhancedAdapter handling of BLOB columns" do
1231
1292
  @employee.binary_data = @binary_data2
1232
1293
  @employee.save!
1233
1294
  @employee.reload
1234
- @employee.binary_data.should == @binary_data2
1295
+ expect(@employee.binary_data).to eq(@binary_data2)
1235
1296
  end
1236
1297
 
1237
1298
  it "should update record that has existing BLOB data with nil" do
@@ -1244,7 +1305,7 @@ describe "OracleEnhancedAdapter handling of BLOB columns" do
1244
1305
  @employee.binary_data = nil
1245
1306
  @employee.save!
1246
1307
  @employee.reload
1247
- @employee.binary_data.should be_nil
1308
+ expect(@employee.binary_data).to be_nil
1248
1309
  end
1249
1310
 
1250
1311
  it "should update record that has existing BLOB data with zero-length BLOB data" do
@@ -1257,7 +1318,7 @@ describe "OracleEnhancedAdapter handling of BLOB columns" do
1257
1318
  @employee.binary_data = ''
1258
1319
  @employee.save!
1259
1320
  @employee.reload
1260
- @employee.binary_data.should == ''
1321
+ expect(@employee.binary_data).to eq('')
1261
1322
  end
1262
1323
 
1263
1324
  it "should update record that has zero-length BLOB data with non-empty BLOB data" do
@@ -1267,11 +1328,11 @@ describe "OracleEnhancedAdapter handling of BLOB columns" do
1267
1328
  :binary_data => ''
1268
1329
  )
1269
1330
  @employee.reload
1270
- @employee.binary_data.should == ''
1331
+ expect(@employee.binary_data).to eq('')
1271
1332
  @employee.binary_data = @binary_data
1272
1333
  @employee.save!
1273
1334
  @employee.reload
1274
- @employee.binary_data.should == @binary_data
1335
+ expect(@employee.binary_data).to eq(@binary_data)
1275
1336
  end
1276
1337
  end
1277
1338
 
@@ -1318,7 +1379,7 @@ describe "OracleEnhancedAdapter handling of RAW columns" do
1318
1379
  :binary_data => @binary_data
1319
1380
  )
1320
1381
  @employee.reload
1321
- @employee.binary_data.should == @binary_data
1382
+ expect(@employee.binary_data).to eq(@binary_data)
1322
1383
  end
1323
1384
 
1324
1385
  it "should update record with RAW data" do
@@ -1327,11 +1388,11 @@ describe "OracleEnhancedAdapter handling of RAW columns" do
1327
1388
  :last_name => "Last"
1328
1389
  )
1329
1390
  @employee.reload
1330
- @employee.binary_data.should be_nil
1391
+ expect(@employee.binary_data).to be_nil
1331
1392
  @employee.binary_data = @binary_data
1332
1393
  @employee.save!
1333
1394
  @employee.reload
1334
- @employee.binary_data.should == @binary_data
1395
+ expect(@employee.binary_data).to eq(@binary_data)
1335
1396
  end
1336
1397
 
1337
1398
  it "should update record with zero-length RAW data" do
@@ -1340,11 +1401,11 @@ describe "OracleEnhancedAdapter handling of RAW columns" do
1340
1401
  :last_name => "Last"
1341
1402
  )
1342
1403
  @employee.reload
1343
- @employee.binary_data.should be_nil
1404
+ expect(@employee.binary_data).to be_nil
1344
1405
  @employee.binary_data = ''
1345
1406
  @employee.save!
1346
1407
  @employee.reload
1347
- @employee.binary_data.should.nil?
1408
+ expect(@employee.binary_data).to be_nil
1348
1409
  end
1349
1410
 
1350
1411
  it "should update record that has existing RAW data with different RAW data" do
@@ -1357,7 +1418,7 @@ describe "OracleEnhancedAdapter handling of RAW columns" do
1357
1418
  @employee.binary_data = @binary_data2
1358
1419
  @employee.save!
1359
1420
  @employee.reload
1360
- @employee.binary_data.should == @binary_data2
1421
+ expect(@employee.binary_data).to eq(@binary_data2)
1361
1422
  end
1362
1423
 
1363
1424
  it "should update record that has existing RAW data with nil" do
@@ -1370,7 +1431,7 @@ describe "OracleEnhancedAdapter handling of RAW columns" do
1370
1431
  @employee.binary_data = nil
1371
1432
  @employee.save!
1372
1433
  @employee.reload
1373
- @employee.binary_data.should be_nil
1434
+ expect(@employee.binary_data).to be_nil
1374
1435
  end
1375
1436
 
1376
1437
  it "should update record that has existing RAW data with zero-length RAW data" do
@@ -1383,7 +1444,7 @@ describe "OracleEnhancedAdapter handling of RAW columns" do
1383
1444
  @employee.binary_data = ''
1384
1445
  @employee.save!
1385
1446
  @employee.reload
1386
- @employee.binary_data.should.nil?
1447
+ expect(@employee.binary_data).to be_nil
1387
1448
  end
1388
1449
 
1389
1450
  it "should update record that has zero-length BLOB data with non-empty RAW data" do
@@ -1396,7 +1457,7 @@ describe "OracleEnhancedAdapter handling of RAW columns" do
1396
1457
  @employee.binary_data = @binary_data
1397
1458
  @employee.save!
1398
1459
  @employee.reload
1399
- @employee.binary_data.should == @binary_data
1460
+ expect(@employee.binary_data).to eq(@binary_data)
1400
1461
  end
1401
1462
  end
1402
1463
 
@@ -1432,12 +1493,12 @@ describe "OracleEnhancedAdapter quoting of NCHAR and NVARCHAR2 columns" do
1432
1493
  ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
1433
1494
  end
1434
1495
 
1435
- it "should set nchar instance variable" do
1496
+ xit "should set nchar instance variable" do
1436
1497
  columns = @conn.columns('test_items')
1437
1498
  %w(nchar_column nvarchar2_column char_column varchar2_column).each do |col|
1438
1499
  column = columns.detect{|c| c.name == col}
1439
- column.type.should == :string
1440
- column.nchar.should == (col[0,1] == 'n' ? true : nil)
1500
+ expect(column.type).to eq(:string)
1501
+ expect(column.nchar).to eq(col[0,1] == 'n' ? true : nil)
1441
1502
  end
1442
1503
  end
1443
1504
 
@@ -1445,8 +1506,8 @@ describe "OracleEnhancedAdapter quoting of NCHAR and NVARCHAR2 columns" do
1445
1506
  columns = @conn.columns('test_items')
1446
1507
  %w(nchar_column nvarchar2_column char_column varchar2_column).each do |col|
1447
1508
  column = columns.detect{|c| c.name == col}
1448
- @conn.quote('abc', column).should == (column.nchar ? "N'abc'" : "'abc'")
1449
- @conn.quote(nil, column).should == 'NULL'
1509
+ expect(@conn.quote('abc', column)).to eq(column.sql_type[0,1] == 'N' ? "N'abc'" : "'abc'")
1510
+ expect(@conn.quote(nil, column)).to eq('NULL')
1450
1511
  end
1451
1512
  end
1452
1513
 
@@ -1456,8 +1517,8 @@ describe "OracleEnhancedAdapter quoting of NCHAR and NVARCHAR2 columns" do
1456
1517
  :nchar_column => nchar_data,
1457
1518
  :nvarchar2_column => nchar_data
1458
1519
  ).reload
1459
- item.nchar_column.should == nchar_data + ' '*17
1460
- item.nvarchar2_column.should == nchar_data
1520
+ expect(item.nchar_column).to eq(nchar_data + ' '*17)
1521
+ expect(item.nvarchar2_column).to eq(nchar_data)
1461
1522
  end
1462
1523
 
1463
1524
  end
@@ -1490,14 +1551,9 @@ describe "OracleEnhancedAdapter handling of BINARY_FLOAT columns" do
1490
1551
  CREATE SEQUENCE test2_employees_seq MINVALUE 1
1491
1552
  INCREMENT BY 1 START WITH 10040 CACHE 20 NOORDER NOCYCLE
1492
1553
  SQL
1493
-
1494
- class ::Test2Employee < ActiveRecord::Base
1495
- end
1496
1554
  end
1497
1555
 
1498
1556
  after(:all) do
1499
- Object.send(:remove_const, "Test2Employee")
1500
-
1501
1557
  @conn.execute "DROP TABLE test2_employees"
1502
1558
  @conn.execute "DROP SEQUENCE test2_employees_seq"
1503
1559
  end
@@ -1505,14 +1561,6 @@ describe "OracleEnhancedAdapter handling of BINARY_FLOAT columns" do
1505
1561
  it "should set BINARY_FLOAT column type as float" do
1506
1562
  columns = @conn.columns('test2_employees')
1507
1563
  column = columns.detect{|c| c.name == "hourly_rate"}
1508
- column.type.should == :float
1509
- end
1510
-
1511
- it "should BINARY_FLOAT column type returns an approximate value" do
1512
- employee = Test2Employee.create(hourly_rate: 4.4)
1513
-
1514
- employee.reload
1515
-
1516
- expect(employee.hourly_rate).to eq(4.400000095367432)
1564
+ expect(column.type).to eq(:float)
1517
1565
  end
1518
1566
  end