rsim-activerecord-oracle_enhanced-adapter 1.2.0 → 1.2.0.1

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.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == master development branch
2
+
3
+ * Bug fixes:
4
+ * return Date (and not DateTime) values for :date column value before year 1970
5
+
1
6
  == 1.2.0 2009-03-22
2
7
 
3
8
  * Enhancements
@@ -137,9 +137,9 @@ module ActiveRecord
137
137
  end
138
138
  end
139
139
 
140
- # RSI: convert Time value to Date for :date columns
140
+ # RSI: convert Time or DateTime value to Date for :date columns
141
141
  def self.string_to_date(string)
142
- return string.to_date if string.is_a?(Time)
142
+ return string.to_date if string.is_a?(Time) || string.is_a?(DateTime)
143
143
  super
144
144
  end
145
145
 
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{activerecord-oracle_enhanced-adapter}
5
- s.version = "1.2.0"
5
+ s.version = "1.2.0.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Raimonds Simanovskis"]
9
- s.date = %q{2009-03-22}
9
+ s.date = %q{2009-04-07}
10
10
  s.description = %q{Oracle enhanced adapter for ActiveRecord}
11
11
  s.email = ["raimonds.simanovskis@gmail.com"]
12
12
  s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "README.txt"]
@@ -74,6 +74,13 @@ describe "OracleEnhancedAdapter date type detection based on column names" do
74
74
  column.type_cast(Time.now).class.should == Date
75
75
  end
76
76
 
77
+ 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
78
+ ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
79
+ columns = @conn.columns('test_employees')
80
+ column = columns.detect{|c| c.name == "hire_date"}
81
+ column.type_cast(DateTime.new(1900,1,1)).class.should == Date
82
+ end
83
+
77
84
  describe "/ DATE values from ActiveRecord model" do
78
85
  before(:each) do
79
86
  ActiveRecord::Base.connection.clear_types_for_columns
@@ -85,9 +92,9 @@ describe "OracleEnhancedAdapter date type detection based on column names" do
85
92
  end
86
93
  end
87
94
 
88
- def create_test_employee
89
- @today = Date.new(2008,8,19)
90
- @now = Time.local(2008,8,19,17,03,59)
95
+ def create_test_employee(params={})
96
+ @today = params[:today] || Date.new(2008,8,19)
97
+ @now = params[:now] || Time.local(2008,8,19,17,03,59)
91
98
  @employee = TestEmployee.create(
92
99
  :first_name => "First",
93
100
  :last_name => "Last",
@@ -114,6 +121,12 @@ describe "OracleEnhancedAdapter date type detection based on column names" do
114
121
  @employee.hire_date.class.should == Date
115
122
  end
116
123
 
124
+ 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
125
+ ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
126
+ create_test_employee(:today => Date.new(1900,1,1))
127
+ @employee.hire_date.class.should == Date
128
+ end
129
+
117
130
  it "should return Time value from DATE column if column name does not contain 'date' and emulate_dates_by_column_name is true" do
118
131
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
119
132
  create_test_employee
@@ -129,6 +142,15 @@ describe "OracleEnhancedAdapter date type detection based on column names" do
129
142
  @employee.hire_date.class.should == Date
130
143
  end
131
144
 
145
+ 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
146
+ class ::TestEmployee < ActiveRecord::Base
147
+ set_date_columns :hire_date
148
+ end
149
+ ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
150
+ create_test_employee(:today => Date.new(1900,1,1))
151
+ @employee.hire_date.class.should == Date
152
+ end
153
+
132
154
  it "should return Time value from DATE column if emulate_dates_by_column_name is true but column is defined as datetime" do
133
155
  class ::TestEmployee < ActiveRecord::Base
134
156
  set_datetime_columns :hire_date
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsim-activerecord-oracle_enhanced-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raimonds Simanovskis
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-22 00:00:00 -07:00
12
+ date: 2009-04-07 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency