ruby-oci8 2.2.6.1-x86-mingw32 → 2.2.10-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_oci8.rb CHANGED
@@ -25,53 +25,142 @@ EOS
25
25
  drop_table('test_rename_table')
26
26
  end
27
27
 
28
- # USE_DYNAMIC_FETCH doesn't work well...
29
- # This test is disabled.
30
- def _test_long_type
31
- drop_table('test_table')
32
- @conn.exec('CREATE TABLE test_table (id number(38), lng long)')
33
- test_data1 = 'a' * 70000
34
- test_data2 = 'b' * 3000
35
- test_data3 = nil
36
- test_data4 = 'c' * 70000
37
- @conn.exec('insert into test_table values (:1, :2)', 1, test_data1)
38
- @conn.exec('insert into test_table values (:1, :2)', 2, [test_data2, :long])
39
- @conn.exec('insert into test_table values (:1, :2)', 3, [nil, :long])
40
- @conn.exec('insert into test_table values (:1, :2)', 4, [test_data4, :long])
41
-
42
- [8000, 65535, 65536, 80000].each do |read_len|
43
- @conn.long_read_len = read_len
44
- cursor = @conn.parse('SELECT lng from test_table order by id')
45
- cursor.exec
46
- assert_equal(test_data1, cursor.fetch[0])
47
- assert_equal(test_data2, cursor.fetch[0])
48
- assert_equal(test_data3, cursor.fetch[0])
49
- assert_equal(test_data4, cursor.fetch[0])
50
- cursor.close
28
+ # Set `OCI8::BindType::Base.initial_chunk_size = 5` to
29
+ # use the following test data.
30
+ LONG_TEST_DATA = [
31
+ # initial chunk size: 5 (total buffer size: 5)
32
+ 'a' * 4, 'b' * 5, 'c' * 6, 'd' * 5, 'e' * 4,
33
+ # second chunk size: 10 (total buffer size: 15)
34
+ 'f' * 14, 'g' * 15, 'h' * 16, 'i' * 15, 'j' * 14,
35
+ # third chunk size: 20 (total buffer size: 35)
36
+ 'k' * 34, 'l' * 35, 'm' * 36, 'n' * 35, 'o' * 34,
37
+ # use data around initial chunk size again
38
+ 'p' * 4, 'q' * 5, 'r' * 6, 's' * 5, 't' * 4,
39
+ # special data
40
+ '', nil,
41
+ ]
42
+
43
+ def test_long_type
44
+ clob_bind_type = OCI8::BindType::Mapping[:clob]
45
+ blob_bind_type = OCI8::BindType::Mapping[:blob]
46
+ initial_cunk_size = OCI8::BindType::Base.initial_chunk_size
47
+ begin
48
+ OCI8::BindType::Base.initial_chunk_size = 5
49
+ @conn.prefetch_rows = LONG_TEST_DATA.size / 3
50
+ drop_table('test_table')
51
+ ascii_enc = Encoding.find('US-ASCII')
52
+ 0.upto(1) do |i|
53
+ if i == 0
54
+ @conn.exec("CREATE TABLE test_table (id number(38), long_column long, clob_column clob)")
55
+ cursor = @conn.parse('insert into test_table values (:1, :2, :3)')
56
+ cursor.bind_param(1, nil, Integer)
57
+ cursor.bind_param(2, nil, :long)
58
+ cursor.bind_param(3, nil, :clob)
59
+ lob = OCI8::CLOB.new(@conn, '')
60
+ enc = Encoding.default_internal || OCI8.encoding
61
+ else
62
+ @conn.exec("CREATE TABLE test_table (id number(38), long_raw_column long raw, blob_column blob)")
63
+ cursor = @conn.parse('insert into test_table values (:1, :2, :3)')
64
+ cursor.bind_param(1, nil, Integer)
65
+ cursor.bind_param(2, nil, :long_raw)
66
+ cursor.bind_param(3, nil, :blob)
67
+ lob = OCI8::BLOB.new(@conn, '')
68
+ enc = Encoding.find('ASCII-8BIT')
69
+ end
70
+
71
+ LONG_TEST_DATA.each_with_index do |data, index|
72
+ cursor[1] = index
73
+ cursor[2] = data
74
+ if data.nil?
75
+ cursor[3] = nil
76
+ else
77
+ lob.rewind
78
+ lob.write(data)
79
+ lob.size = data.size
80
+ cursor[3] = lob
81
+ end
82
+ cursor.exec
83
+ end
84
+ cursor.close
85
+
86
+ cursor = @conn.parse('SELECT * from test_table order by id')
87
+ cursor.exec
88
+ LONG_TEST_DATA.each_with_index do |data, index|
89
+ row = cursor.fetch
90
+ assert_equal(index, row[0])
91
+ if data.nil?
92
+ assert_nil(row[1])
93
+ assert_nil(row[2])
94
+ elsif data.empty?
95
+ # '' is inserted to the long or long raw column as null.
96
+ assert_nil(row[1])
97
+ # '' is inserted to the clob or blob column as an empty clob.
98
+ # It is fetched as '' when the data is read using a LOB locator.
99
+ assert_equal(data, clob_data = row[2].read)
100
+ assert_equal(ascii_enc, clob_data.encoding)
101
+ else
102
+ assert_equal(data, row[1])
103
+ assert_equal(data, clob_data = row[2].read)
104
+ assert_equal(enc, row[1].encoding)
105
+ assert_equal(enc, clob_data.encoding)
106
+ end
107
+ end
108
+ assert_nil(cursor.fetch)
109
+ cursor.close
110
+
111
+ begin
112
+ OCI8::BindType::Mapping[:clob] = OCI8::BindType::Long
113
+ OCI8::BindType::Mapping[:blob] = OCI8::BindType::LongRaw
114
+ cursor = @conn.parse('SELECT * from test_table order by id')
115
+ cursor.exec
116
+ LONG_TEST_DATA.each_with_index do |data, index|
117
+ row = cursor.fetch
118
+ assert_equal(index, row[0])
119
+ if data.nil?
120
+ assert_nil(row[1])
121
+ assert_nil(row[2])
122
+ elsif data.empty?
123
+ # '' is inserted to the long or long raw column as null.
124
+ assert_nil(row[1])
125
+ # '' is inserted to the clob or blob column as an empty clob.
126
+ # However it is fetched as nil.
127
+ assert_nil(row[2])
128
+ else
129
+ assert_equal(data, row[1])
130
+ assert_equal(data, row[2])
131
+ assert_equal(enc, row[1].encoding)
132
+ assert_equal(enc, row[2].encoding)
133
+ end
134
+ end
135
+ assert_nil(cursor.fetch)
136
+ cursor.close
137
+ ensure
138
+ OCI8::BindType::Mapping[:clob] = clob_bind_type
139
+ OCI8::BindType::Mapping[:blob] = blob_bind_type
140
+ end
141
+ drop_table('test_table')
142
+ end
143
+ ensure
144
+ OCI8::BindType::Base.initial_chunk_size = initial_cunk_size
51
145
  end
52
146
  drop_table('test_table')
53
147
  end
54
148
 
55
- def test_long_type
56
- @conn.long_read_len = 80000
57
- drop_table('test_table')
58
- @conn.exec('CREATE TABLE test_table (id number(38), lng long)')
59
- test_data1 = 'a' * 70000
60
- test_data2 = 'b' * 3000
61
- test_data4 = 'c' * 70000
62
- @conn.exec('insert into test_table values (:1, :2)', 1, test_data1)
63
- @conn.exec('insert into test_table values (:1, :2)', 2, [test_data2, :long])
64
- @conn.exec('insert into test_table values (:1, :2)', 3, [nil, :long])
65
- @conn.exec('insert into test_table values (:1, :2)', 4, [test_data4, :long])
66
-
67
- cursor = @conn.parse('SELECT lng from test_table order by id')
68
- cursor.exec
69
- assert_equal(test_data1, cursor.fetch[0])
70
- assert_equal(test_data2, cursor.fetch[0])
71
- assert_nil(cursor.fetch[0])
72
- assert_equal(test_data4, cursor.fetch[0])
73
- cursor.close
74
- drop_table('test_table')
149
+ def test_bind_long_data
150
+ initial_cunk_size = OCI8::BindType::Base.initial_chunk_size
151
+ begin
152
+ OCI8::BindType::Base.initial_chunk_size = 5
153
+ cursor = @conn.parse("begin :1 := '<' || :2 || '>'; end;")
154
+ cursor.bind_param(1, nil, :long)
155
+ cursor.bind_param(2, nil, :long)
156
+ (LONG_TEST_DATA + ['z' * 4000]).each do |data|
157
+ cursor[2] = data
158
+ cursor.exec
159
+ assert_equal("<#{data}>", cursor[1])
160
+ end
161
+ ensure
162
+ OCI8::BindType::Base.initial_chunk_size = initial_cunk_size
163
+ end
75
164
  end
76
165
 
77
166
  def test_select
@@ -450,6 +539,7 @@ EOS
450
539
  assert_nil(@conn.last_error)
451
540
  @conn.last_error = 'dummy'
452
541
  cursor = @conn.parse('select col1, max(col2) from (select 1 as col1, null as col2 from dual) group by col1')
542
+ cursor.prefetch_rows = 1
453
543
  assert_nil(@conn.last_error)
454
544
 
455
545
  # When an OCI function returns OCI_SUCCESS_WITH_INFO, OCI8#last_error is set.
@@ -510,4 +600,25 @@ EOS
510
600
  end
511
601
  assert_equal(ver, @conn.oracle_server_version.to_s)
512
602
  end
603
+
604
+ def test_array_fetch
605
+ drop_table('test_table')
606
+ @conn.exec("CREATE TABLE test_table (id number, val clob)")
607
+ cursor = @conn.parse("INSERT INTO test_table VALUES (:1, :2)")
608
+ 1.upto(10) do |i|
609
+ cursor.exec(i, ('a'.ord + i).chr * i)
610
+ end
611
+ cursor.close
612
+ cursor = @conn.parse("select * from test_table where id <= :1 order by id")
613
+ cursor.prefetch_rows = 4
614
+ [1, 6, 2, 7, 3, 8, 4, 9, 5, 10].each do |i|
615
+ cursor.exec(i)
616
+ 1.upto(i) do |j|
617
+ row = cursor.fetch
618
+ assert_equal(j, row[0])
619
+ assert_equal(('a'.ord + j).chr * j, row[1].read)
620
+ end
621
+ assert_nil(cursor.fetch)
622
+ end
623
+ end
513
624
  end # TestOCI8
@@ -215,9 +215,15 @@ EOS
215
215
  end
216
216
 
217
217
  def test_yaml
218
+ # Use the permitted_classes keyword parameter if it is supported by YAML.load
219
+ keyword_params = if YAML.method(:load).parameters.any? { |key, value| value == :permitted_symbols }
220
+ {permitted_classes: [OraNumber]}
221
+ else
222
+ {}
223
+ end
218
224
  (LARGE_RANGE_VALUES + ['~', '-~']).each do |x|
219
225
  n = OraNumber.new(x)
220
- assert_equal(n, YAML.load(YAML.dump(n)))
226
+ assert_equal(n, YAML.load(YAML.dump(n), **keyword_params))
221
227
  end
222
228
  end
223
229
 
metadata CHANGED
@@ -1,37 +1,26 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ruby-oci8
3
- version: !ruby/object:Gem::Version
4
- hash: 101
5
- prerelease: false
6
- segments:
7
- - 2
8
- - 2
9
- - 6
10
- - 1
11
- version: 2.2.6.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.2.10
12
5
  platform: x86-mingw32
13
- authors:
6
+ authors:
14
7
  - Kubo Takehiro
15
8
  autorequire:
16
9
  bindir: bin
17
10
  cert_chain: []
18
-
19
- date: 2018-09-16 00:00:00 +09:00
20
- default_executable:
11
+ date: 2022-01-12 00:00:00.000000000 Z
21
12
  dependencies: []
13
+ description: 'ruby-oci8 is a ruby interface for Oracle using OCI8 API. It is available
14
+ with Oracle 10g or later including Oracle Instant Client.
22
15
 
23
- description: |
24
- ruby-oci8 is a ruby interface for Oracle using OCI8 API. It is available with Oracle 10g or later including Oracle Instant Client.
25
-
16
+ '
26
17
  email: kubo@jiubao.org
27
18
  executables: []
28
-
29
19
  extensions: []
30
-
31
- extra_rdoc_files:
20
+ extra_rdoc_files:
32
21
  - README.md
33
- files:
34
- - .yardopts
22
+ files:
23
+ - ".yardopts"
35
24
  - COPYING
36
25
  - COPYING_old
37
26
  - ChangeLog
@@ -39,10 +28,6 @@ files:
39
28
  - NEWS
40
29
  - README.md
41
30
  - dist-files
42
- - metaconfig
43
- - pre-distclean.rb
44
- - ruby-oci8.gemspec
45
- - setup.rb
46
31
  - docs/bind-array-to-in_cond.md
47
32
  - docs/conflicts-local-connections-and-processes.md
48
33
  - docs/hanging-after-inactivity.md
@@ -52,13 +37,12 @@ files:
52
37
  - docs/install-on-osx.md
53
38
  - docs/ldap-auth-and-function-interposition.md
54
39
  - docs/number-type-mapping.md
55
- - docs/osx-install-dev-tools.png
56
40
  - docs/platform-specific-issues.md
57
41
  - docs/report-installation-issue.md
58
42
  - docs/timeout-parameters.md
59
43
  - lib/.document
60
- - lib/oci8.rb
61
44
  - lib/dbd/OCI8.rb
45
+ - lib/oci8.rb
62
46
  - lib/oci8/.document
63
47
  - lib/oci8/bindtype.rb
64
48
  - lib/oci8/check_load_error.rb
@@ -75,8 +59,17 @@ files:
75
59
  - lib/oci8/oracle_version.rb
76
60
  - lib/oci8/properties.rb
77
61
  - lib/oci8/version.rb
62
+ - lib/oci8lib_250.so
63
+ - lib/oci8lib_260.so
64
+ - lib/oci8lib_270.so
65
+ - lib/oci8lib_300.so
66
+ - lib/oci8lib_310.so
78
67
  - lib/ruby-oci8.rb
79
- - test/README
68
+ - metaconfig
69
+ - pre-distclean.rb
70
+ - ruby-oci8.gemspec
71
+ - setup.rb
72
+ - test/README.md
80
73
  - test/config.rb
81
74
  - test/setup_test_object.sql
82
75
  - test/setup_test_package.sql
@@ -85,18 +78,18 @@ files:
85
78
  - test/test_array_dml.rb
86
79
  - test/test_bind_array.rb
87
80
  - test/test_bind_boolean.rb
81
+ - test/test_bind_integer.rb
88
82
  - test/test_bind_raw.rb
89
83
  - test/test_bind_string.rb
90
84
  - test/test_bind_time.rb
91
- - test/test_bind_integer.rb
92
85
  - test/test_break.rb
93
86
  - test/test_clob.rb
94
87
  - test/test_connection_pool.rb
95
88
  - test/test_connstr.rb
96
- - test/test_encoding.rb
97
89
  - test/test_datetime.rb
98
90
  - test/test_dbi.rb
99
91
  - test/test_dbi_clob.rb
92
+ - test/test_encoding.rb
100
93
  - test/test_error.rb
101
94
  - test/test_metadata.rb
102
95
  - test/test_object.rb
@@ -107,49 +100,29 @@ files:
107
100
  - test/test_package_type.rb
108
101
  - test/test_properties.rb
109
102
  - test/test_rowid.rb
110
- - lib/oci8lib_191.so
111
- - lib/oci8lib_200.so
112
- - lib/oci8lib_210.so
113
- - lib/oci8lib_220.so
114
- - lib/oci8lib_230.so
115
- - lib/oci8lib_240.so
116
- - lib/oci8lib_250.so
117
- has_rdoc: true
118
103
  homepage: http://www.rubydoc.info/github/kubo/ruby-oci8
119
- licenses:
104
+ licenses:
120
105
  - BSD-2-Clause
106
+ metadata: {}
121
107
  post_install_message:
122
108
  rdoc_options: []
123
-
124
- require_paths:
109
+ require_paths:
125
110
  - lib
126
- - ext/oci8
127
- required_ruby_version: !ruby/object:Gem::Requirement
128
- none: false
129
- requirements:
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
130
113
  - - ">="
131
- - !ruby/object:Gem::Version
132
- hash: 49
133
- segments:
134
- - 1
135
- - 9
136
- - 1
137
- version: 1.9.1
138
- required_rubygems_version: !ruby/object:Gem::Requirement
139
- none: false
140
- requirements:
114
+ - !ruby/object:Gem::Version
115
+ version: 2.5.0
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
141
118
  - - ">="
142
- - !ruby/object:Gem::Version
143
- hash: 3
144
- segments:
145
- - 0
146
- version: "0"
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
147
121
  requirements: []
148
-
149
122
  rubyforge_project:
150
- rubygems_version: 1.3.7
123
+ rubygems_version: 2.7.3
151
124
  signing_key:
152
- specification_version: 3
125
+ specification_version: 4
153
126
  summary: Ruby interface for Oracle using OCI8 API
154
- test_files:
127
+ test_files:
155
128
  - test/test_all.rb
Binary file
data/lib/oci8lib_191.so DELETED
Binary file
data/lib/oci8lib_200.so DELETED
Binary file
data/lib/oci8lib_210.so DELETED
Binary file
data/lib/oci8lib_220.so DELETED
Binary file
data/lib/oci8lib_230.so DELETED
Binary file
data/lib/oci8lib_240.so DELETED
Binary file
data/test/README DELETED
@@ -1,42 +0,0 @@
1
- Before runing unit test:
2
-
3
- 1. connect to Oracle as system:
4
-
5
- $ sqlplus system/<password_of_system>
6
-
7
- 2. create user ruby:
8
-
9
- SQL> CREATE USER ruby IDENTIFIED BY oci8;
10
-
11
- or
12
-
13
- SQL> CREATE USER ruby IDENTIFIED BY oci8
14
- 2 DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp;
15
-
16
- 3. grant the privilege to connect and execute.
17
-
18
- SQL> GRANT connect, resource, create view TO ruby;
19
-
20
- 4. connect to Oracle as sys
21
-
22
- $ sqlplus 'sys/<password_of_sys> as sysdba'
23
-
24
- 5. grant privileges
25
-
26
- SQL> GRANT EXECUTE ON dbms_lock TO ruby;
27
- SQL> GRANT CREATE VIEW TO ruby;
28
-
29
- 6. connect as ruby user.
30
-
31
- $ sqlplus ruby/oci8
32
-
33
- 7. Create object types
34
-
35
- SQL> @test/setup_test_object.sql
36
-
37
- 8. change $dbname if the database
38
-
39
- Then you can run:
40
- $ make check
41
- or
42
- $ nmake check (If your compiler is MS Visual C++.)