pmacs-activerecord-oracle_enhanced-adapter 1.5.6.1 → 1.6.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -7
  3. data/History.md +126 -0
  4. data/README.md +285 -178
  5. data/Rakefile +1 -1
  6. data/VERSION +1 -1
  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} +1 -3
  18. data/lib/active_record/connection_adapters/{oracle_enhanced_schema_creation.rb → oracle_enhanced/schema_creation.rb} +34 -35
  19. data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +95 -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 +548 -0
  22. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +74 -0
  23. data/lib/active_record/connection_adapters/{oracle_enhanced_structure_dump.rb → oracle_enhanced/structure_dump.rb} +28 -6
  24. data/lib/active_record/connection_adapters/oracle_enhanced/version.rb +1 -0
  25. data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +161 -68
  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/pmacs-activerecord-oracle_enhanced-adapter.rb +1 -1
  30. data/pmacs-activerecord-oracle_enhanced-adapter.gemspec +35 -31
  31. data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +6 -31
  32. data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +1 -1
  33. data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +2 -2
  34. data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +2 -2
  35. data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +75 -63
  36. data/spec/active_record/connection_adapters/oracle_enhanced_database_tasks_spec.rb +1 -1
  37. data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +7 -13
  38. data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +2 -1
  39. data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +25 -178
  40. data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +60 -5
  41. data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +1 -0
  42. data/spec/spec_helper.rb +21 -10
  43. metadata +32 -28
  44. data/lib/active_record/connection_adapters/oracle_enhanced_column_dumper.rb +0 -77
  45. data/lib/active_record/connection_adapters/oracle_enhanced_context_index.rb +0 -350
  46. data/lib/active_record/connection_adapters/oracle_enhanced_database_statements.rb +0 -262
  47. data/lib/active_record/connection_adapters/oracle_enhanced_dirty.rb +0 -45
  48. data/lib/active_record/connection_adapters/oracle_enhanced_schema_definitions.rb +0 -223
  49. data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb +0 -450
  50. data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements_ext.rb +0 -267
  51. 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
@@ -5,11 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pmacs-activerecord-oracle_enhanced-adapter}
8
- s.version = "1.5.6.1"
8
+ s.version = "1.6.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.license = 'MIT'
11
12
  s.authors = [%q{Charles Treatman}, %q{Raimonds Simanovskis}]
12
- s.date = %q{2015-06-30}
13
+ s.date = %q{2015-08-12}
13
14
  s.description = %q{Oracle "enhanced" ActiveRecord adapter contains useful additional methods for working with new and legacy Oracle databases.
14
15
  This adapter is superset of original ActiveRecord Oracle adapter.
15
16
  }
@@ -26,28 +27,31 @@ This adapter is superset of original ActiveRecord Oracle adapter.
26
27
  "RUNNING_TESTS.md",
27
28
  "Rakefile",
28
29
  "VERSION",
30
+ "pmacs-activerecord-oracle_enhanced-adapter.gemspec",
29
31
  "lib/active_record/connection_adapters/emulation/oracle_adapter.rb",
30
32
  "lib/active_record/connection_adapters/oracle_enhanced_adapter.rb",
31
- "lib/active_record/connection_adapters/oracle_enhanced_column.rb",
32
- "lib/active_record/connection_adapters/oracle_enhanced_column_dumper.rb",
33
- "lib/active_record/connection_adapters/oracle_enhanced_connection.rb",
34
- "lib/active_record/connection_adapters/oracle_enhanced_context_index.rb",
35
- "lib/active_record/connection_adapters/oracle_enhanced_cpk.rb",
36
- "lib/active_record/connection_adapters/oracle_enhanced_database_statements.rb",
37
- "lib/active_record/connection_adapters/oracle_enhanced_database_tasks.rb",
38
- "lib/active_record/connection_adapters/oracle_enhanced_dirty.rb",
39
- "lib/active_record/connection_adapters/oracle_enhanced_jdbc_connection.rb",
40
- "lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb",
41
- "lib/active_record/connection_adapters/oracle_enhanced_procedures.rb",
42
- "lib/active_record/connection_adapters/oracle_enhanced_schema_creation.rb",
43
- "lib/active_record/connection_adapters/oracle_enhanced_schema_definitions.rb",
44
- "lib/active_record/connection_adapters/oracle_enhanced_schema_dumper.rb",
45
- "lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb",
46
- "lib/active_record/connection_adapters/oracle_enhanced_schema_statements_ext.rb",
47
- "lib/active_record/connection_adapters/oracle_enhanced_structure_dump.rb",
48
- "lib/active_record/connection_adapters/oracle_enhanced_version.rb",
33
+ "lib/active_record/connection_adapters/oracle_enhanced/column.rb",
34
+ "lib/active_record/connection_adapters/oracle_enhanced/column_dumper.rb",
35
+ "lib/active_record/connection_adapters/oracle_enhanced/connection.rb",
36
+ "lib/active_record/connection_adapters/oracle_enhanced/context_index.rb",
37
+ "lib/active_record/connection_adapters/oracle_enhanced/cpk.rb",
38
+ "lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb",
39
+ "lib/active_record/connection_adapters/oracle_enhanced/dirty.rb",
40
+ "lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb",
41
+ "lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb",
42
+ "lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb",
43
+ "lib/active_record/connection_adapters/oracle_enhanced/procedures.rb",
44
+ "lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb",
45
+ "lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb",
46
+ "lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb",
47
+ "lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb",
48
+ "lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb",
49
+ "lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb",
50
+ "lib/active_record/connection_adapters/oracle_enhanced/version.rb",
51
+ "lib/active_record/oracle_enhanced/type/integer.rb",
52
+ "lib/active_record/oracle_enhanced/type/timestamp.rb",
53
+ "lib/active_record/oracle_enhanced/type/raw.rb",
49
54
  "lib/pmacs-activerecord-oracle_enhanced-adapter.rb",
50
- "pmacs-activerecord-oracle_enhanced-adapter.gemspec",
51
55
  "spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb",
52
56
  "spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb",
53
57
  "spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb",
@@ -63,10 +67,10 @@ This adapter is superset of original ActiveRecord Oracle adapter.
63
67
  "spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb",
64
68
  "spec/spec_helper.rb"
65
69
  ]
66
- s.homepage = "http://github.com/pmacs/oracle-enhanced"
67
- s.require_paths = ["lib"]
68
- s.rubygems_version = "1.8.21"
69
- s.summary = "Oracle enhanced adapter for ActiveRecord"
70
+ s.homepage = %q{http://github.com/pmacs/oracle-enhanced}
71
+ s.require_paths = [%q{lib}]
72
+ s.rubygems_version = %q{2.2.2}
73
+ s.summary = %q{Oracle enhanced adapter for ActiveRecord}
70
74
  s.test_files = [
71
75
  "spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb",
72
76
  "spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb",
@@ -88,10 +92,10 @@ This adapter is superset of original ActiveRecord Oracle adapter.
88
92
  s.specification_version = 3
89
93
 
90
94
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
91
- s.add_development_dependency(%q<jeweler>, ["~> 1.8"])
95
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
92
96
  s.add_development_dependency(%q<rspec>, ["~> 2.4"])
93
97
  s.add_development_dependency(%q<rdoc>, [">= 0"])
94
- s.add_development_dependency(%q<activerecord>, [">= 0"])
98
+ s.add_development_dependency(%q<activerecord>, ["~> 4.2.1"])
95
99
  s.add_development_dependency(%q<activemodel>, [">= 0"])
96
100
  s.add_development_dependency(%q<activesupport>, [">= 0"])
97
101
  s.add_development_dependency(%q<actionpack>, [">= 0"])
@@ -101,10 +105,10 @@ This adapter is superset of original ActiveRecord Oracle adapter.
101
105
  s.add_development_dependency(%q<ruby-plsql>, [">= 0.4.4"])
102
106
  s.add_development_dependency(%q<ruby-oci8>, [">= 2.0.4"])
103
107
  else
104
- s.add_dependency(%q<jeweler>, ["~> 1.8"])
108
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
105
109
  s.add_dependency(%q<rspec>, ["~> 2.4"])
106
110
  s.add_dependency(%q<rdoc>, [">= 0"])
107
- s.add_dependency(%q<activerecord>, [">= 0"])
111
+ s.add_dependency(%q<activerecord>, ["~> 4.2.1"])
108
112
  s.add_dependency(%q<activemodel>, [">= 0"])
109
113
  s.add_dependency(%q<activesupport>, [">= 0"])
110
114
  s.add_dependency(%q<actionpack>, [">= 0"])
@@ -115,10 +119,10 @@ This adapter is superset of original ActiveRecord Oracle adapter.
115
119
  s.add_dependency(%q<ruby-oci8>, [">= 2.0.4"])
116
120
  end
117
121
  else
118
- s.add_dependency(%q<jeweler>, ["~> 1.8"])
122
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
119
123
  s.add_dependency(%q<rspec>, ["~> 2.4"])
120
124
  s.add_dependency(%q<rdoc>, [">= 0"])
121
- s.add_dependency(%q<activerecord>, [">= 0"])
125
+ s.add_dependency(%q<activerecord>, ["~> 4.2.1"])
122
126
  s.add_dependency(%q<activemodel>, [">= 0"])
123
127
  s.add_dependency(%q<activesupport>, [">= 0"])
124
128
  s.add_dependency(%q<actionpack>, [">= 0"])
@@ -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
@@ -1130,6 +1087,18 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
1130
1087
  @employee.reload
1131
1088
  @employee.comments.should == "initial serialized data"
1132
1089
  end
1090
+
1091
+ it "should keep serialized data after save" do
1092
+ @employee = Test2Employee.new
1093
+ @employee.comments = {:length=>{:is=>1}}
1094
+ @employee.save
1095
+ @employee.reload
1096
+ @employee.comments.should == {:length=>{:is=>1}}
1097
+ @employee.comments = {:length=>{:is=>2}}
1098
+ @employee.save
1099
+ @employee.reload
1100
+ @employee.comments.should == {:length=>{:is=>2}}
1101
+ end
1133
1102
  end
1134
1103
 
1135
1104
  describe "OracleEnhancedAdapter handling of BLOB columns" do
@@ -1383,6 +1352,7 @@ describe "OracleEnhancedAdapter handling of RAW columns" do
1383
1352
  end
1384
1353
  end
1385
1354
 
1355
+
1386
1356
  describe "OracleEnhancedAdapter quoting of NCHAR and NVARCHAR2 columns" do
1387
1357
  before(:all) do
1388
1358
  ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
@@ -1443,3 +1413,45 @@ describe "OracleEnhancedAdapter quoting of NCHAR and NVARCHAR2 columns" do
1443
1413
  end
1444
1414
 
1445
1415
  end
1416
+
1417
+ describe "OracleEnhancedAdapter handling of BINARY_FLOAT columns" do
1418
+ before(:all) do
1419
+ ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
1420
+ @conn = ActiveRecord::Base.connection
1421
+ @conn.execute "DROP TABLE test2_employees" rescue nil
1422
+ @conn.execute <<-SQL
1423
+ CREATE TABLE test2_employees (
1424
+ id NUMBER PRIMARY KEY,
1425
+ first_name VARCHAR2(20),
1426
+ last_name VARCHAR2(25),
1427
+ email VARCHAR2(25),
1428
+ phone_number VARCHAR2(20),
1429
+ hire_date DATE,
1430
+ job_id NUMBER,
1431
+ salary NUMBER,
1432
+ commission_pct NUMBER(2,2),
1433
+ hourly_rate BINARY_FLOAT,
1434
+ manager_id NUMBER(6),
1435
+ is_manager NUMBER(1),
1436
+ department_id NUMBER(4,0),
1437
+ created_at DATE
1438
+ )
1439
+ SQL
1440
+ @conn.execute "DROP SEQUENCE test2_employees_seq" rescue nil
1441
+ @conn.execute <<-SQL
1442
+ CREATE SEQUENCE test2_employees_seq MINVALUE 1
1443
+ INCREMENT BY 1 START WITH 10040 CACHE 20 NOORDER NOCYCLE
1444
+ SQL
1445
+ end
1446
+
1447
+ after(:all) do
1448
+ @conn.execute "DROP TABLE test2_employees"
1449
+ @conn.execute "DROP SEQUENCE test2_employees_seq"
1450
+ end
1451
+
1452
+ it "should set BINARY_FLOAT column type as float" do
1453
+ columns = @conn.columns('test2_employees')
1454
+ column = columns.detect{|c| c.name == "hourly_rate"}
1455
+ column.type.should == :float
1456
+ end
1457
+ end