activerecord-oracle_enhanced-adapter 1.5.6 → 1.6.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/History.md +87 -0
  4. data/README.md +271 -174
  5. data/VERSION +1 -1
  6. data/activerecord-oracle_enhanced-adapter.gemspec +26 -22
  7. data/lib/active_record/connection_adapters/{oracle_enhanced_column.rb → oracle_enhanced/column.rb} +14 -63
  8. data/lib/active_record/connection_adapters/oracle_enhanced/column_dumper.rb +65 -0
  9. data/lib/active_record/connection_adapters/{oracle_enhanced_connection.rb → oracle_enhanced/connection.rb} +2 -2
  10. data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +347 -0
  11. data/lib/active_record/connection_adapters/{oracle_enhanced_cpk.rb → oracle_enhanced/cpk.rb} +0 -0
  12. data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +257 -0
  13. data/lib/active_record/connection_adapters/{oracle_enhanced_database_tasks.rb → oracle_enhanced/database_tasks.rb} +0 -0
  14. data/lib/active_record/connection_adapters/oracle_enhanced/dirty.rb +40 -0
  15. data/lib/active_record/connection_adapters/{oracle_enhanced_jdbc_connection.rb → oracle_enhanced/jdbc_connection.rb} +0 -0
  16. data/lib/active_record/connection_adapters/{oracle_enhanced_oci_connection.rb → oracle_enhanced/oci_connection.rb} +0 -0
  17. data/lib/active_record/connection_adapters/{oracle_enhanced_procedures.rb → oracle_enhanced/procedures.rb} +0 -0
  18. data/lib/active_record/connection_adapters/{oracle_enhanced_schema_creation.rb → oracle_enhanced/schema_creation.rb} +17 -16
  19. data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +92 -0
  20. data/lib/active_record/connection_adapters/{oracle_enhanced_schema_dumper.rb → oracle_enhanced/schema_dumper.rb} +4 -32
  21. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +543 -0
  22. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +65 -0
  23. data/lib/active_record/connection_adapters/{oracle_enhanced_structure_dump.rb → oracle_enhanced/structure_dump.rb} +26 -4
  24. data/lib/active_record/connection_adapters/oracle_enhanced/version.rb +1 -0
  25. data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +159 -66
  26. data/lib/active_record/oracle_enhanced/type/integer.rb +13 -0
  27. data/lib/active_record/oracle_enhanced/type/raw.rb +13 -0
  28. data/lib/active_record/oracle_enhanced/type/timestamp.rb +11 -0
  29. data/lib/activerecord-oracle_enhanced-adapter.rb +1 -1
  30. data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +6 -31
  31. data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +1 -1
  32. data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +2 -2
  33. data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +2 -2
  34. data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +63 -63
  35. data/spec/active_record/connection_adapters/oracle_enhanced_database_tasks_spec.rb +1 -1
  36. data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +7 -13
  37. data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +21 -175
  38. data/spec/spec_config.yaml.template +10 -0
  39. data/spec/spec_helper.rb +21 -10
  40. metadata +29 -25
  41. data/lib/active_record/connection_adapters/oracle_enhanced_column_dumper.rb +0 -77
  42. data/lib/active_record/connection_adapters/oracle_enhanced_context_index.rb +0 -350
  43. data/lib/active_record/connection_adapters/oracle_enhanced_database_statements.rb +0 -262
  44. data/lib/active_record/connection_adapters/oracle_enhanced_dirty.rb +0 -45
  45. data/lib/active_record/connection_adapters/oracle_enhanced_schema_definitions.rb +0 -197
  46. data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb +0 -450
  47. data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements_ext.rb +0 -258
  48. data/lib/active_record/connection_adapters/oracle_enhanced_version.rb +0 -1
@@ -0,0 +1,13 @@
1
+ module ActiveRecord
2
+ module OracleEnhanced
3
+ module Type
4
+ class Integer < ActiveRecord::Type::Integer # :nodoc:
5
+ private
6
+
7
+ def max_value
8
+ ("9"*38).to_i
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'active_record/type/string'
2
+
3
+ module ActiveRecord
4
+ module OracleEnhanced
5
+ module Type
6
+ class Raw < ActiveRecord::Type::String # :nodoc:
7
+ def type
8
+ :raw
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module ActiveRecord
2
+ module OracleEnhanced
3
+ module Type
4
+ class Timestamp < ActiveRecord::Type::Value # :nodoc:
5
+ def type
6
+ :timestamp
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -5,7 +5,7 @@ if defined?(::Rails::Railtie)
5
5
  module ConnectionAdapters
6
6
  class OracleEnhancedRailtie < ::Rails::Railtie
7
7
  rake_tasks do
8
- load 'active_record/connection_adapters/oracle_enhanced_database_tasks.rb'
8
+ load 'active_record/connection_adapters/oracle_enhanced/database_tasks.rb'
9
9
  end
10
10
 
11
11
  ActiveSupport.on_load(:active_record) do
@@ -476,7 +476,7 @@ describe "OracleEnhancedAdapter" do
476
476
  t.string :title
477
477
  # cannot update LOBs over database link
478
478
  t.string :body
479
- t.timestamps
479
+ t.timestamps null: true
480
480
  end
481
481
  @db_link_username = SYSTEM_CONNECTION_PARAMS[:username]
482
482
  @db_link_password = SYSTEM_CONNECTION_PARAMS[:password]
@@ -628,8 +628,8 @@ describe "OracleEnhancedAdapter" do
628
628
  end
629
629
 
630
630
  it "should clear older cursors when statement limit is reached" do
631
- pk = TestPost.columns.find { |c| c.primary }
632
- sub = @conn.substitute_at(pk, 0)
631
+ pk = TestPost.columns_hash[TestPost.primary_key]
632
+ sub = @conn.substitute_at(pk, 0).to_sql
633
633
  binds = [[pk, 1]]
634
634
 
635
635
  lambda {
@@ -641,8 +641,8 @@ describe "OracleEnhancedAdapter" do
641
641
 
642
642
  it "should cache UPDATE statements with bind variables" do
643
643
  lambda {
644
- pk = TestPost.columns.find { |c| c.primary }
645
- sub = @conn.substitute_at(pk, 0)
644
+ pk = TestPost.columns_hash[TestPost.primary_key]
645
+ sub = @conn.substitute_at(pk, 0).to_sql
646
646
  binds = [[pk, 1]]
647
647
  @conn.exec_update("UPDATE test_posts SET id = #{sub}", "SQL", binds)
648
648
  }.should change(@statements, :length).by(+1)
@@ -682,36 +682,11 @@ describe "OracleEnhancedAdapter" do
682
682
  end
683
683
 
684
684
  it "should explain query with binds" do
685
- pk = TestPost.columns.find { |c| c.primary }
685
+ pk = TestPost.columns_hash[TestPost.primary_key]
686
686
  sub = @conn.substitute_at(pk, 0)
687
687
  explain = TestPost.where(TestPost.arel_table[pk.name].eq(sub)).bind([pk, 1]).explain
688
688
  explain.should include("Cost")
689
689
  explain.should include("INDEX UNIQUE SCAN")
690
690
  end
691
691
  end if ENV['RAILS_GEM_VERSION'] >= '3.2'
692
-
693
- describe ".is_integer_column?" do
694
- before(:all) do
695
- @adapter = ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter
696
- end
697
-
698
- it "should return TrueClass or FalseClass" do
699
- @adapter.is_integer_column?("adapter_id").should be_a TrueClass
700
- @adapter.is_integer_column?("").should be_a FalseClass
701
- end
702
-
703
- it "should return true if name is 'id'" do
704
- @adapter.is_integer_column?("id").should be_true
705
- end
706
-
707
- it "should return true if name ends with '_id'" do
708
- @adapter.is_integer_column?("_id").should be_true
709
- @adapter.is_integer_column?("foo_id").should be_true
710
- end
711
-
712
- it "should return false if name is 'something_else'" do
713
- @adapter.is_integer_column?("something_else").should be_false
714
- end
715
- end
716
-
717
692
  end
@@ -227,7 +227,7 @@ describe "OracleEnhancedConnection" do
227
227
 
228
228
  it "should execute prepared statement with decimal bind parameter " do
229
229
  cursor = @conn.prepare("INSERT INTO test_employees VALUES(:1)")
230
- column = ActiveRecord::ConnectionAdapters::OracleEnhancedColumn.new('age', nil, 'NUMBER(10,2)')
230
+ column = ActiveRecord::ConnectionAdapters::OracleEnhancedColumn.new('age', nil, ActiveRecord::Type::Decimal.new, 'NUMBER(10,2)')
231
231
  column.type.should == :decimal
232
232
  cursor.bind_param(1, "1.5", column)
233
233
  cursor.exec
@@ -11,7 +11,7 @@ describe "OracleEnhancedAdapter context index" do
11
11
  t.string :title
12
12
  t.text :body
13
13
  t.integer :comments_count
14
- t.timestamps
14
+ t.timestamps null: true
15
15
  t.string :all_text, limit: 2 # will be used for multi-column index
16
16
  end
17
17
  end
@@ -23,7 +23,7 @@ describe "OracleEnhancedAdapter context index" do
23
23
  t.integer :post_id
24
24
  t.string :author
25
25
  t.text :body
26
- t.timestamps
26
+ t.timestamps null: true
27
27
  end
28
28
  end
29
29
  end
@@ -67,12 +67,12 @@ describe "OracleEnhancedAdapter composite_primary_keys support" do
67
67
  t.string :type_category, :limit => 15, :null => false
68
68
  t.date :date_value, :null => false
69
69
  t.text :results, :null => false
70
- t.timestamps
70
+ t.timestamps null: true
71
71
  end
72
72
  create_table :non_cpk_write_lobs_test, :force => true do |t|
73
73
  t.date :date_value, :null => false
74
74
  t.text :results, :null => false
75
- t.timestamps
75
+ t.timestamps null: true
76
76
  end
77
77
  end
78
78
  class ::CpkWriteLobsTest < ActiveRecord::Base
@@ -67,21 +67,21 @@ describe "OracleEnhancedAdapter date type detection based on column names" do
67
67
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
68
68
  columns = @conn.columns('test_employees')
69
69
  column = columns.detect{|c| c.name == "hire_date"}
70
- column.type_cast(Time.now).class.should == Time
70
+ column.type_cast_from_database(Time.now).class.should == Time
71
71
  end
72
72
 
73
73
  it "should return Date value from DATE column if column name contains 'date' and emulate_dates_by_column_name is true" do
74
74
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
75
75
  columns = @conn.columns('test_employees')
76
76
  column = columns.detect{|c| c.name == "hire_date"}
77
- column.type_cast(Time.now).class.should == Date
77
+ column.type_cast_from_database(Time.now).class.should == Date
78
78
  end
79
79
 
80
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
81
81
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
82
82
  columns = @conn.columns('test_employees')
83
83
  column = columns.detect{|c| c.name == "hire_date"}
84
- column.type_cast(DateTime.new(1900,1,1)).class.should == Date
84
+ column.type_cast_from_database(DateTime.new(1900,1,1)).class.should == Date
85
85
  end
86
86
 
87
87
  describe "/ DATE values from ActiveRecord model" do
@@ -206,7 +206,6 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
206
206
  job_id NUMBER,
207
207
  salary NUMBER,
208
208
  commission_pct NUMBER(2,2),
209
- unwise_name_id NUMBER(2,2),
210
209
  manager_id NUMBER(6),
211
210
  is_manager NUMBER(1),
212
211
  department_id NUMBER(4,0),
@@ -219,46 +218,17 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
219
218
  INCREMENT BY 1 START WITH 10040 CACHE 20 NOORDER NOCYCLE
220
219
  SQL
221
220
  end
222
-
221
+
223
222
  after(:all) do
224
223
  @conn.execute "DROP TABLE test2_employees"
225
224
  @conn.execute "DROP SEQUENCE test2_employees_seq"
226
225
  end
227
226
 
228
- context "when number_datatype_coercion is :decimal" do
229
- before { ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.stub(:number_datatype_coercion).and_return(:decimal) }
230
-
231
- it "should set NUMBER column type as decimal if emulate_integers_by_column_name is false" do
232
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = false
233
- columns = @conn.columns('test2_employees')
234
- column = columns.detect{|c| c.name == "job_id"}
235
- column.type.should == :decimal
236
- end
237
-
238
- it "should set NUMBER column type as decimal if column name is not 'id' and does not ends with '_id' and emulate_integers_by_column_name is true" do
239
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
240
- columns = @conn.columns('test2_employees')
241
- column = columns.detect{|c| c.name == "salary"}
242
- column.type.should == :decimal
243
- end
244
- end
245
-
246
- context "when number_datatype_coercion is :float" do
247
- before { ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.stub(:number_datatype_coercion).and_return(:float) }
248
-
249
- it "should set NUMBER column type as float if emulate_integers_by_column_name is false" do
250
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = false
251
- columns = @conn.columns('test2_employees')
252
- column = columns.detect{|c| c.name == "job_id"}
253
- column.type.should == :float
254
- end
255
-
256
- it "should set NUMBER column type as float if column name is not 'id' and does not ends with '_id' and emulate_integers_by_column_name is true" do
257
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
258
- columns = @conn.columns('test2_employees')
259
- column = columns.detect{|c| c.name == "salary"}
260
- column.type.should == :float
261
- end
227
+ it "should set NUMBER column type as decimal if emulate_integers_by_column_name is false" do
228
+ ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = false
229
+ columns = @conn.columns('test2_employees')
230
+ column = columns.detect{|c| c.name == "job_id"}
231
+ column.type.should == :decimal
262
232
  end
263
233
 
264
234
  it "should set NUMBER column type as integer if emulate_integers_by_column_name is true" do
@@ -270,24 +240,10 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
270
240
  column.type.should == :integer
271
241
  end
272
242
 
273
- it "should set NUMBER(p,0) column type as integer" do
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
274
244
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
275
245
  columns = @conn.columns('test2_employees')
276
- column = columns.detect{|c| c.name == "department_id"}
277
- column.type.should == :integer
278
- end
279
-
280
- it "should set NUMBER(p,s) column type as integer if column name ends with '_id' and emulate_integers_by_column_name is true" do
281
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
282
- columns = @conn.columns('test2_employees')
283
- column = columns.detect{|c| c.name == "unwise_name_id"}
284
- column.type.should == :integer
285
- end
286
-
287
- it "should set NUMBER(p,s) column type as decimal if column name ends with '_id' and emulate_integers_by_column_name is false" do
288
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = false
289
- columns = @conn.columns('test2_employees')
290
- column = columns.detect{|c| c.name == "unwise_name_id"}
246
+ column = columns.detect{|c| c.name == "salary"}
291
247
  column.type.should == :decimal
292
248
  end
293
249
 
@@ -295,14 +251,14 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
295
251
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = false
296
252
  columns = @conn.columns('test2_employees')
297
253
  column = columns.detect{|c| c.name == "job_id"}
298
- column.type_cast(1.0).class.should == BigDecimal
254
+ column.type_cast_from_database(1.0).class.should == BigDecimal
299
255
  end
300
256
 
301
- it "should return Fixnum value from NUMBER column if column name ends with '_id' and emulate_integers_by_column_name is true" do
257
+ it "should return Fixnum value from NUMBER column if column name contains 'id' and emulate_integers_by_column_name is true" do
302
258
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
303
259
  columns = @conn.columns('test2_employees')
304
260
  column = columns.detect{|c| c.name == "job_id"}
305
- column.type_cast(1.0).class.should == Fixnum
261
+ column.type_cast_from_database(1.0).class.should == Fixnum
306
262
  end
307
263
 
308
264
  describe "/ NUMBER values from ActiveRecord model" do
@@ -310,7 +266,7 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
310
266
  class ::Test2Employee < ActiveRecord::Base
311
267
  end
312
268
  end
313
-
269
+
314
270
  after(:each) do
315
271
  Object.send(:remove_const, "Test2Employee")
316
272
  @conn.clear_types_for_columns
@@ -452,7 +408,7 @@ describe "OracleEnhancedAdapter boolean type detection based on string column ty
452
408
  columns = @conn.columns('test3_employees')
453
409
  %w(has_email has_phone active_flag manager_yn).each do |col|
454
410
  column = columns.detect{|c| c.name == col}
455
- column.type_cast("Y").class.should == String
411
+ column.type_cast_from_database("Y").class.should == String
456
412
  end
457
413
  end
458
414
 
@@ -461,8 +417,8 @@ describe "OracleEnhancedAdapter boolean type detection based on string column ty
461
417
  columns = @conn.columns('test3_employees')
462
418
  %w(has_email has_phone active_flag manager_yn).each do |col|
463
419
  column = columns.detect{|c| c.name == col}
464
- column.type_cast("Y").class.should == TrueClass
465
- column.type_cast("N").class.should == FalseClass
420
+ column.type_cast_from_database("Y").class.should == TrueClass
421
+ column.type_cast_from_database("N").class.should == FalseClass
466
422
  end
467
423
  end
468
424
 
@@ -650,6 +606,7 @@ describe "OracleEnhancedAdapter timestamp with timezone support" do
650
606
 
651
607
  end
652
608
 
609
+
653
610
  describe "OracleEnhancedAdapter date and timestamp with different NLS date formats" do
654
611
  before(:all) do
655
612
  ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
@@ -906,7 +863,7 @@ describe "OracleEnhancedAdapter assign string to :date and :datetime columns" do
906
863
  @employee.reload
907
864
  @employee.last_login_at.should == @today.to_time
908
865
  end
909
-
866
+
910
867
  end
911
868
 
912
869
  describe "OracleEnhancedAdapter handling of CLOB columns" do
@@ -1383,6 +1340,7 @@ describe "OracleEnhancedAdapter handling of RAW columns" do
1383
1340
  end
1384
1341
  end
1385
1342
 
1343
+
1386
1344
  describe "OracleEnhancedAdapter quoting of NCHAR and NVARCHAR2 columns" do
1387
1345
  before(:all) do
1388
1346
  ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
@@ -1443,3 +1401,45 @@ describe "OracleEnhancedAdapter quoting of NCHAR and NVARCHAR2 columns" do
1443
1401
  end
1444
1402
 
1445
1403
  end
1404
+
1405
+ describe "OracleEnhancedAdapter handling of BINARY_FLOAT columns" do
1406
+ before(:all) do
1407
+ ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
1408
+ @conn = ActiveRecord::Base.connection
1409
+ @conn.execute "DROP TABLE test2_employees" rescue nil
1410
+ @conn.execute <<-SQL
1411
+ CREATE TABLE test2_employees (
1412
+ id NUMBER PRIMARY KEY,
1413
+ first_name VARCHAR2(20),
1414
+ last_name VARCHAR2(25),
1415
+ email VARCHAR2(25),
1416
+ phone_number VARCHAR2(20),
1417
+ hire_date DATE,
1418
+ job_id NUMBER,
1419
+ salary NUMBER,
1420
+ commission_pct NUMBER(2,2),
1421
+ hourly_rate BINARY_FLOAT,
1422
+ manager_id NUMBER(6),
1423
+ is_manager NUMBER(1),
1424
+ department_id NUMBER(4,0),
1425
+ created_at DATE
1426
+ )
1427
+ SQL
1428
+ @conn.execute "DROP SEQUENCE test2_employees_seq" rescue nil
1429
+ @conn.execute <<-SQL
1430
+ CREATE SEQUENCE test2_employees_seq MINVALUE 1
1431
+ INCREMENT BY 1 START WITH 10040 CACHE 20 NOORDER NOCYCLE
1432
+ SQL
1433
+ end
1434
+
1435
+ after(:all) do
1436
+ @conn.execute "DROP TABLE test2_employees"
1437
+ @conn.execute "DROP SEQUENCE test2_employees_seq"
1438
+ end
1439
+
1440
+ it "should set BINARY_FLOAT column type as float" do
1441
+ columns = @conn.columns('test2_employees')
1442
+ column = columns.detect{|c| c.name == "hourly_rate"}
1443
+ column.type.should == :float
1444
+ end
1445
+ end
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
- require 'active_record/connection_adapters/oracle_enhanced_database_tasks'
2
+ require 'active_record/connection_adapters/oracle_enhanced/database_tasks'
3
3
  require 'stringio'
4
4
  require 'tempfile'
5
5
 
@@ -16,7 +16,6 @@ if ActiveRecord::Base.method_defined?(:changed?)
16
16
  last_name VARCHAR2(25),
17
17
  job_id NUMBER(6,0) NULL,
18
18
  salary NUMBER(8,2),
19
- pto_per_hour NUMBER,
20
19
  comments CLOB,
21
20
  hire_date DATE
22
21
  )
@@ -28,7 +27,7 @@ if ActiveRecord::Base.method_defined?(:changed?)
28
27
  class TestEmployee < ActiveRecord::Base
29
28
  end
30
29
  end
31
-
30
+
32
31
  after(:all) do
33
32
  Object.send(:remove_const, "TestEmployee")
34
33
  @conn.execute "DROP TABLE test_employees"
@@ -63,16 +62,6 @@ if ActiveRecord::Base.method_defined?(:changed?)
63
62
  @employee.should_not be_changed
64
63
  end
65
64
 
66
- it "should not mark empty float (stored as NULL) as changed when reassigning it" do
67
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.stub(:number_datatype_coercion) { :float }
68
- @employee = TestEmployee.create!(:pto_per_hour => '')
69
- @employee.pto_per_hour = ''
70
- @employee.should_not be_changed
71
- @employee.reload
72
- @employee.pto_per_hour = ''
73
- @employee.should_not be_changed
74
- end
75
-
76
65
  it "should not mark empty text (stored as NULL) as changed when reassigning it" do
77
66
  @employee = TestEmployee.create!(:comments => nil)
78
67
  @employee.comments = nil
@@ -122,7 +111,7 @@ if ActiveRecord::Base.method_defined?(:changed?)
122
111
  @employee = TestEmployee.new
123
112
  @employee.job_id = 0
124
113
  @employee.save!.should be_true
125
-
114
+
126
115
  @employee.should_not be_changed
127
116
 
128
117
  @employee.job_id = '0'
@@ -147,6 +136,11 @@ if ActiveRecord::Base.method_defined?(:changed?)
147
136
  end
148
137
  end
149
138
 
139
+ it "should be able to handle attributes which are not backed by a column" do
140
+ TestEmployee.create!(:comments => "initial")
141
+ @employee = TestEmployee.select("#{TestEmployee.quoted_table_name}.*, 24 ranking").first
142
+ expect { @employee.ranking = 25 }.to_not raise_error
143
+ end
150
144
  end
151
145
 
152
146
  end