ruby-oci8 2.2.1 → 2.2.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.
@@ -425,22 +425,6 @@ class OCIHandle
425
425
  # @private
426
426
  OCI_CRED_EXT = 2
427
427
 
428
- #################################
429
- #
430
- # Authentication Modes
431
- #
432
- #################################
433
-
434
- # for SYSDBA authorization
435
- # @private
436
- OCI_SYSDBA = 0x0002
437
- # for SYSOPER authorization
438
- # @private
439
- OCI_SYSOPER = 0x0004
440
- # for SYSASM authorization
441
- # @private
442
- OCI_SYSASM = 0x8000
443
-
444
428
  #################################
445
429
  #
446
430
  # OCI Parameter Types
@@ -13,6 +13,10 @@ class OCI8
13
13
  :statement_cache_size => 0,
14
14
  :events_mode => ((OCI8.__get_prop(2) & 4) != 0), # 4 <- OCI_EVENTS in oci.h
15
15
  :cancel_read_at_exit => false,
16
+ :tcp_connect_timeout => nil,
17
+ :connect_timeout => nil,
18
+ :send_timeout => nil,
19
+ :recv_timeout => nil,
16
20
  }
17
21
 
18
22
  # @private
@@ -53,6 +57,11 @@ class OCI8
53
57
  when :cancel_read_at_exit
54
58
  val = val ? true : false
55
59
  OCI8.__set_prop(3, val)
60
+ when :tcp_connect_timeout, :connect_timeout, :send_timeout, :recv_timeout
61
+ if !val.nil?
62
+ val = val.to_i
63
+ raise ArgumentError, "The property value for :#{name} must be nil or a positive integer." if val <= 0
64
+ end
56
65
  end
57
66
  super(name, val)
58
67
  end
@@ -132,6 +141,30 @@ class OCI8
132
141
  #
133
142
  # *Since:* 2.1.8
134
143
  #
144
+ # [:tcp_connect_timeout]
145
+ #
146
+ # See {file:docs/timeout-parameters.md}
147
+ #
148
+ # *Since:* 2.2.2
149
+ #
150
+ # [:connect_timeout]
151
+ #
152
+ # See {file:docs/timeout-parameters.md}
153
+ #
154
+ # *Since:* 2.2.2
155
+ #
156
+ # [:send_timeout]
157
+ #
158
+ # See {file:docs/timeout-parameters.md}
159
+ #
160
+ # *Since:* 2.2.2
161
+ #
162
+ # [:recv_timeout]
163
+ #
164
+ # See {file:docs/timeout-parameters.md}
165
+ #
166
+ # *Since:* 2.2.2
167
+ #
135
168
  # @return [a customized Hash]
136
169
  # @since 2.0.5
137
170
  #
@@ -1,3 +1,3 @@
1
1
  class OCI8
2
- VERSION = "2.2.1"
2
+ VERSION = "2.2.2"
3
3
  end
@@ -0,0 +1,4 @@
1
+ if caller[0] !~ /\/bundler\/runtime\.rb:\d+:in `require'/
2
+ warn "Don't requie 'ruby-oci8'. Use \"require 'oci8'\" instead. 'ruby-oci8.rb' was added only for 'Bundler.require'."
3
+ end
4
+ require 'oci8'
@@ -37,7 +37,7 @@ EOS
37
37
  s.has_rdoc = 'yard'
38
38
  s.authors = ['Kubo Takehiro']
39
39
  s.platform = gem_platform
40
- s.license = '2-clause BSD-style license'
40
+ s.license = 'BSD-2-Clause'
41
41
  files = File.read('dist-files').split("\n")
42
42
  if gem_platform == Gem::Platform::RUBY
43
43
  s.extensions << 'ext/oci8/extconf.rb'
@@ -10,6 +10,10 @@ drop type rb_test_obj_elem_array
10
10
  /
11
11
  drop type rb_test_obj_elem
12
12
  /
13
+ drop type rb_test_obj_sub
14
+ /
15
+ drop type rb_test_obj_base
16
+ /
13
17
  create type rb_test_obj_elem as object (
14
18
  x integer,
15
19
  y integer
@@ -116,7 +120,7 @@ create or replace type body rb_test_obj is
116
120
 
117
121
  static function test_object_version return integer is
118
122
  begin
119
- return 2;
123
+ return 3;
120
124
  end;
121
125
 
122
126
  static function class_func(n number) return rb_test_obj is
@@ -167,5 +171,21 @@ begin
167
171
  end loop;
168
172
  end;
169
173
  /
170
- commit
174
+
175
+ create type rb_test_obj_base as object (
176
+ id varchar2(30)
177
+ ) not final
178
+ /
179
+ create type rb_test_obj_sub under rb_test_obj_base (
180
+ subid varchar2(30)
181
+ ) final
182
+ /
183
+ create or replace function rb_test_obj_get_object(get_base integer) return rb_test_obj_base is
184
+ begin
185
+ if get_base = 0 then
186
+ return rb_test_obj_base('base');
187
+ else
188
+ return rb_test_obj_sub('sub', 'subid');
189
+ end if;
190
+ end;
171
191
  /
@@ -5,6 +5,7 @@ require "#{srcdir}/config"
5
5
 
6
6
  require "#{srcdir}/test_oradate"
7
7
  require "#{srcdir}/test_oranumber"
8
+ require "#{srcdir}/test_bind_array.rb"
8
9
  require "#{srcdir}/test_bind_string"
9
10
  require "#{srcdir}/test_bind_time"
10
11
  require "#{srcdir}/test_bind_raw"
@@ -75,4 +75,130 @@ class TestConnStr < Minitest::Test
75
75
  end
76
76
  end
77
77
  end
78
+
79
+ # https://docs.oracle.com/database/121/NETAG/naming.htm#BABJBFHJ
80
+ DESC_TEST_CASE =
81
+ [
82
+ # Cannot distinguish net service names from easy connect strings in this case.
83
+ ["sales-server", nil, nil, "sales-server"],
84
+ # Easy Connect string with host.
85
+ ["//sales-server", nil, nil, <<EOS],
86
+ (DESCRIPTION=
87
+ (CONNECT_DATA=
88
+ (SERVICE_NAME=))
89
+ (ADDRESS=
90
+ (PROTOCOL=TCP)
91
+ (HOST=sales-server)
92
+ (PORT=1521)))
93
+ EOS
94
+ # Easy Connect string with host and port.
95
+ ["sales-server:3456", nil, nil, <<EOS],
96
+ (DESCRIPTION=
97
+ (CONNECT_DATA=
98
+ (SERVICE_NAME=))
99
+ (ADDRESS=
100
+ (PROTOCOL=TCP)
101
+ (HOST=sales-server)
102
+ (PORT=3456)))
103
+ EOS
104
+ # The host name is sales-server and the service name is sales.
105
+ ["sales-server/sales", nil, nil, <<EOS],
106
+ (DESCRIPTION=
107
+ (CONNECT_DATA=
108
+ (SERVICE_NAME=sales))
109
+ (ADDRESS=
110
+ (PROTOCOL=TCP)
111
+ (HOST=sales-server)
112
+ (PORT=1521)))
113
+ EOS
114
+ # Easy Connect string with IPv6 address.
115
+ ["[2001:0db8:0:0::200C:417A]:80/sales", nil, nil, <<EOS],
116
+ (DESCRIPTION=
117
+ (CONNECT_DATA=
118
+ (SERVICE_NAME=sales))
119
+ (ADDRESS=
120
+ (PROTOCOL=TCP)
121
+ (HOST=2001:0db8:0:0::200C:417A)
122
+ (PORT=80)))
123
+ EOS
124
+ # Easy Connect string with IPv6 host address.
125
+ ["sales-server:80/sales", nil, nil, <<EOS],
126
+ (DESCRIPTION=
127
+ (CONNECT_DATA=
128
+ (SERVICE_NAME=sales))
129
+ (ADDRESS=
130
+ (PROTOCOL=TCP)
131
+ (HOST=sales-server)
132
+ (PORT=80)))
133
+ EOS
134
+ # Easy Connect string with host, service name, and server.
135
+ ["sales-server/sales:dedicated/inst1", nil, nil, <<EOS],
136
+ (DESCRIPTION=
137
+ (CONNECT_DATA=
138
+ (SERVICE_NAME=sales)
139
+ (SERVER=dedicated)
140
+ (INSTANCE_NAME=inst1))
141
+ (ADDRESS=
142
+ (PROTOCOL=TCP)
143
+ (HOST=sales-server)
144
+ (PORT=1521)))
145
+ EOS
146
+ ["sales-server//inst1", nil, nil, <<EOS],
147
+ (DESCRIPTION=
148
+ (CONNECT_DATA=
149
+ (SERVICE_NAME=)
150
+ (INSTANCE_NAME=inst1))
151
+ (ADDRESS=
152
+ (PROTOCOL=TCP)
153
+ (HOST=sales-server)
154
+ (PORT=1521)))
155
+ EOS
156
+ #
157
+ ["sales-server/sales", 20, nil, <<EOS],
158
+ (DESCRIPTION=
159
+ (CONNECT_DATA=
160
+ (SERVICE_NAME=sales))
161
+ (ADDRESS=
162
+ (PROTOCOL=TCP)
163
+ (HOST=sales-server)
164
+ (PORT=1521))
165
+ (TRANSPORT_CONNECT_TIMEOUT=20))
166
+ EOS
167
+ #
168
+ ["sales-server/sales", nil, 30, <<EOS],
169
+ (DESCRIPTION=
170
+ (CONNECT_DATA=
171
+ (SERVICE_NAME=sales))
172
+ (ADDRESS=
173
+ (PROTOCOL=TCP)
174
+ (HOST=sales-server)
175
+ (PORT=1521))
176
+ (CONNECT_TIMEOUT=30))
177
+ EOS
178
+ #
179
+ ["sales-server/sales", 20, 30, <<EOS],
180
+ (DESCRIPTION=
181
+ (CONNECT_DATA=
182
+ (SERVICE_NAME=sales))
183
+ (ADDRESS=
184
+ (PROTOCOL=TCP)
185
+ (HOST=sales-server)
186
+ (PORT=1521))
187
+ (TRANSPORT_CONNECT_TIMEOUT=20)
188
+ (CONNECT_TIMEOUT=30))
189
+ EOS
190
+ ]
191
+
192
+ def test_connect_descriptor
193
+ obj = OCI8.allocate # create an uninitialized object.
194
+ DESC_TEST_CASE.each do |test_case|
195
+ easy_connect_string = test_case[0]
196
+ tcp_connnect_timeout= test_case[1]
197
+ outbound_connnect_timeout = test_case[2]
198
+ expected_result = test_case[3].gsub(/\s/, '')
199
+ # use instance_eval to call a private method to_connect_descriptor
200
+ result = obj.instance_eval { to_connect_descriptor(easy_connect_string, tcp_connnect_timeout, outbound_connnect_timeout) }
201
+ assert_equal(expected_result, result, easy_connect_string)
202
+ end
203
+ end
78
204
  end
@@ -22,7 +22,7 @@ begin
22
22
 
23
23
  begin
24
24
  version = RbTestObj.test_object_version(conn)
25
- error_message = "Invalid test object version" if version != 2
25
+ error_message = "Invalid test object version" if version != 3
26
26
  rescue NoMethodError
27
27
  raise unless $!.to_s.include?('test_object_version')
28
28
  error_message = "rb_test_obj.test_object_version is not declared."
@@ -48,6 +48,12 @@ EOS
48
48
  class RbTestIntArray < OCI8::Object::Base
49
49
  end
50
50
 
51
+ class RbTestObjBase < OCI8::Object::Base
52
+ end
53
+
54
+ class RbTestObjSub < RbTestObjBase
55
+ end
56
+
51
57
  class TestObj1 < Minitest::Test
52
58
  Delta = 0.00001
53
59
 
@@ -456,4 +462,23 @@ EOS
456
462
  assert_equal(ary ? ary[2] : nil, csr[:out3])
457
463
  end
458
464
  end
465
+
466
+ def test_get_subtype
467
+ csr = @conn.parse("BEGIN :result := rb_test_obj_get_object(:1); END;")
468
+ csr.bind_param(1, nil, RbTestObjBase)
469
+ csr.bind_param(2, nil, Integer)
470
+
471
+ csr[2] = 0
472
+ csr.exec
473
+ val = csr[1]
474
+ assert_instance_of(RbTestObjBase, val)
475
+ assert_equal(val.id, 'base')
476
+
477
+ csr[2] = 1
478
+ csr.exec
479
+ val = csr[1]
480
+ assert_instance_of(RbTestObjSub, val)
481
+ assert_equal(val.id, 'sub')
482
+ assert_equal(val.subid, 'subid')
483
+ end
459
484
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2
7
7
  - 2
8
- - 1
9
- version: 2.2.1
8
+ - 2
9
+ version: 2.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kubo Takehiro
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2015-11-01 00:00:00 +09:00
17
+ date: 2016-04-24 00:00:00 +09:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -41,13 +41,16 @@ files:
41
41
  - pre-distclean.rb
42
42
  - ruby-oci8.gemspec
43
43
  - setup.rb
44
+ - docs/bind-array-to-in_cond.md
44
45
  - docs/install-binary-package.md
45
46
  - docs/install-full-client.md
46
47
  - docs/install-instant-client.md
47
48
  - docs/install-on-osx.md
49
+ - docs/conflicts-local-connections-and-processes.md
48
50
  - docs/osx-install-dev-tools.png
49
51
  - docs/platform-specific-issues.md
50
52
  - docs/report-installation-issue.md
53
+ - docs/timeout-parameters.md
51
54
  - ext/oci8/.document
52
55
  - ext/oci8/MANIFEST
53
56
  - ext/oci8/apiwrap.c.tmpl
@@ -104,6 +107,7 @@ files:
104
107
  - lib/oci8/oracle_version.rb
105
108
  - lib/oci8/properties.rb
106
109
  - lib/oci8/version.rb
110
+ - lib/ruby-oci8.rb
107
111
  - test/README
108
112
  - test/config.rb
109
113
  - test/setup_test_object.sql
@@ -133,7 +137,7 @@ files:
133
137
  has_rdoc: true
134
138
  homepage: http://www.rubydoc.info/github/kubo/ruby-oci8
135
139
  licenses:
136
- - 2-clause BSD-style license
140
+ - BSD-2-Clause
137
141
  post_install_message:
138
142
  rdoc_options: []
139
143