ruby-oci8 2.2.6.1-x64-mingw32 → 2.2.10-x64-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,24 +1,26 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-oci8
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.6.1
4
+ version: 2.2.10
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - Kubo Takehiro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-16 00:00:00.000000000 Z
11
+ date: 2022-01-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: |
14
- ruby-oci8 is a ruby interface for Oracle using OCI8 API. It is available with Oracle 10g or later including Oracle Instant Client.
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.
15
+
16
+ '
15
17
  email: kubo@jiubao.org
16
18
  executables: []
17
19
  extensions: []
18
20
  extra_rdoc_files:
19
21
  - README.md
20
22
  files:
21
- - .yardopts
23
+ - ".yardopts"
22
24
  - COPYING
23
25
  - COPYING_old
24
26
  - ChangeLog
@@ -26,10 +28,6 @@ files:
26
28
  - NEWS
27
29
  - README.md
28
30
  - dist-files
29
- - metaconfig
30
- - pre-distclean.rb
31
- - ruby-oci8.gemspec
32
- - setup.rb
33
31
  - docs/bind-array-to-in_cond.md
34
32
  - docs/conflicts-local-connections-and-processes.md
35
33
  - docs/hanging-after-inactivity.md
@@ -39,13 +37,12 @@ files:
39
37
  - docs/install-on-osx.md
40
38
  - docs/ldap-auth-and-function-interposition.md
41
39
  - docs/number-type-mapping.md
42
- - docs/osx-install-dev-tools.png
43
40
  - docs/platform-specific-issues.md
44
41
  - docs/report-installation-issue.md
45
42
  - docs/timeout-parameters.md
46
43
  - lib/.document
47
- - lib/oci8.rb
48
44
  - lib/dbd/OCI8.rb
45
+ - lib/oci8.rb
49
46
  - lib/oci8/.document
50
47
  - lib/oci8/bindtype.rb
51
48
  - lib/oci8/check_load_error.rb
@@ -62,8 +59,17 @@ files:
62
59
  - lib/oci8/oracle_version.rb
63
60
  - lib/oci8/properties.rb
64
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
65
67
  - lib/ruby-oci8.rb
66
- - test/README
68
+ - metaconfig
69
+ - pre-distclean.rb
70
+ - ruby-oci8.gemspec
71
+ - setup.rb
72
+ - test/README.md
67
73
  - test/config.rb
68
74
  - test/setup_test_object.sql
69
75
  - test/setup_test_package.sql
@@ -72,18 +78,18 @@ files:
72
78
  - test/test_array_dml.rb
73
79
  - test/test_bind_array.rb
74
80
  - test/test_bind_boolean.rb
81
+ - test/test_bind_integer.rb
75
82
  - test/test_bind_raw.rb
76
83
  - test/test_bind_string.rb
77
84
  - test/test_bind_time.rb
78
- - test/test_bind_integer.rb
79
85
  - test/test_break.rb
80
86
  - test/test_clob.rb
81
87
  - test/test_connection_pool.rb
82
88
  - test/test_connstr.rb
83
- - test/test_encoding.rb
84
89
  - test/test_datetime.rb
85
90
  - test/test_dbi.rb
86
91
  - test/test_dbi_clob.rb
92
+ - test/test_encoding.rb
87
93
  - test/test_error.rb
88
94
  - test/test_metadata.rb
89
95
  - test/test_object.rb
@@ -94,12 +100,6 @@ files:
94
100
  - test/test_package_type.rb
95
101
  - test/test_properties.rb
96
102
  - test/test_rowid.rb
97
- - lib/oci8lib_200.so
98
- - lib/oci8lib_210.so
99
- - lib/oci8lib_220.so
100
- - lib/oci8lib_230.so
101
- - lib/oci8lib_240.so
102
- - lib/oci8lib_250.so
103
103
  homepage: http://www.rubydoc.info/github/kubo/ruby-oci8
104
104
  licenses:
105
105
  - BSD-2-Clause
@@ -108,20 +108,19 @@ post_install_message:
108
108
  rdoc_options: []
109
109
  require_paths:
110
110
  - lib
111
- - ext/oci8
112
111
  required_ruby_version: !ruby/object:Gem::Requirement
113
112
  requirements:
114
- - - '>='
113
+ - - ">="
115
114
  - !ruby/object:Gem::Version
116
- version: 2.0.0
115
+ version: 2.5.0
117
116
  required_rubygems_version: !ruby/object:Gem::Requirement
118
117
  requirements:
119
- - - '>='
118
+ - - ">="
120
119
  - !ruby/object:Gem::Version
121
120
  version: '0'
122
121
  requirements: []
123
122
  rubyforge_project:
124
- rubygems_version: 2.0.0
123
+ rubygems_version: 2.7.3
125
124
  signing_key:
126
125
  specification_version: 4
127
126
  summary: Ruby interface for Oracle using OCI8 API
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++.)