activerecord-oracle_enhanced-adapter 1.1.1 → 1.1.2

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.

Potentially problematic release.


This version of activerecord-oracle_enhanced-adapter might be problematic. Click here for more details.

data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ == 1.1.2 2008-07-08
2
+
3
+ * Bug fixes:
4
+ * Fixed after_save callback addition for session store in ActiveRecord version 2.0.2
5
+ * Changed date column name recognition - now should match regex /(^|_)date(_|$)/i
6
+ (previously "updated_at" was recognized as :date column and not as :datetime)
7
+
1
8
  == 1.1.1 2008-06-28
2
9
 
3
10
  * Enhancements:
@@ -160,14 +160,14 @@ begin
160
160
  @@emulate_dates_by_column_name = false
161
161
  cattr_accessor :emulate_dates_by_column_name
162
162
  def self.is_date_column?(name)
163
- name =~ /date/i
163
+ name =~ /(^|_)date(_|$)/i
164
164
  end
165
165
 
166
166
  # RSI: set to true if NUMBER columns with ID at the end of their name should be emulated as integers
167
167
  @@emulate_integers_by_column_name = false
168
168
  cattr_accessor :emulate_integers_by_column_name
169
169
  def self.is_integer_column?(name)
170
- name =~ /^id$/i || name =~ /_id$/i
170
+ name =~ /(^|_)id$/i
171
171
  end
172
172
 
173
173
  # RSI: set to true if CHAR(1), VARCHAR2(1) columns or VARCHAR2 columns with FLAG or YN at the end of their name
@@ -839,9 +839,11 @@ end
839
839
 
840
840
  # RSI: Added LOB writing callback for sessions stored in database
841
841
  # Otherwise it is not working as Session class is defined before OracleAdapter is loaded in Rails 2.0
842
- if defined?(CGI::Session::ActiveRecordStore::Session) &&
843
- CGI::Session::ActiveRecordStore::Session.after_save_callback_chain.detect{|cb| cb.method == :enhanced_write_lobs}.nil?
844
- class CGI::Session::ActiveRecordStore::Session
845
- after_save :enhanced_write_lobs
842
+ if defined?(CGI::Session::ActiveRecordStore::Session)
843
+ if !CGI::Session::ActiveRecordStore::Session.respond_to?(:after_save_callback_chain) ||
844
+ CGI::Session::ActiveRecordStore::Session.after_save_callback_chain.detect{|cb| cb.method == :enhanced_write_lobs}.nil?
845
+ class CGI::Session::ActiveRecordStore::Session
846
+ after_save :enhanced_write_lobs
847
+ end
846
848
  end
847
849
  end
@@ -3,7 +3,7 @@ module ActiveRecord #:nodoc:
3
3
  module OracleEnhancedVersion #:nodoc:
4
4
  MAJOR = 1
5
5
  MINOR = 1
6
- TINY = 1
6
+ TINY = 2
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY].join('.')
9
9
  end
@@ -105,6 +105,13 @@ describe "OracleEnhancedAdapter database session store" do
105
105
  CGI::Session::ActiveRecordStore::Session.after_save_callback_chain.select{|cb| cb.method == :enhanced_write_lobs}.should have(1).record
106
106
  end
107
107
 
108
+ it "should not set sessions table session_id column type as integer if emulate_integers_by_column_name is true" do
109
+ ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
110
+ columns = @conn.columns('sessions')
111
+ column = columns.detect{|c| c.name == "session_id"}
112
+ column.type.should == :string
113
+ end
114
+
108
115
  end
109
116
 
110
117
  describe "OracleEnhancedAdapter date type detection based on column names" do
@@ -127,7 +134,8 @@ describe "OracleEnhancedAdapter date type detection based on column names" do
127
134
  commission_pct NUMBER(2,2),
128
135
  manager_id NUMBER(6,0),
129
136
  department_id NUMBER(4,0),
130
- created_at DATE
137
+ created_at DATE,
138
+ updated_at DATE
131
139
  )
132
140
  SQL
133
141
  @conn.execute <<-SQL
@@ -148,20 +156,27 @@ describe "OracleEnhancedAdapter date type detection based on column names" do
148
156
  column.type.should == :datetime
149
157
  end
150
158
 
151
- it "should set DATE column type as date if column name contains 'date' and emulate_dates_by_column_name is true" do
159
+ it "should set DATE column type as date if column name contains '_date_' and emulate_dates_by_column_name is true" do
152
160
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
153
161
  columns = @conn.columns('test_employees')
154
162
  column = columns.detect{|c| c.name == "hire_date"}
155
163
  column.type.should == :date
156
164
  end
157
165
 
158
- it "should set DATE column type as datetime if column name does not contain 'date' and emulate_dates_by_column_name is true" do
166
+ it "should set DATE column type as datetime if column name does not contain '_date_' and emulate_dates_by_column_name is true" do
159
167
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
160
168
  columns = @conn.columns('test_employees')
161
169
  column = columns.detect{|c| c.name == "created_at"}
162
170
  column.type.should == :datetime
163
171
  end
164
172
 
173
+ 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
174
+ ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
175
+ columns = @conn.columns('test_employees')
176
+ column = columns.detect{|c| c.name == "updated_at"}
177
+ column.type.should == :datetime
178
+ end
179
+
165
180
  it "should return Time value from DATE column if emulate_dates_by_column_name is false" do
166
181
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
167
182
  columns = @conn.columns('test_employees')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-oracle_enhanced-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
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: 2008-06-28 00:00:00 +03:00
12
+ date: 2008-07-08 00:00:00 +03:00
13
13
  default_executable:
14
14
  dependencies: []
15
15