ruby-oci8 2.0.6-x86-mingw32 → 2.1.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -96,9 +96,9 @@ EOS
96
96
  cursor = @conn.parse("INSERT INTO test_table VALUES (:C, :V, :N, :D1, :D2, :D3, :D4, :INT, :BIGNUM)")
97
97
  1.upto(10) do |i|
98
98
  if i == 1
99
- dt = [nil, OraDate]
99
+ dt = [nil, OraDate]
100
100
  else
101
- dt = OraDate.new(2000 + i, 8, 3, 23, 59, 59)
101
+ dt = OraDate.new(2000 + i, i % 2 == 0 ? 7 : 1, 3, 23, 59, 59)
102
102
  end
103
103
  cursor.exec(format("%10d", i * 10), i.to_s, i, dt, dt, dt, dt, i * 11111111111, i * 10000000000)
104
104
  end
@@ -122,9 +122,10 @@ EOS
122
122
  assert_nil(rv[5])
123
123
  assert_nil(rv[6])
124
124
  else
125
- tm = Time.local(2000 + i, 8, 3, 23, 59, 59)
126
- dt = Date.civil(2000 + i, 8, 3)
127
- dttm = DateTime.civil(2000 + i, 8, 3, 23, 59, 59, Time.now.utc_offset.to_r/86400)
125
+ month = i % 2 == 0 ? 7 : 1
126
+ tm = Time.local(2000 + i, month, 3, 23, 59, 59)
127
+ dt = Date.civil(2000 + i, month, 3)
128
+ dttm = DateTime.civil(2000 + i, month, 3, 23, 59, 59, tm.utc_offset.to_r/86400)
128
129
  assert_equal(tm, rv[3])
129
130
  assert_equal(tm, rv[4])
130
131
  assert_equal(dt, rv[5])
@@ -148,9 +149,10 @@ EOS
148
149
  assert_nil(row['D3'])
149
150
  assert_nil(row['D4'])
150
151
  else
151
- tm = Time.local(2000 + i, 8, 3, 23, 59, 59)
152
- dt = Date.civil(2000 + i, 8, 3)
153
- dttm = DateTime.civil(2000 + i, 8, 3, 23, 59, 59, Time.now.utc_offset.to_r/86400)
152
+ month = i % 2 == 0 ? 7 : 1
153
+ tm = Time.local(2000 + i, month, 3, 23, 59, 59)
154
+ dt = Date.civil(2000 + i, month, 3)
155
+ dttm = DateTime.civil(2000 + i, month, 3, 23, 59, 59, tm.utc_offset.to_r/86400)
154
156
  assert_equal(tm, row['D1'])
155
157
  assert_equal(tm, row['D2'])
156
158
  assert_equal(dt, row['D3'])
@@ -431,4 +433,21 @@ EOS
431
433
  end
432
434
  end
433
435
 
436
+ def test_last_error
437
+ # OCI8#parse and OCI8#exec reset OCI8#last_error
438
+ @conn.last_error = 'dummy'
439
+ @conn.exec('begin null; end;')
440
+ assert_nil(@conn.last_error)
441
+ @conn.last_error = 'dummy'
442
+ cursor = @conn.parse('select col1, max(col2) from (select 1 as col1, null as col2 from dual) group by col1')
443
+ assert_nil(@conn.last_error)
444
+
445
+ # When an OCI function returns OCI_SUCCESS_WITH_INFO, OCI8#last_error is set.
446
+ @conn.last_error = 'dummy'
447
+ cursor.exec
448
+ assert_equal('dummy', @conn.last_error)
449
+ cursor.fetch
450
+ assert_kind_of(OCISuccessWithInfo, @conn.last_error)
451
+ assert_equal(24347, @conn.last_error.code)
452
+ end
434
453
  end # TestOCI8
@@ -743,4 +743,45 @@ EOS
743
743
  assert_equal(false, OraNumber(10.0).has_decimal_part?)
744
744
  assert_equal(true, OraNumber(10.1).has_decimal_part?)
745
745
  end
746
+
747
+ def test_float_conversion_type_ruby
748
+ orig = OCI8.properties[:float_conversion_type]
749
+ conn = get_oci8_connection
750
+ begin
751
+ OCI8.properties[:float_conversion_type] = :ruby
752
+ # Oracle Number -> Ruby Float
753
+ cursor = conn.parse('begin :out := :in; end;')
754
+ cursor.bind_param(:in, nil, String, 50)
755
+ cursor.bind_param(:out, nil, Float)
756
+ LARGE_RANGE_VALUES.each do |n|
757
+ cursor[:in] = n
758
+ cursor.exec
759
+ assert_equal(n.to_f, cursor[:out])
760
+ end
761
+ cursor.close
762
+ # Ruby Float -> Oracle Number
763
+ LARGE_RANGE_VALUES.each do |n|
764
+ float_val = n.to_f
765
+ expected_val = float_val.to_s
766
+ # convert
767
+ if /(-?)(\d).(\d+)e([+-]?\d+)/ =~ expected_val
768
+ sign = $1
769
+ int = $2
770
+ frac = $3
771
+ shift = $4.to_i
772
+ if frac.length <= shift
773
+ expected_val = sign + int + frac + '0' * (shift - frac.length)
774
+ elsif shift < 0
775
+ expected_val = sign + '0.' + '0' * (-shift - 1) + int + frac
776
+ expected_val.gsub!(/0+$/, '')
777
+ end
778
+ end
779
+ expected_val.gsub!(/\.0$/, '')
780
+ assert_equal(expected_val, OraNumber(float_val).to_s, "n = #{n}, float_val.to_s = #{float_val.to_s}")
781
+ end
782
+ ensure
783
+ OCI8.properties[:float_conversion_type] = orig
784
+ conn.logoff
785
+ end
786
+ end
746
787
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-oci8
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
+ - 1
8
9
  - 0
9
- - 6
10
- version: 2.0.6
10
+ version: 2.1.0
11
11
  platform: x86-mingw32
12
12
  authors:
13
13
  - KUBO Takehiro
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-14 00:00:00 +09:00
18
+ date: 2011-12-13 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -51,12 +51,14 @@ files:
51
51
  - lib/oci8/.document
52
52
  - lib/oci8/bindtype.rb
53
53
  - lib/oci8/compat.rb
54
+ - lib/oci8/connection_pool.rb
54
55
  - lib/oci8/datetime.rb
55
56
  - lib/oci8/encoding-init.rb
56
57
  - lib/oci8/encoding.yml
57
58
  - lib/oci8/metadata.rb
58
59
  - lib/oci8/object.rb
59
60
  - lib/oci8/oci8.rb
61
+ - lib/oci8/ocihandle.rb
60
62
  - lib/oci8/oracle_version.rb
61
63
  - lib/oci8/properties.rb
62
64
  - test/README
@@ -65,22 +67,25 @@ files:
65
67
  - test/test_appinfo.rb
66
68
  - test/test_array_dml.rb
67
69
  - test/test_bind_raw.rb
70
+ - test/test_bind_string.rb
68
71
  - test/test_bind_time.rb
69
72
  - test/test_break.rb
70
73
  - test/test_clob.rb
74
+ - test/test_connection_pool.rb
71
75
  - test/test_connstr.rb
72
76
  - test/test_encoding.rb
73
77
  - test/test_datetime.rb
74
78
  - test/test_dbi.rb
75
79
  - test/test_dbi_clob.rb
80
+ - test/test_error.rb
76
81
  - test/test_metadata.rb
77
82
  - test/test_oci8.rb
78
83
  - test/test_oracle_version.rb
79
84
  - test/test_oradate.rb
80
85
  - test/test_oranumber.rb
81
86
  - test/test_rowid.rb
82
- - lib/oci8lib_18.so
83
87
  - lib/oci8lib_191.so
88
+ - lib/oci8lib_18.so
84
89
  - lib/oci8.rb
85
90
  has_rdoc: true
86
91
  homepage: http://ruby-oci8.rubyforge.org