activerecord-oracle_enhanced-adapter 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.

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,9 @@
1
+ == 1.1.4 2008-07-14
2
+
3
+ * Enhancements:
4
+ * Date/Time quoting changes to support composite_primary_keys
5
+ * Added additional methods that are used by composite_primary_keys
6
+
1
7
  == 1.1.3 2008-07-10
2
8
 
3
9
  * Enhancements:
@@ -241,14 +241,17 @@ begin
241
241
  %Q{empty_#{ column.sql_type.downcase rescue 'blob' }()}
242
242
  # RSI: TIMESTAMP support
243
243
  when :timestamp
244
- # add up to 9 digits of fractional seconds to inserted time
245
- "TO_TIMESTAMP('#{value.to_s(:db)}.#{("%.9f"%value.to_f).split('.')[1]}','YYYY-MM-DD HH24:MI:SS:FF9')"
244
+ quote_timestamp_with_to_timestamp(value)
246
245
  # RSI: NLS_DATE_FORMAT independent DATE support
247
246
  when :date, :time, :datetime
248
- "TO_DATE('#{value.to_s(:db)}','YYYY-MM-DD HH24:MI:SS')"
247
+ quote_date_with_to_date(value)
249
248
  else
250
249
  super
251
250
  end
251
+ elsif value.acts_like?(:date)
252
+ quote_date_with_to_date(value)
253
+ elsif value.acts_like?(:time)
254
+ value.to_i == value.to_f ? quote_date_with_to_date(value) : quote_timestamp_with_to_timestamp(value)
252
255
  else
253
256
  super
254
257
  end
@@ -264,6 +267,17 @@ begin
264
267
  "0"
265
268
  end
266
269
 
270
+ # RSI: should support that composite_primary_keys gem will pass date as string
271
+ def quote_date_with_to_date(value)
272
+ value = value.to_s(:db) if value.acts_like?(:date) || value.acts_like?(:time)
273
+ "TO_DATE('#{value}','YYYY-MM-DD HH24:MI:SS')"
274
+ end
275
+
276
+ def quote_timestamp_with_to_timestamp(value)
277
+ # add up to 9 digits of fractional seconds to inserted time
278
+ value = "#{value.to_s(:db)}.#{("%.6f"%value.to_f).split('.')[1]}" if value.acts_like?(:time)
279
+ "TO_TIMESTAMP('#{value}','YYYY-MM-DD HH24:MI:SS.FF6')"
280
+ end
267
281
 
268
282
  # CONNECTION MANAGEMENT ====================================
269
283
  #
@@ -858,3 +872,6 @@ rescue LoadError
858
872
  "Custom create, update and delete methods will not be available."
859
873
  end
860
874
  end
875
+
876
+ # RSI: load additional methods for composite_primary_keys support
877
+ require 'active_record/connection_adapters/oracle_enhanced_cpk'
@@ -0,0 +1,20 @@
1
+ module ActiveRecord #:nodoc:
2
+ module ConnectionAdapters #:nodoc:
3
+ module OracleEnhancedCpk #:nodoc:
4
+
5
+ # This mightn't be in Core, but count(distinct x,y) doesn't work for me
6
+ def supports_count_distinct? #:nodoc:
7
+ false
8
+ end
9
+
10
+ def concat(*columns)
11
+ "(#{columns.join('||')})"
12
+ end
13
+
14
+ end
15
+ end
16
+ end
17
+
18
+ ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.class_eval do
19
+ include ActiveRecord::ConnectionAdapters::OracleEnhancedCpk
20
+ end
@@ -3,7 +3,7 @@ module ActiveRecord #:nodoc:
3
3
  module OracleEnhancedVersion #:nodoc:
4
4
  MAJOR = 1
5
5
  MINOR = 1
6
- TINY = 3
6
+ TINY = 4
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY].join('.')
9
9
  end
@@ -716,4 +716,19 @@ describe "OracleEnhancedAdapter date and timestamp with different NLS date forma
716
716
  @employee.created_at_ts.should == @now
717
717
  end
718
718
 
719
+ it "should quote Date values with TO_DATE" do
720
+ @conn.quote(@today).should == "TO_DATE('#{@today.year}-#{"%02d" % @today.month}-#{"%02d" % @today.day}','YYYY-MM-DD HH24:MI:SS')"
721
+ end
722
+
723
+ it "should quote Time values with TO_DATE" do
724
+ @conn.quote(@now).should == "TO_DATE('#{@now.year}-#{"%02d" % @now.month}-#{"%02d" % @now.day} "+
725
+ "#{"%02d" % @now.hour}:#{"%02d" % @now.min}:#{"%02d" % @now.sec}','YYYY-MM-DD HH24:MI:SS')"
726
+ end
727
+
728
+ it "should quote Time values with TO_TIMESTAMP" do
729
+ @ts = Time.at(@now.to_f + 0.1)
730
+ @conn.quote(@ts).should == "TO_TIMESTAMP('#{@ts.year}-#{"%02d" % @ts.month}-#{"%02d" % @ts.day} "+
731
+ "#{"%02d" % @ts.hour}:#{"%02d" % @ts.min}:#{"%02d" % @ts.sec}.100000','YYYY-MM-DD HH24:MI:SS.FF6')"
732
+ end
733
+
719
734
  end
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+ require "composite_primary_keys"
3
+
4
+ describe "OracleEnhancedAdapter composite_primary_keys support" do
5
+
6
+ # Currently testing was done based on composite_primary_keys tests
7
+
8
+ end
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.3
4
+ version: 1.1.4
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-07-10 00:00:00 +03:00
12
+ date: 2008-07-15 00:00:00 +03:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -30,10 +30,12 @@ files:
30
30
  - README.txt
31
31
  - lib/active_record/connection_adapters/oracle_enhanced.rake
32
32
  - lib/active_record/connection_adapters/oracle_enhanced_adapter.rb
33
+ - lib/active_record/connection_adapters/oracle_enhanced_cpk.rb
33
34
  - lib/active_record/connection_adapters/oracle_enhanced_procedures.rb
34
35
  - lib/active_record/connection_adapters/oracle_enhanced_tasks.rb
35
36
  - lib/active_record/connection_adapters/oracle_enhanced_version.rb
36
37
  - spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb
38
+ - spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb
37
39
  - spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb
38
40
  - spec/spec.opts
39
41
  - spec/spec_helper.rb