ruby-oci8 2.1.5-x86-mingw32 → 2.1.7-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -71,6 +71,29 @@ EOS
71
71
  OCI8::TDO.new(self, metadata, klass)
72
72
  end
73
73
 
74
+ # Returns the type descriptor object which correspond to the given type name.
75
+ #
76
+ # @param [String] typename
77
+ # @return [OCI8::TDO]
78
+ #
79
+ # @private
80
+ def get_tdo_by_typename(typename)
81
+ tdo = @name_to_tdo && @name_to_tdo[typename]
82
+ return tdo if tdo
83
+
84
+ metadata = describe_any(typename)
85
+ if metadata.is_a? OCI8::Metadata::Synonym
86
+ metadata = describe_any(metadata.translated_name)
87
+ end
88
+ unless metadata.is_a? OCI8::Metadata::Type
89
+ raise "unknown typename #{typename}"
90
+ end
91
+ tdo = get_tdo_by_metadata(metadata)
92
+
93
+ @name_to_tdo[typename] = tdo
94
+ tdo
95
+ end
96
+
74
97
  # A helper class to bind arguments.
75
98
  #
76
99
  # @private
Binary file
Binary file
Binary file
Binary file
@@ -19,7 +19,7 @@ spec = Gem::Specification.new do |s|
19
19
  s.version = File.read('VERSION').strip
20
20
  s.summary = 'Ruby interface for Oracle using OCI8 API'
21
21
  s.email = 'kubo@jiubao.org'
22
- s.homepage = 'http://ruby-oci8.rubyforge.org'
22
+ s.homepage = 'https://github.com/kubo/ruby-oci8/'
23
23
  s.rubyforge_project = 'ruby-oci8'
24
24
  s.description = <<EOS
25
25
  ruby-oci8 is a ruby interface for Oracle using OCI8 API. It is available with Oracle8i, Oracle9i, Oracle10g, Oracle11g and Oracle Instant Client.
@@ -57,7 +57,7 @@ EOS
57
57
  if so_vers[0] < '2.0.0'
58
58
  s.required_ruby_version = "~> #{so_vermin}"
59
59
  else
60
- s.required_ruby_version = "= #{so_vermin}"
60
+ s.required_ruby_version = "~> #{so_vermin}.0"
61
61
  end
62
62
  else
63
63
  puts "Binary gem for ruby #{so_vers.join(', ')}"
@@ -18,6 +18,21 @@ $lobreadnum = 256 # counts in charactors
18
18
 
19
19
  # don't modify below.
20
20
 
21
+ begin
22
+ require 'minitest/autorun'
23
+ Minitest = MiniTest unless defined? Minitest
24
+ Minitest::Test = Minitest::Unit::TestCase unless defined? Minitest::Test
25
+ rescue LoadError
26
+ require 'test/unit'
27
+ module Minitest
28
+ Test = ::Test::Unit::TestCase
29
+ Assertions = ::Test::Unit::Assertions
30
+ module Assertions
31
+ alias refute_nil assert_not_nil
32
+ end
33
+ end
34
+ end
35
+
21
36
  # $oracle_server_version: database compatible level of the Oracle server.
22
37
  # $oracle_client_version: Oracle client library version for which oci8 is compiled.
23
38
  # $oracle_version: lower value of $oracle_server_version and $oracle_client_version.
@@ -108,77 +123,72 @@ def convert_to_datetime(year, month, day, hour, minute, sec, subsec, timezone)
108
123
  end
109
124
  end
110
125
 
111
- module Test
112
- module Unit
113
- class TestCase
126
+ class Minitest::Test
114
127
 
115
- def get_oci8_connection()
116
- OCI8.new($dbuser, $dbpass, $dbname)
128
+ def get_oci8_connection()
129
+ OCI8.new($dbuser, $dbpass, $dbname)
117
130
  rescue OCIError
118
- raise if $!.code != 12516 && $!.code != 12520
119
- # sleep a few second and try again if
120
- # the error code is ORA-12516 or ORA-12520.
121
- #
122
- # ORA-12516 - TNS:listener could not find available handler with
123
- # matching protocol stack
124
- # ORA-12520 - TNS:listener could not find available handler for
125
- # requested type of server
126
- #
127
- # Thanks to Christopher Jones.
128
- #
129
- # Ref: The Underground PHP and Oracle Manual (page 175 in vesion 1.4)
130
- # http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf
131
- #
132
- sleep(5)
133
- OCI8.new($dbuser, $dbpass, $dbname)
134
- end
131
+ raise if $!.code != 12516 && $!.code != 12520
132
+ # sleep a few second and try again if
133
+ # the error code is ORA-12516 or ORA-12520.
134
+ #
135
+ # ORA-12516 - TNS:listener could not find available handler with
136
+ # matching protocol stack
137
+ # ORA-12520 - TNS:listener could not find available handler for
138
+ # requested type of server
139
+ #
140
+ # Thanks to Christopher Jones.
141
+ #
142
+ # Ref: The Underground PHP and Oracle Manual (page 175 in vesion 1.4)
143
+ # http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf
144
+ #
145
+ sleep(5)
146
+ OCI8.new($dbuser, $dbpass, $dbname)
147
+ end
148
+
149
+ def get_dbi_connection()
150
+ DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
151
+ rescue DBI::DatabaseError
152
+ raise if $!.err != 12516 && $!.err != 12520
153
+ # same as get_oci8_connection()
154
+ sleep(5)
155
+ DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
156
+ end
135
157
 
136
- def get_dbi_connection()
137
- DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
158
+ def drop_table(table_name)
159
+ if $oracle_server_version < OCI8::ORAVER_10_1
160
+ # Oracle 8 - 9i
161
+ sql = "DROP TABLE #{table_name}"
162
+ else
163
+ # Oracle 10g -
164
+ sql = "DROP TABLE #{table_name} PURGE"
165
+ end
166
+
167
+ if defined? @conn
168
+ begin
169
+ @conn.exec(sql)
170
+ rescue OCIError
171
+ raise if $!.code != 942 # table or view does not exist
172
+ end
173
+ elsif instance_variable_get(:@dbh)
174
+ begin
175
+ @dbh.do(sql)
138
176
  rescue DBI::DatabaseError
139
- raise if $!.err != 12516 && $!.err != 12520
140
- # same as get_oci8_connection()
141
- sleep(5)
142
- DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
177
+ raise if $!.err != 942 # table or view does not exist
143
178
  end
179
+ end
180
+ end # drop_table
144
181
 
145
- def drop_table(table_name)
146
- if $oracle_server_version < OCI8::ORAVER_10_1
147
- # Oracle 8 - 9i
148
- sql = "DROP TABLE #{table_name}"
149
- else
150
- # Oracle 10g -
151
- sql = "DROP TABLE #{table_name} PURGE"
152
- end
153
-
154
- if defined? @conn
155
- begin
156
- @conn.exec(sql)
157
- rescue OCIError
158
- raise if $!.code != 942 # table or view does not exist
159
- end
160
- elsif instance_variable_get(:@dbh)
161
- begin
162
- @dbh.do(sql)
163
- rescue DBI::DatabaseError
164
- raise if $!.err != 942 # table or view does not exist
165
- end
166
- end
167
- end # drop_table
168
-
169
- def drop_type(type_name)
170
- begin
171
- @conn.exec("DROP TYPE BODY #{type_name}")
172
- rescue OCIError
173
- raise if $!.code != 4043
174
- end
175
- begin
176
- @conn.exec("DROP TYPE #{type_name}")
177
- rescue OCIError
178
- raise if $!.code != 4043
179
- end
180
- end # drop_type
182
+ def drop_type(type_name)
183
+ begin
184
+ @conn.exec("DROP TYPE BODY #{type_name}")
185
+ rescue OCIError
186
+ raise if $!.code != 4043
181
187
  end
182
- end
188
+ begin
189
+ @conn.exec("DROP TYPE #{type_name}")
190
+ rescue OCIError
191
+ raise if $!.code != 4043
192
+ end
193
+ end # drop_type
183
194
  end
184
-
@@ -1,7 +1,6 @@
1
1
  srcdir = File.dirname(__FILE__)
2
2
 
3
3
  require 'oci8'
4
- require 'test/unit'
5
4
  require "#{srcdir}/config"
6
5
 
7
6
  require "#{srcdir}/test_oradate"
@@ -30,6 +29,10 @@ if OCI8.respond_to? :encoding
30
29
  require "#{srcdir}/test_encoding"
31
30
  end
32
31
 
32
+ if $oracle_version >= OCI8::ORAVER_12_1
33
+ require "#{srcdir}/test_package_type"
34
+ end
35
+
33
36
  # Ruby/DBI
34
37
  begin
35
38
  require 'dbi'
@@ -47,8 +50,3 @@ unless dbi_not_found
47
50
  require "#{srcdir}/test_dbi_clob"
48
51
  end
49
52
  end
50
-
51
- #Test::Unit::AutoRunner.run(true, true)
52
- if defined? Test::Unit::AutoRunner
53
- Test::Unit::AutoRunner.run()
54
- end
@@ -1,8 +1,7 @@
1
1
  require 'oci8'
2
- require 'test/unit'
3
2
  require File.dirname(__FILE__) + '/config'
4
3
 
5
- class TestAppInfo < Test::Unit::TestCase
4
+ class TestAppInfo < Minitest::Test
6
5
 
7
6
  def setup
8
7
  @conn = get_oci8_connection
@@ -14,7 +13,7 @@ class TestAppInfo < Test::Unit::TestCase
14
13
  @conn.client_identifier = client_id
15
14
  assert_equal(client_id, @conn.select_one("SELECT SYS_CONTEXT('USERENV', 'CLIENT_IDENTIFIER') FROM DUAL")[0]);
16
15
  # check the first character
17
- assert_raise ArgumentError do
16
+ assert_raises ArgumentError do
18
17
  @conn.client_identifier = ':bad_identifier'
19
18
  end
20
19
 
@@ -1,8 +1,7 @@
1
1
  require 'oci8'
2
- require 'test/unit'
3
2
  require File.dirname(__FILE__) + '/config'
4
3
 
5
- class TestArrayDML < Test::Unit::TestCase
4
+ class TestArrayDML < Minitest::Test
6
5
  def setup
7
6
  @conn = get_oci8_connection
8
7
  end
@@ -131,7 +130,7 @@ EOS
131
130
  v_arr << i.to_s if i != max_array_size
132
131
  end
133
132
  cursor[1] = n_arr
134
- assert_raise(RuntimeError) { cursor[2] = v_arr }
133
+ assert_raises(RuntimeError) { cursor[2] = v_arr }
135
134
  cursor.close
136
135
 
137
136
  drop_table('test_table')
@@ -154,9 +153,9 @@ EOS
154
153
  cursor.bind_param_array(1, [1, 2, 3])
155
154
  cursor.bind_param_array(2, ['happy', 'new', 'year'])
156
155
  cursor.bind_param_array(3, [Time.gm(1990,1,1), Time.gm(2000,1,1), Time.gm(2010,1,1)])
157
- assert_nothing_raised() { cursor.exec_array }
156
+ cursor.exec_array
158
157
  cursor.max_array_size = 2
159
- assert_raise(RuntimeError) { cursor.exec_array }
158
+ assert_raises(RuntimeError) { cursor.exec_array }
160
159
  drop_table('test_table')
161
160
  end
162
161
 
@@ -184,7 +183,7 @@ EOS
184
183
  end
185
184
  cursor[1] = n_arr
186
185
  cursor[2] = v_arr
187
- assert_nothing_raised() { cursor.exec_array }
186
+ cursor.exec_array
188
187
  cursor.close
189
188
 
190
189
  cursor = @conn.parse("SELECT * FROM test_table ORDER BY N")
@@ -213,7 +212,7 @@ EOS
213
212
  cursor.max_array_size = max_array_size
214
213
  cursor.bind_param_array(1, nil, Fixnum)
215
214
  cursor.bind_param_array(2, nil, String)
216
- assert_raise(RuntimeError) { cursor.exec_array }
215
+ assert_raises(RuntimeError) { cursor.exec_array }
217
216
  cursor.close
218
217
  drop_table('test_table')
219
218
  end
@@ -1,9 +1,8 @@
1
1
  # Low-level API
2
2
  require 'oci8'
3
- require 'test/unit'
4
3
  require File.dirname(__FILE__) + '/config'
5
4
 
6
- class TestBindRaw < Test::Unit::TestCase
5
+ class TestBindRaw < Minitest::Test
7
6
  CHECK_TARGET = [
8
7
  ["0123456789:;<=>?", "303132333435363738393A3B3C3D3E3F"],
9
8
  ["@ABCDEFGHIJKLMNO", "404142434445464748494A4B4C4D4E4F"],
@@ -1,9 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'oci8'
3
- require 'test/unit'
4
3
  require File.dirname(__FILE__) + '/config'
5
4
 
6
- class TestBindString < Test::Unit::TestCase
5
+ class TestBindString < Minitest::Test
7
6
  def setup
8
7
  @conn = get_oci8_connection
9
8
  end
@@ -1,8 +1,7 @@
1
1
  require 'oci8'
2
- require 'test/unit'
3
2
  require File.dirname(__FILE__) + '/config'
4
3
 
5
- class TestBindTime < Test::Unit::TestCase
4
+ class TestBindTime < Minitest::Test
6
5
 
7
6
  YEAR_CHECK_TARGET = [1971, 1989, 2002, 2037]
8
7
  MON_CHECK_TARGET = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
@@ -1,10 +1,9 @@
1
1
  # High-level API
2
2
  require 'oci8'
3
- require 'test/unit'
4
3
  require 'timeout'
5
4
  require File.dirname(__FILE__) + '/config'
6
5
 
7
- class TestBreak < Test::Unit::TestCase
6
+ class TestBreak < Minitest::Test
8
7
 
9
8
  def setup
10
9
  @conn = get_oci8_connection
@@ -107,7 +106,7 @@ class TestBreak < Test::Unit::TestCase
107
106
  # MRI and Rubinius 2.0.0
108
107
  expected = Timeout::Error
109
108
  end
110
- assert_raise(expected) do
109
+ assert_raises(expected) do
111
110
  Timeout.timeout(1) do
112
111
  @conn.exec("BEGIN DBMS_LOCK.SLEEP(5); END;")
113
112
  end
@@ -1,9 +1,8 @@
1
1
  # Low-level API
2
2
  require 'oci8'
3
- require 'test/unit'
4
3
  require File.dirname(__FILE__) + '/config'
5
4
 
6
- class TestCLob < Test::Unit::TestCase
5
+ class TestCLob < Minitest::Test
7
6
 
8
7
  def setup
9
8
  @conn = get_oci8_connection
@@ -1,8 +1,7 @@
1
1
  require 'oci8'
2
- require 'test/unit'
3
2
  require File.dirname(__FILE__) + '/config'
4
3
 
5
- class TestConnectionPool < Test::Unit::TestCase
4
+ class TestConnectionPool < Minitest::Test
6
5
 
7
6
  def create_pool(min, max, incr)
8
7
  OCI8::ConnectionPool.new(min, max, incr, $dbuser, $dbpass, $dbname)
@@ -48,7 +47,7 @@ class TestConnectionPool < Test::Unit::TestCase
48
47
  if cnt == 0
49
48
  unless conn.non_blocking?
50
49
  non_blocking = false
51
- assert_raise(RuntimeError) do
50
+ assert_raises(RuntimeError) do
52
51
  # This should raise "Could not set non-blocking mode to a connection allocated from OCI8::ConnectionPool."
53
52
  conn.non_blocking = true
54
53
  end
@@ -1,8 +1,7 @@
1
1
  require 'oci8'
2
- require 'test/unit'
3
2
  require File.dirname(__FILE__) + '/config'
4
3
 
5
- class TestConnStr < Test::Unit::TestCase
4
+ class TestConnStr < Minitest::Test
6
5
  TEST_CASES =
7
6
  [
8
7
  # success cases:
@@ -77,5 +76,3 @@ class TestConnStr < Test::Unit::TestCase
77
76
  end
78
77
  end
79
78
  end
80
-
81
- Test::Unit::AutoRunner.run() if $0 == __FILE__
@@ -1,9 +1,8 @@
1
1
  require 'oci8'
2
- require 'test/unit'
3
2
  require File.dirname(__FILE__) + '/config'
4
3
  require 'scanf'
5
4
 
6
- class TestDateTime < Test::Unit::TestCase
5
+ class TestDateTime < Minitest::Test
7
6
 
8
7
  def timezone_string(tzh, tzm)
9
8
  if tzh >= 0
@@ -247,7 +246,7 @@ EOS
247
246
  def test_timezone
248
247
  begin
249
248
  # temporarily change the mapping to test OCI8::BindType::Util.default_timezone.
250
- assert_raise(ArgumentError) do
249
+ assert_raises(ArgumentError) do
251
250
  OCI8::BindType::Util.default_timezone = :invalid_value
252
251
  end
253
252
 
@@ -1,9 +1,8 @@
1
1
  require 'dbi'
2
2
  require 'oci8'
3
- require 'test/unit'
4
3
  require File.dirname(__FILE__) + '/config'
5
4
 
6
- class TestDBI < Test::Unit::TestCase
5
+ class TestDBI < Minitest::Test
7
6
 
8
7
  def setup
9
8
  @dbh = get_dbi_connection()
@@ -1,23 +1,23 @@
1
1
  require 'dbi'
2
2
  require 'oci8'
3
- require 'test/unit'
4
3
  require File.dirname(__FILE__) + '/config'
5
4
 
6
- class TestDbiCLob < Test::Unit::TestCase
5
+ class TestDbiCLob < Minitest::Test
7
6
 
8
7
  def setup
9
8
  @dbh = get_dbi_connection()
9
+ drop_table('test_table')
10
+ @dbh.execute('CREATE TABLE test_table (filename VARCHAR2(40), content CLOB)')
10
11
  end
11
12
 
12
13
  def test_insert
13
14
  filename = File.basename($lobfile)
14
- @dbh.do("DELETE FROM test_clob WHERE filename = :1", filename)
15
15
 
16
16
  # insert an empty clob and get the rowid.
17
- rowid = @dbh.execute("INSERT INTO test_clob(filename, content) VALUES (:1, EMPTY_CLOB())", filename) do |sth|
17
+ rowid = @dbh.execute("INSERT INTO test_table(filename, content) VALUES (:1, EMPTY_CLOB())", filename) do |sth|
18
18
  sth.func(:rowid)
19
19
  end
20
- lob = @dbh.select_one("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE", filename)[0]
20
+ lob = @dbh.select_one("SELECT content FROM test_table WHERE filename = :1 FOR UPDATE", filename)[0]
21
21
  begin
22
22
  open($lobfile) do |f|
23
23
  while f.gets()
@@ -32,7 +32,7 @@ class TestDbiCLob < Test::Unit::TestCase
32
32
  def test_read
33
33
  filename = File.basename($lobfile)
34
34
  test_insert() # first insert data.
35
- lob = @dbh.select_one("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE", filename)[0]
35
+ lob = @dbh.select_one("SELECT content FROM test_table WHERE filename = :1 FOR UPDATE", filename)[0]
36
36
  begin
37
37
  open($lobfile) do |f|
38
38
  while buf = lob.read($lobreadnum)