ruby-plsql 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +8 -6
- data/History.txt +14 -0
- data/README.md +28 -5
- data/Rakefile +4 -3
- data/VERSION +1 -1
- data/lib/plsql/jdbc_connection.rb +6 -4
- data/lib/plsql/oci_connection.rb +10 -1
- data/lib/plsql/procedure.rb +23 -8
- data/lib/plsql/schema.rb +10 -1
- data/ruby-plsql.gemspec +24 -20
- data/spec/plsql/connection_spec.rb +97 -97
- data/spec/plsql/package_spec.rb +9 -9
- data/spec/plsql/procedure_spec.rb +192 -192
- data/spec/plsql/schema_spec.rb +47 -46
- data/spec/plsql/sequence_spec.rb +7 -7
- data/spec/plsql/sql_statements_spec.rb +10 -10
- data/spec/plsql/table_spec.rb +50 -50
- data/spec/plsql/type_spec.rb +40 -39
- data/spec/plsql/variable_spec.rb +52 -52
- data/spec/plsql/version_spec.rb +1 -1
- data/spec/plsql/view_spec.rb +41 -41
- data/spec/spec_helper.rb +40 -17
- metadata +73 -41
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ce8ef00f5273841d619be6cb08c25d09abd45078
|
4
|
+
data.tar.gz: f77984b605d43abeec8805ad021fc329cbc011a3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: daceb0231b71f9f41e782d66f07327dea768c84be2925de9ef4ba8054d086be372ea19579a77399fcc03ef1cb67d85d8fecd5dd46b54bafaad4272c1d0b309f8
|
7
|
+
data.tar.gz: 6b300a47e477130f096af709b4c70b56f421981989d4b761c4559d02f1a975e32f57879639502f19d8aba6bc5d76a4589ac06862149d10746332c710e0ca19b9
|
data/Gemfile
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
3
|
group :development do
|
4
|
-
gem 'jeweler', '~>
|
5
|
-
gem 'rspec', '~>
|
4
|
+
gem 'jeweler', '~> 2.0.1'
|
5
|
+
gem 'rspec', '~> 3.1'
|
6
6
|
|
7
7
|
unless ENV['NO_ACTIVERECORD']
|
8
|
-
gem 'activerecord', '
|
9
|
-
gem 'activerecord-oracle_enhanced-adapter', '
|
8
|
+
gem 'activerecord', '>= 3.2.3', '< 4.2.0'
|
9
|
+
gem 'activerecord-oracle_enhanced-adapter', '>= 1.4.1', '< 1.6.0'
|
10
|
+
gem 'simplecov', '>= 0'
|
10
11
|
end
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
platforms :ruby do
|
14
|
+
gem 'ruby-oci8', '~> 2.1.2'
|
15
|
+
end
|
14
16
|
end
|
data/History.txt
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
== 0.5.1 2014-10-12
|
2
|
+
* Improvements
|
3
|
+
* Support for Oracle Ehnanced Adapter 1.5 and ActiveRecord 4.1, 4.2
|
4
|
+
* Oracle 12c support
|
5
|
+
* Better diagnostics output when ruby-oci8 initialization fails
|
6
|
+
* Bug fixes
|
7
|
+
* Support for ruby-oci8 2.1.2+ preventing segfaults
|
8
|
+
* Multi-thread support (applies to oci8 connections)
|
9
|
+
* Internal (development) improvements
|
10
|
+
* Tests database connection enhancements (eazy connect syntax, allow service name != db name)
|
11
|
+
* Tests migrated to rspec 3
|
12
|
+
* Tests coverage migrated from rcov to simplecov
|
13
|
+
* README update with how to run tests
|
14
|
+
|
1
15
|
== 0.5.0 2012-04-16
|
2
16
|
|
3
17
|
* Improvements
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ ruby-plsql gem provides simple Ruby API for calling Oracle PL/SQL procedures. It
|
|
10
10
|
|
11
11
|
NUMBER, BINARY_INTEGER, PLS_INTEGER, VARCHAR2, NVARCHAR2, CHAR, NCHAR, DATE, TIMESTAMP, CLOB, BLOB, BOOLEAN, PL/SQL RECORD, TABLE, VARRAY, OBJECT and CURSOR types are supported for input and output parameters and return values of PL/SQL procedures and functions.
|
12
12
|
|
13
|
-
ruby-plsql supports Ruby 1.8.7, 1.9.3 and JRuby 1.6.7 implementations.
|
13
|
+
ruby-plsql supports Ruby 1.8.7, 1.9.3, 2.1.3 and JRuby 1.6.7, 1.7.16 implementations.
|
14
14
|
|
15
15
|
USAGE
|
16
16
|
-----
|
@@ -127,16 +127,38 @@ or include gem in Gemfile if using bundler.
|
|
127
127
|
|
128
128
|
In addition install either ruby-oci8 (for MRI/YARV) or copy Oracle JDBC driver to $JRUBY_HOME/lib (for JRuby).
|
129
129
|
|
130
|
-
If you are using MRI 1.8
|
130
|
+
If you are using MRI 1.8, 1.9 or 2.x Ruby implementation then you need to install ruby-oci8 gem (version 2.0.x or 2.1.x)
|
131
131
|
as well as Oracle client, e.g. [Oracle Instant Client](http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html).
|
132
132
|
|
133
|
-
If you are using JRuby then you need to download latest [Oracle JDBC driver](http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html) - either ojdbc6.jar for Java 6 or ojdbc5.jar for Java 5. And copy this file to one of these locations:
|
133
|
+
If you are using JRuby then you need to download latest [Oracle JDBC driver](http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html) - either ojdbc6.jar for Java 6, 7, 8 or ojdbc5.jar for Java 5. And copy this file to one of these locations:
|
134
134
|
|
135
135
|
* in `./lib` directory of Rails application and require it manually
|
136
136
|
* in some directory which is in `PATH`
|
137
137
|
* in `JRUBY_HOME/lib` directory
|
138
138
|
* or include path to JDBC driver jar file in Java `CLASSPATH`
|
139
139
|
|
140
|
+
TESTS
|
141
|
+
-----
|
142
|
+
|
143
|
+
* Create Oracle database schema for test purposes. Review `spec/spec_helper.rb` to see default schema/user names and database names (use environment variables to override defaults)
|
144
|
+
|
145
|
+
SQL> CREATE USER hr IDENTIFIED BY hr;
|
146
|
+
SQL> GRANT unlimited tablespace, create session, create table, create sequence, create procedure, create type, create view, create synonym TO hr;
|
147
|
+
|
148
|
+
SQL> CREATE USER arunit IDENTIFIED BY arunit;
|
149
|
+
SQL> GRANT create session TO arunit;
|
150
|
+
|
151
|
+
* Install bundler with
|
152
|
+
|
153
|
+
gem install bundler
|
154
|
+
|
155
|
+
* Install necessary gems with
|
156
|
+
|
157
|
+
bundle install
|
158
|
+
|
159
|
+
* Run tests with
|
160
|
+
|
161
|
+
rake spec
|
140
162
|
|
141
163
|
LINKS
|
142
164
|
-----
|
@@ -154,13 +176,14 @@ CONTRIBUTORS
|
|
154
176
|
* Wiehann Matthysen
|
155
177
|
* Dayle Larson
|
156
178
|
* Yasuo Honda
|
179
|
+
* Yavor Nikolov
|
157
180
|
|
158
181
|
LICENSE
|
159
182
|
-------
|
160
183
|
|
161
184
|
(The MIT License)
|
162
185
|
|
163
|
-
Copyright (c) 2008-
|
186
|
+
Copyright (c) 2008-2014 Raimonds Simanovskis
|
164
187
|
|
165
188
|
Permission is hereby granted, free of charge, to any person obtaining
|
166
189
|
a copy of this software and associated documentation files (the
|
@@ -179,4 +202,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
179
202
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
180
203
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
181
204
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
182
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
205
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -29,9 +29,10 @@ Jeweler::RubygemsDotOrgTasks.new
|
|
29
29
|
require 'rspec/core/rake_task'
|
30
30
|
RSpec::Core::RakeTask.new(:spec)
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
desc "Code coverage detail"
|
33
|
+
task :simplecov do
|
34
|
+
ENV['COVERAGE'] = "true"
|
35
|
+
Rake::Task['spec'].execute
|
35
36
|
end
|
36
37
|
|
37
38
|
task :default => :spec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
@@ -39,10 +39,12 @@ module PLSQL
|
|
39
39
|
class JDBCConnection < Connection #:nodoc:
|
40
40
|
|
41
41
|
def self.create_raw(params)
|
42
|
-
|
43
|
-
|
42
|
+
database = params[:database]
|
43
|
+
url = if ENV['TNS_ADMIN'] && database && !params[:host] && !params[:url]
|
44
|
+
"jdbc:oracle:thin:@#{database}"
|
44
45
|
else
|
45
|
-
|
46
|
+
database = ":#{database}" unless database.match(/^(\:|\/)/)
|
47
|
+
params[:url] || "jdbc:oracle:thin:@#{params[:host] || 'localhost'}:#{params[:port] || 1521}#{database}"
|
46
48
|
end
|
47
49
|
new(java.sql.DriverManager.getConnection(url, params[:username], params[:password]))
|
48
50
|
end
|
@@ -539,4 +541,4 @@ module PLSQL
|
|
539
541
|
|
540
542
|
end
|
541
543
|
|
542
|
-
end
|
544
|
+
end
|
data/lib/plsql/oci_connection.rb
CHANGED
@@ -2,7 +2,16 @@ begin
|
|
2
2
|
require "oci8"
|
3
3
|
rescue LoadError
|
4
4
|
# OCI8 driver is unavailable.
|
5
|
-
|
5
|
+
msg = $!.to_s
|
6
|
+
if /-- oci8$/ =~ msg
|
7
|
+
# ruby-oci8 is not installed.
|
8
|
+
# MRI <= 1.9.2, Rubinius, JRuby:
|
9
|
+
# no such file to load -- oci8
|
10
|
+
# MRI >= 1.9.3:
|
11
|
+
# cannot load such file -- oci8
|
12
|
+
msg = "Please install ruby-oci8 gem."
|
13
|
+
end
|
14
|
+
raise LoadError, "ERROR: ruby-plsql could not load ruby-oci8 library. #{msg}"
|
6
15
|
end
|
7
16
|
|
8
17
|
require "plsql/oci8_patches"
|
data/lib/plsql/procedure.rb
CHANGED
@@ -4,21 +4,28 @@ module PLSQL
|
|
4
4
|
def find(schema, procedure, package = nil, override_schema_name = nil)
|
5
5
|
if package.nil?
|
6
6
|
if (row = schema.select_first(
|
7
|
-
"SELECT object_id
|
8
|
-
|
9
|
-
|
10
|
-
AND
|
7
|
+
"SELECT #{procedure_object_id_src(schema)}.object_id
|
8
|
+
FROM all_procedures p, all_objects o
|
9
|
+
WHERE p.owner = :owner
|
10
|
+
AND p.object_name = :object_name
|
11
|
+
AND o.owner = p.owner
|
12
|
+
AND o.object_name = p.object_name
|
13
|
+
AND o.object_type = p.object_type
|
14
|
+
AND o.object_type in ('PROCEDURE', 'FUNCTION')",
|
11
15
|
schema.schema_name, procedure.to_s.upcase))
|
12
16
|
new(schema, procedure, nil, nil, row[0])
|
13
17
|
# search for synonym
|
14
18
|
elsif (row = schema.select_first(
|
15
|
-
"SELECT o.owner, o.object_name,
|
16
|
-
FROM all_synonyms s, all_objects o
|
19
|
+
"SELECT o.owner, o.object_name, #{procedure_object_id_src(schema)}.object_id
|
20
|
+
FROM all_synonyms s, all_objects o, all_procedures p
|
17
21
|
WHERE s.owner IN (:owner, 'PUBLIC')
|
18
22
|
AND s.synonym_name = :synonym_name
|
19
23
|
AND o.owner = s.table_owner
|
20
24
|
AND o.object_name = s.table_name
|
21
25
|
AND o.object_type IN ('PROCEDURE','FUNCTION')
|
26
|
+
AND o.owner = p.owner
|
27
|
+
AND o.object_name = p.object_name
|
28
|
+
AND o.object_type = p.object_type
|
22
29
|
ORDER BY DECODE(s.owner, 'PUBLIC', 1, 0)",
|
23
30
|
schema.schema_name, procedure.to_s.upcase))
|
24
31
|
new(schema, row[1], nil, row[0], row[2])
|
@@ -27,12 +34,14 @@ module PLSQL
|
|
27
34
|
end
|
28
35
|
elsif package && (row = schema.select_first(
|
29
36
|
# older Oracle versions do not have object_id column in all_procedures
|
30
|
-
"SELECT
|
37
|
+
"SELECT #{procedure_object_id_src(schema)}.object_id
|
38
|
+
FROM all_procedures p, all_objects o
|
31
39
|
WHERE p.owner = :owner
|
32
40
|
AND p.object_name = :object_name
|
33
41
|
AND p.procedure_name = :procedure_name
|
34
42
|
AND o.owner = p.owner
|
35
43
|
AND o.object_name = p.object_name
|
44
|
+
AND o.object_type = p.object_type
|
36
45
|
AND o.object_type = 'PACKAGE'",
|
37
46
|
override_schema_name || schema.schema_name, package, procedure.to_s.upcase))
|
38
47
|
new(schema, procedure, package, override_schema_name, row[0])
|
@@ -40,6 +49,12 @@ module PLSQL
|
|
40
49
|
nil
|
41
50
|
end
|
42
51
|
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def procedure_object_id_src(schema)
|
56
|
+
(schema.connection.database_version <=> [11, 1, 0, 0]) >= 0 ? "p" : "o"
|
57
|
+
end
|
43
58
|
end
|
44
59
|
|
45
60
|
module ProcedureCommon #:nodoc:
|
@@ -254,4 +269,4 @@ module PLSQL
|
|
254
269
|
|
255
270
|
end
|
256
271
|
|
257
|
-
end
|
272
|
+
end
|
data/lib/plsql/schema.rb
CHANGED
@@ -41,7 +41,7 @@ module PLSQL
|
|
41
41
|
# or
|
42
42
|
#
|
43
43
|
# plsql.connection = java.sql.DriverManager.getConnection(
|
44
|
-
# "jdbc:oracle:thin:@#{database_host}:#{database_port}
|
44
|
+
# "jdbc:oracle:thin:@#{database_host}:#{database_port}/#{database_service_name}",
|
45
45
|
# database_user, database_password)
|
46
46
|
#
|
47
47
|
def connection=(conn)
|
@@ -210,6 +210,15 @@ module PLSQL
|
|
210
210
|
_errors(object_schema_name, object_name, 'PACKAGE BODY')}" if body_status == 'INVALID'
|
211
211
|
case object_type
|
212
212
|
when 'PROCEDURE', 'FUNCTION'
|
213
|
+
if (connection.database_version <=> [11, 1, 0, 0]) >= 0
|
214
|
+
row = select_first(
|
215
|
+
"SELECT p.object_id FROM all_procedures p
|
216
|
+
WHERE p.owner = :owner
|
217
|
+
AND p.object_name = :object_name
|
218
|
+
AND p.object_type = :object_type",
|
219
|
+
object_schema_name, object_name, object_type)
|
220
|
+
object_id = row[0]
|
221
|
+
end
|
213
222
|
Procedure.new(self, name, nil, override_schema_name, object_id)
|
214
223
|
when 'PACKAGE'
|
215
224
|
Package.new(self, name, override_schema_name)
|
data/ruby-plsql.gemspec
CHANGED
@@ -2,14 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: ruby-plsql 0.5.1 ruby lib
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
8
|
s.name = "ruby-plsql"
|
8
|
-
s.version = "0.5.
|
9
|
+
s.version = "0.5.1"
|
9
10
|
|
10
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
11
13
|
s.authors = ["Raimonds Simanovskis"]
|
12
|
-
s.date = "
|
14
|
+
s.date = "2014-10-12"
|
13
15
|
s.description = "ruby-plsql gem provides simple Ruby API for calling Oracle PL/SQL procedures.\nIt could be used both for accessing Oracle PL/SQL API procedures in legacy applications\nas well as it could be used to create PL/SQL unit tests using Ruby testing libraries.\n"
|
14
16
|
s.email = "raimonds.simanovskis@gmail.com"
|
15
17
|
s.extra_rdoc_files = [
|
@@ -56,32 +58,34 @@ Gem::Specification.new do |s|
|
|
56
58
|
"spec/spec_helper.rb"
|
57
59
|
]
|
58
60
|
s.homepage = "http://github.com/rsim/ruby-plsql"
|
59
|
-
s.
|
60
|
-
s.rubygems_version = "1.8.11"
|
61
|
+
s.rubygems_version = "2.2.2"
|
61
62
|
s.summary = "Ruby API for calling Oracle PL/SQL procedures."
|
62
63
|
|
63
64
|
if s.respond_to? :specification_version then
|
64
|
-
s.specification_version =
|
65
|
+
s.specification_version = 4
|
65
66
|
|
66
67
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
67
|
-
s.add_development_dependency(%q<jeweler>, ["~>
|
68
|
-
s.add_development_dependency(%q<rspec>, ["~>
|
69
|
-
s.add_development_dependency(%q<activerecord>, ["
|
70
|
-
s.add_development_dependency(%q<activerecord-oracle_enhanced-adapter>, ["
|
71
|
-
s.add_development_dependency(%q<
|
68
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
69
|
+
s.add_development_dependency(%q<rspec>, ["~> 3.1"])
|
70
|
+
s.add_development_dependency(%q<activerecord>, ["< 4.2.0", ">= 3.2.3"])
|
71
|
+
s.add_development_dependency(%q<activerecord-oracle_enhanced-adapter>, ["< 1.6.0", ">= 1.4.1"])
|
72
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
73
|
+
s.add_development_dependency(%q<ruby-oci8>, ["~> 2.1.2"])
|
72
74
|
else
|
73
|
-
s.add_dependency(%q<jeweler>, ["~>
|
74
|
-
s.add_dependency(%q<rspec>, ["~>
|
75
|
-
s.add_dependency(%q<activerecord>, ["
|
76
|
-
s.add_dependency(%q<activerecord-oracle_enhanced-adapter>, ["
|
77
|
-
s.add_dependency(%q<
|
75
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
76
|
+
s.add_dependency(%q<rspec>, ["~> 3.1"])
|
77
|
+
s.add_dependency(%q<activerecord>, ["< 4.2.0", ">= 3.2.3"])
|
78
|
+
s.add_dependency(%q<activerecord-oracle_enhanced-adapter>, ["< 1.6.0", ">= 1.4.1"])
|
79
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
80
|
+
s.add_dependency(%q<ruby-oci8>, ["~> 2.1.2"])
|
78
81
|
end
|
79
82
|
else
|
80
|
-
s.add_dependency(%q<jeweler>, ["~>
|
81
|
-
s.add_dependency(%q<rspec>, ["~>
|
82
|
-
s.add_dependency(%q<activerecord>, ["
|
83
|
-
s.add_dependency(%q<activerecord-oracle_enhanced-adapter>, ["
|
84
|
-
s.add_dependency(%q<
|
83
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
84
|
+
s.add_dependency(%q<rspec>, ["~> 3.1"])
|
85
|
+
s.add_dependency(%q<activerecord>, ["< 4.2.0", ">= 3.2.3"])
|
86
|
+
s.add_dependency(%q<activerecord-oracle_enhanced-adapter>, ["< 1.6.0", ">= 1.4.1"])
|
87
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
88
|
+
s.add_dependency(%q<ruby-oci8>, ["~> 2.1.2"])
|
85
89
|
end
|
86
90
|
end
|
87
91
|
|
@@ -29,23 +29,23 @@ describe "Connection" do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should create connection" do
|
32
|
-
@conn1.raw_connection.
|
32
|
+
expect(@conn1.raw_connection).to eq @raw_conn1
|
33
33
|
end
|
34
34
|
|
35
35
|
unless defined?(JRuby)
|
36
36
|
it "should be oci connection" do
|
37
|
-
@conn1.
|
38
|
-
@conn1.raw_driver.
|
37
|
+
expect(@conn1).to be_oci
|
38
|
+
expect(@conn1.raw_driver).to eq :oci
|
39
39
|
end
|
40
40
|
else
|
41
41
|
it "should be jdbc connection" do
|
42
|
-
@conn1.
|
43
|
-
@conn1.raw_driver.
|
42
|
+
expect(@conn1).to be_jdbc
|
43
|
+
expect(@conn1.raw_driver).to eq :jdbc
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should logoff connection" do
|
48
|
-
@conn1.logoff.
|
48
|
+
expect(@conn1.logoff).to be true
|
49
49
|
end
|
50
50
|
|
51
51
|
end
|
@@ -54,68 +54,68 @@ describe "Connection" do
|
|
54
54
|
unless defined?(JRuby)
|
55
55
|
describe "OCI data type conversions" do
|
56
56
|
it "should translate PL/SQL VARCHAR2 to Ruby String" do
|
57
|
-
@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR2", :data_length => 100).
|
58
|
-
@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR2", :data_length => nil).
|
57
|
+
expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR2", :data_length => 100)).to eq [String, 100]
|
58
|
+
expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR2", :data_length => nil)).to eq [String, 32767]
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should translate PL/SQL CLOB to Ruby String" do
|
62
|
-
@conn.plsql_to_ruby_data_type(:data_type => "CLOB", :data_length => 100_000).
|
63
|
-
@conn.plsql_to_ruby_data_type(:data_type => "CLOB", :data_length => nil).
|
62
|
+
expect(@conn.plsql_to_ruby_data_type(:data_type => "CLOB", :data_length => 100_000)).to eq [OCI8::CLOB, nil]
|
63
|
+
expect(@conn.plsql_to_ruby_data_type(:data_type => "CLOB", :data_length => nil)).to eq [OCI8::CLOB, nil]
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should translate PL/SQL NUMBER to Ruby OraNumber" do
|
67
|
-
@conn.plsql_to_ruby_data_type(:data_type => "NUMBER", :data_length => 15).
|
67
|
+
expect(@conn.plsql_to_ruby_data_type(:data_type => "NUMBER", :data_length => 15)).to eq [OraNumber, nil]
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should translate PL/SQL DATE to Ruby DateTime" do
|
71
|
-
@conn.plsql_to_ruby_data_type(:data_type => "DATE", :data_length => nil).
|
71
|
+
expect(@conn.plsql_to_ruby_data_type(:data_type => "DATE", :data_length => nil)).to eq [DateTime, nil]
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should translate PL/SQL TIMESTAMP to Ruby Time" do
|
75
|
-
@conn.plsql_to_ruby_data_type(:data_type => "TIMESTAMP", :data_length => nil).
|
75
|
+
expect(@conn.plsql_to_ruby_data_type(:data_type => "TIMESTAMP", :data_length => nil)).to eq [Time, nil]
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should not translate Ruby Fixnum when OraNumber type specified" do
|
79
|
-
@conn.ruby_value_to_ora_value(100, OraNumber).
|
79
|
+
expect(@conn.ruby_value_to_ora_value(100, OraNumber)).to eql(100)
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should translate Ruby Bignum value to OraNumber when OraNumber type specified" do
|
83
83
|
ora_number = @conn.ruby_value_to_ora_value(12345678901234567890, OraNumber)
|
84
|
-
ora_number.class.
|
85
|
-
ora_number.to_s.
|
84
|
+
expect(ora_number.class).to eq OraNumber
|
85
|
+
expect(ora_number.to_s).to eq "12345678901234567890"
|
86
86
|
# OraNumber has more numeric comparison methods in ruby-oci8 2.0
|
87
|
-
ora_number.
|
87
|
+
expect(ora_number).to eq OraNumber.new("12345678901234567890") if OCI8::VERSION >= '2.0.0'
|
88
88
|
end
|
89
89
|
|
90
90
|
it "should translate Ruby String value to OCI8::CLOB when OCI8::CLOB type specified" do
|
91
91
|
large_text = "x" * 100_000
|
92
92
|
ora_value = @conn.ruby_value_to_ora_value(large_text, OCI8::CLOB)
|
93
|
-
ora_value.class.
|
94
|
-
ora_value.size.
|
93
|
+
expect(ora_value.class).to eq OCI8::CLOB
|
94
|
+
expect(ora_value.size).to eq 100_000
|
95
95
|
ora_value.rewind
|
96
|
-
ora_value.read.
|
96
|
+
expect(ora_value.read).to eq large_text
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should translate Oracle OraNumber integer value to Fixnum" do
|
100
|
-
@conn.ora_value_to_ruby_value(OraNumber.new(100)).
|
100
|
+
expect(@conn.ora_value_to_ruby_value(OraNumber.new(100))).to eql(100)
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should translate Oracle OraNumber float value to BigDecimal" do
|
104
|
-
@conn.ora_value_to_ruby_value(OraNumber.new(100.11)).
|
104
|
+
expect(@conn.ora_value_to_ruby_value(OraNumber.new(100.11))).to eql(BigDecimal("100.11"))
|
105
105
|
end
|
106
106
|
|
107
107
|
# ruby-oci8 2.0 returns DATE as Time or DateTime
|
108
108
|
if OCI8::VERSION < '2.0.0'
|
109
109
|
it "should translate Oracle OraDate value to Time" do
|
110
110
|
now = OraDate.now
|
111
|
-
@conn.ora_value_to_ruby_value(now).
|
111
|
+
expect(@conn.ora_value_to_ruby_value(now)).to eql(now.to_time)
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
115
|
it "should translate Oracle CLOB value to String" do
|
116
116
|
large_text = "x" * 100_000
|
117
117
|
clob = OCI8::CLOB.new(@raw_conn, large_text)
|
118
|
-
@conn.ora_value_to_ruby_value(clob).
|
118
|
+
expect(@conn.ora_value_to_ruby_value(clob)).to eq large_text
|
119
119
|
end
|
120
120
|
|
121
121
|
end
|
@@ -125,63 +125,63 @@ describe "Connection" do
|
|
125
125
|
|
126
126
|
describe "JDBC data type conversions" do
|
127
127
|
it "should translate PL/SQL VARCHAR2 to Ruby String" do
|
128
|
-
@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR2", :data_length => 100).
|
129
|
-
@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR2", :data_length => nil).
|
128
|
+
expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR2", :data_length => 100)).to eq [String, 100]
|
129
|
+
expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR2", :data_length => nil)).to eq [String, 32767]
|
130
130
|
end
|
131
131
|
|
132
132
|
it "should translate PL/SQL NUMBER to Ruby BigDecimal" do
|
133
|
-
@conn.plsql_to_ruby_data_type(:data_type => "NUMBER", :data_length => 15).
|
133
|
+
expect(@conn.plsql_to_ruby_data_type(:data_type => "NUMBER", :data_length => 15)).to eq [BigDecimal, nil]
|
134
134
|
end
|
135
135
|
|
136
136
|
it "should translate PL/SQL DATE to Ruby DateTime" do
|
137
|
-
@conn.plsql_to_ruby_data_type(:data_type => "DATE", :data_length => nil).
|
137
|
+
expect(@conn.plsql_to_ruby_data_type(:data_type => "DATE", :data_length => nil)).to eq [DateTime, nil]
|
138
138
|
end
|
139
139
|
|
140
140
|
it "should translate PL/SQL TIMESTAMP to Ruby Time" do
|
141
|
-
@conn.plsql_to_ruby_data_type(:data_type => "TIMESTAMP", :data_length => nil).
|
141
|
+
expect(@conn.plsql_to_ruby_data_type(:data_type => "TIMESTAMP", :data_length => nil)).to eq [Time, nil]
|
142
142
|
end
|
143
143
|
|
144
144
|
it "should not translate Ruby Fixnum when BigDecimal type specified" do
|
145
|
-
@conn.ruby_value_to_ora_value(100, BigDecimal).
|
145
|
+
expect(@conn.ruby_value_to_ora_value(100, BigDecimal)).to eq java.math.BigDecimal.new(100)
|
146
146
|
end
|
147
147
|
|
148
148
|
it "should translate Ruby Bignum value to BigDecimal when BigDecimal type specified" do
|
149
149
|
big_decimal = @conn.ruby_value_to_ora_value(12345678901234567890, BigDecimal)
|
150
|
-
big_decimal.
|
150
|
+
expect(big_decimal).to eq java.math.BigDecimal.new("12345678901234567890")
|
151
151
|
end
|
152
152
|
|
153
153
|
it "should translate Ruby String value to Java::OracleSql::CLOB when Java::OracleSql::CLOB type specified" do
|
154
154
|
large_text = "x" * 100_000
|
155
155
|
ora_value = @conn.ruby_value_to_ora_value(large_text, Java::OracleSql::CLOB)
|
156
|
-
ora_value.class.
|
157
|
-
ora_value.length.
|
158
|
-
ora_value.getSubString(1, ora_value.length)
|
156
|
+
expect(ora_value.class).to eq Java::OracleSql::CLOB
|
157
|
+
expect(ora_value.length).to eq 100_000
|
158
|
+
expect(ora_value.getSubString(1, ora_value.length)).to eq large_text
|
159
159
|
ora_value.freeTemporary
|
160
160
|
end
|
161
161
|
|
162
162
|
it "should translate Ruby nil value to nil when Java::OracleSql::CLOB type specified" do
|
163
163
|
ora_value = @conn.ruby_value_to_ora_value(nil, Java::OracleSql::CLOB)
|
164
|
-
ora_value.
|
164
|
+
expect(ora_value).to be_nil
|
165
165
|
end
|
166
166
|
|
167
167
|
it "should translate Oracle BigDecimal integer value to Fixnum" do
|
168
|
-
@conn.ora_value_to_ruby_value(BigDecimal("100")).
|
168
|
+
expect(@conn.ora_value_to_ruby_value(BigDecimal("100"))).to eql(100)
|
169
169
|
end
|
170
170
|
|
171
171
|
it "should translate Oracle BigDecimal float value to BigDecimal" do
|
172
|
-
@conn.ora_value_to_ruby_value(BigDecimal("100.11")).
|
172
|
+
expect(@conn.ora_value_to_ruby_value(BigDecimal("100.11"))).to eql(BigDecimal("100.11"))
|
173
173
|
end
|
174
174
|
|
175
175
|
it "should translate Oracle CLOB value to String" do
|
176
176
|
large_text = "āčē" * 100_000
|
177
177
|
clob = @conn.ruby_value_to_ora_value(large_text, Java::OracleSql::CLOB)
|
178
|
-
@conn.ora_value_to_ruby_value(clob).
|
178
|
+
expect(@conn.ora_value_to_ruby_value(clob)).to eq large_text
|
179
179
|
clob.freeTemporary
|
180
180
|
end
|
181
181
|
|
182
182
|
it "should translate empty Oracle CLOB value to nil" do
|
183
183
|
clob = @conn.ruby_value_to_ora_value(nil, Java::OracleSql::CLOB)
|
184
|
-
@conn.ora_value_to_ruby_value(clob).
|
184
|
+
expect(@conn.ora_value_to_ruby_value(clob)).to be_nil
|
185
185
|
end
|
186
186
|
|
187
187
|
end
|
@@ -192,30 +192,30 @@ describe "Connection" do
|
|
192
192
|
|
193
193
|
it "should execute SQL statement and return first result" do
|
194
194
|
@now = Time.local(2008,05,31,23,22,11)
|
195
|
-
@conn.select_first("SELECT 'abc',123,123.456,
|
195
|
+
expect(@conn.select_first("SELECT 'abc',123,123.456,
|
196
196
|
TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}','YYYY-MM-DD HH24:MI:SS')
|
197
|
-
FROM dual").
|
197
|
+
FROM dual")).to eq ["abc",123,123.456,@now]
|
198
198
|
end
|
199
199
|
|
200
200
|
it "should execute SQL statement and return first result as hash" do
|
201
201
|
@now = Time.local(2008,05,31,23,22,11)
|
202
|
-
@conn.select_hash_first("SELECT 'abc' a, 123 b, 123.456 c,
|
202
|
+
expect(@conn.select_hash_first("SELECT 'abc' a, 123 b, 123.456 c,
|
203
203
|
TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}', 'YYYY-MM-DD HH24:MI:SS') d
|
204
|
-
FROM dual").
|
204
|
+
FROM dual")).to eq({:a => "abc", :b => 123, :c => 123.456, :d => @now})
|
205
205
|
end
|
206
206
|
|
207
207
|
it "should execute SQL statement with bind parameters and return first result" do
|
208
208
|
@today = Date.parse("2008-05-31")
|
209
209
|
@now = Time.local(2008,05,31,23,22,11)
|
210
|
-
@conn.select_first("SELECT :1,:2,:3,:4,:5 FROM dual",
|
211
|
-
'abc',123,123.456,@now,@today).
|
210
|
+
expect(@conn.select_first("SELECT :1,:2,:3,:4,:5 FROM dual",
|
211
|
+
'abc',123,123.456,@now,@today)).to eq ["abc",123,123.456,@now,Time.parse(@today.to_s)]
|
212
212
|
end
|
213
213
|
|
214
214
|
it "should execute SQL statement with NULL values and return first result" do
|
215
215
|
@now = Time.local(2008,05,31,23,22,11)
|
216
|
-
@conn.select_first("SELECT NULL,123,123.456,
|
216
|
+
expect(@conn.select_first("SELECT NULL,123,123.456,
|
217
217
|
TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}','YYYY-MM-DD HH24:MI:SS')
|
218
|
-
FROM dual").
|
218
|
+
FROM dual")).to eq [nil,123,123.456,@now]
|
219
219
|
end
|
220
220
|
|
221
221
|
if defined?(JRuby)
|
@@ -223,56 +223,56 @@ describe "Connection" do
|
|
223
223
|
it "should execute SQL statement with NULL values as bind parameters and return first result" do
|
224
224
|
@today = Date.parse("2008-05-31")
|
225
225
|
@now = Time.local(2008,05,31,23,22,11)
|
226
|
-
@conn.select_first("SELECT :1,:2,:3,:4,:5 FROM dual",
|
227
|
-
nil,123,123.456,@now,@today).
|
226
|
+
expect(@conn.select_first("SELECT :1,:2,:3,:4,:5 FROM dual",
|
227
|
+
nil,123,123.456,@now,@today)).to eq [nil,123,123.456,@now,Time.parse(@today.to_s)]
|
228
228
|
end
|
229
229
|
|
230
230
|
end
|
231
231
|
|
232
232
|
it "should execute SQL statement and return all results" do
|
233
233
|
@now = Time.local(2008,05,31,23,22,11)
|
234
|
-
@conn.select_all("SELECT 'abc',123,123.456,
|
234
|
+
expect(@conn.select_all("SELECT 'abc',123,123.456,
|
235
235
|
TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}','YYYY-MM-DD HH24:MI:SS')
|
236
236
|
FROM dual
|
237
237
|
UNION ALL SELECT 'abc',123,123.456,
|
238
238
|
TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}','YYYY-MM-DD HH24:MI:SS')
|
239
|
-
FROM dual").
|
239
|
+
FROM dual")).to eq [["abc",123,123.456,@now],["abc",123,123.456,@now]]
|
240
240
|
end
|
241
241
|
|
242
242
|
it "should execute SQL statement and return all results as hash" do
|
243
243
|
@now = Time.local(2008,05,31,23,22,11)
|
244
|
-
@conn.select_hash_all("SELECT 'abc' a, 123 b, 123.456 c,
|
244
|
+
expect(@conn.select_hash_all("SELECT 'abc' a, 123 b, 123.456 c,
|
245
245
|
TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}','YYYY-MM-DD HH24:MI:SS') d
|
246
246
|
FROM dual
|
247
247
|
UNION ALL SELECT 'def' a, 123 b, 123.456 c,
|
248
248
|
TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}','YYYY-MM-DD HH24:MI:SS') d
|
249
|
-
FROM dual").
|
249
|
+
FROM dual")).to eq [{:a=>"abc",:b=>123,:c=>123.456,:d=>@now},{:a=>"def",:b=>123,:c=>123.456,:d=>@now}]
|
250
250
|
end
|
251
251
|
|
252
252
|
it "should execute SQL statement with bind parameters and return all results" do
|
253
253
|
@now = Time.local(2008,05,31,23,22,11)
|
254
|
-
@conn.select_all("SELECT :1,:2,:3,:4 FROM dual UNION ALL SELECT :1,:2,:3,:4 FROM dual",
|
255
|
-
'abc',123,123.456,@now,'abc',123,123.456,@now).
|
254
|
+
expect(@conn.select_all("SELECT :1,:2,:3,:4 FROM dual UNION ALL SELECT :1,:2,:3,:4 FROM dual",
|
255
|
+
'abc',123,123.456,@now,'abc',123,123.456,@now)).to eq [["abc",123,123.456,@now],["abc",123,123.456,@now]]
|
256
256
|
end
|
257
257
|
|
258
258
|
it "should execute SQL statement and yield all results in block" do
|
259
259
|
@now = Time.local(2008,05,31,23,22,11)
|
260
|
-
@conn.select_all("SELECT 'abc',123,123.456,
|
260
|
+
expect(@conn.select_all("SELECT 'abc',123,123.456,
|
261
261
|
TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}','YYYY-MM-DD HH24:MI:SS')
|
262
262
|
FROM dual
|
263
263
|
UNION ALL SELECT 'abc',123,123.456,
|
264
264
|
TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}','YYYY-MM-DD HH24:MI:SS')
|
265
265
|
FROM dual") do |r|
|
266
|
-
r.
|
267
|
-
end.
|
266
|
+
expect(r).to eq ["abc",123,123.456,@now]
|
267
|
+
end).to eq 2
|
268
268
|
end
|
269
269
|
|
270
270
|
it "should execute SQL statement with bind parameters and yield all results in block" do
|
271
271
|
@now = Time.local(2008,05,31,23,22,11)
|
272
|
-
@conn.select_all("SELECT :1,:2,:3,:4 FROM dual UNION ALL SELECT :1,:2,:3,:4 FROM dual",
|
272
|
+
expect(@conn.select_all("SELECT :1,:2,:3,:4 FROM dual UNION ALL SELECT :1,:2,:3,:4 FROM dual",
|
273
273
|
'abc',123,123.456,@now,'abc',123,123.456,@now) do |r|
|
274
|
-
r.
|
275
|
-
end.
|
274
|
+
expect(r).to eq ["abc",123,123.456,@now]
|
275
|
+
end).to eq 2
|
276
276
|
end
|
277
277
|
|
278
278
|
end
|
@@ -289,7 +289,7 @@ describe "Connection" do
|
|
289
289
|
RETURN p_number + #{@random};
|
290
290
|
END test_add_random;
|
291
291
|
SQL
|
292
|
-
@conn.exec(sql).
|
292
|
+
expect(@conn.exec(sql)).to be true
|
293
293
|
end
|
294
294
|
|
295
295
|
after(:all) do
|
@@ -308,19 +308,19 @@ describe "Connection" do
|
|
308
308
|
cursor.bind_param(":p_varchar", "abc", :data_type => 'VARCHAR2', :in_out => 'IN/OUT')
|
309
309
|
cursor.bind_param(":p_date", @now, :data_type => 'DATE', :in_out => 'IN/OUT')
|
310
310
|
cursor.exec
|
311
|
-
cursor[":result"].
|
312
|
-
cursor[":p_varchar"].
|
313
|
-
cursor[":p_date"].
|
314
|
-
cursor.close.
|
311
|
+
expect(cursor[":result"]).to eq @random + 100
|
312
|
+
expect(cursor[":p_varchar"]).to eq "abc"
|
313
|
+
expect(cursor[":p_date"]).to eq @now
|
314
|
+
expect(cursor.close).to be_nil
|
315
315
|
end
|
316
316
|
|
317
317
|
end
|
318
318
|
|
319
319
|
describe "commit and rollback" do
|
320
320
|
before(:all) do
|
321
|
-
@conn.exec("CREATE TABLE test_commit (dummy VARCHAR2(100))").
|
321
|
+
expect(@conn.exec("CREATE TABLE test_commit (dummy VARCHAR2(100))")).to be true
|
322
322
|
@conn.autocommit = false
|
323
|
-
@conn.
|
323
|
+
expect(@conn).not_to be_autocommit
|
324
324
|
end
|
325
325
|
|
326
326
|
after(:all) do
|
@@ -335,20 +335,20 @@ describe "Connection" do
|
|
335
335
|
it "should do commit" do
|
336
336
|
@conn.exec("INSERT INTO test_commit VALUES ('test')")
|
337
337
|
@conn.commit
|
338
|
-
@conn.select_first("SELECT COUNT(*) FROM test_commit")[0].
|
338
|
+
expect(@conn.select_first("SELECT COUNT(*) FROM test_commit")[0]).to eq 1
|
339
339
|
end
|
340
340
|
|
341
341
|
it "should do rollback" do
|
342
342
|
@conn.exec("INSERT INTO test_commit VALUES ('test')")
|
343
343
|
@conn.rollback
|
344
|
-
@conn.select_first("SELECT COUNT(*) FROM test_commit")[0].
|
344
|
+
expect(@conn.select_first("SELECT COUNT(*) FROM test_commit")[0]).to eq 0
|
345
345
|
end
|
346
346
|
|
347
347
|
it "should do commit and rollback should not undo commited transaction" do
|
348
348
|
@conn.exec("INSERT INTO test_commit VALUES ('test')")
|
349
349
|
@conn.commit
|
350
350
|
@conn.rollback
|
351
|
-
@conn.select_first("SELECT COUNT(*) FROM test_commit")[0].
|
351
|
+
expect(@conn.select_first("SELECT COUNT(*) FROM test_commit")[0]).to eq 1
|
352
352
|
end
|
353
353
|
|
354
354
|
end
|
@@ -361,21 +361,21 @@ describe "Connection" do
|
|
361
361
|
it "should set prefetch rows for connection" do
|
362
362
|
sql = "SELECT 1 FROM dual UNION ALL SELECT 1/0 FROM dual"
|
363
363
|
@conn.prefetch_rows = 2
|
364
|
-
|
364
|
+
expect {
|
365
365
|
@conn.cursor_from_query(sql)
|
366
|
-
}.
|
366
|
+
}.to raise_error(/divisor is equal to zero/)
|
367
367
|
@conn.prefetch_rows = 1
|
368
|
-
|
368
|
+
expect {
|
369
369
|
@conn.cursor_from_query(sql)
|
370
|
-
}.
|
370
|
+
}.not_to raise_error
|
371
371
|
end
|
372
372
|
|
373
373
|
it "should fetch just one row when using select_first" do
|
374
374
|
sql = "SELECT 1 FROM dual UNION ALL SELECT 1/0 FROM dual"
|
375
375
|
@conn.prefetch_rows = 2
|
376
|
-
|
376
|
+
expect {
|
377
377
|
@conn.select_first(sql)
|
378
|
-
}.
|
378
|
+
}.not_to raise_error
|
379
379
|
end
|
380
380
|
|
381
381
|
end
|
@@ -390,21 +390,21 @@ describe "Connection" do
|
|
390
390
|
end
|
391
391
|
|
392
392
|
it "should describe local synonym" do
|
393
|
-
@conn.describe_synonym('HR','SYNONYM_FOR_DUAL').
|
394
|
-
@conn.describe_synonym('hr','synonym_for_dual').
|
395
|
-
@conn.describe_synonym(:hr,:synonym_for_dual).
|
393
|
+
expect(@conn.describe_synonym('HR','SYNONYM_FOR_DUAL')).to eq ['SYS', 'DUAL']
|
394
|
+
expect(@conn.describe_synonym('hr','synonym_for_dual')).to eq ['SYS', 'DUAL']
|
395
|
+
expect(@conn.describe_synonym(:hr,:synonym_for_dual)).to eq ['SYS', 'DUAL']
|
396
396
|
end
|
397
397
|
|
398
398
|
it "should return nil on non-existing synonym" do
|
399
|
-
@conn.describe_synonym('HR','SYNONYM_FOR_XXX').
|
400
|
-
@conn.describe_synonym('hr','synonym_for_xxx').
|
401
|
-
@conn.describe_synonym(:hr,:synonym_for_xxx).
|
399
|
+
expect(@conn.describe_synonym('HR','SYNONYM_FOR_XXX')).to be_nil
|
400
|
+
expect(@conn.describe_synonym('hr','synonym_for_xxx')).to be_nil
|
401
|
+
expect(@conn.describe_synonym(:hr,:synonym_for_xxx)).to be_nil
|
402
402
|
end
|
403
403
|
|
404
404
|
it "should describe public synonym" do
|
405
|
-
@conn.describe_synonym('PUBLIC','DUAL').
|
406
|
-
@conn.describe_synonym('PUBLIC','dual').
|
407
|
-
@conn.describe_synonym('PUBLIC',:dual).
|
405
|
+
expect(@conn.describe_synonym('PUBLIC','DUAL')).to eq ['SYS', 'DUAL']
|
406
|
+
expect(@conn.describe_synonym('PUBLIC','dual')).to eq ['SYS', 'DUAL']
|
407
|
+
expect(@conn.describe_synonym('PUBLIC',:dual)).to eq ['SYS', 'DUAL']
|
408
408
|
end
|
409
409
|
|
410
410
|
end
|
@@ -412,11 +412,11 @@ describe "Connection" do
|
|
412
412
|
describe "session information" do
|
413
413
|
it "should get database version" do
|
414
414
|
# using Oracle version 10.2.0.4 for unit tests
|
415
|
-
@conn.database_version.
|
415
|
+
expect(@conn.database_version).to eq DATABASE_VERSION.split('.').map{|n| n.to_i}
|
416
416
|
end
|
417
417
|
|
418
418
|
it "should get session ID" do
|
419
|
-
@conn.session_id.
|
419
|
+
expect(@conn.session_id).to eq @conn.select_first("SELECT USERENV('SESSIONID') FROM dual")[0].to_i
|
420
420
|
end
|
421
421
|
end
|
422
422
|
|
@@ -428,25 +428,25 @@ describe "Connection" do
|
|
428
428
|
it "should drop all ruby temporary tables" do
|
429
429
|
tmp_table = "ruby_111_222_333"
|
430
430
|
@conn.exec "CREATE GLOBAL TEMPORARY TABLE #{tmp_table} (dummy CHAR(1))"
|
431
|
-
|
431
|
+
expect { @conn.select_first("SELECT * FROM #{tmp_table}") }.not_to raise_error
|
432
432
|
@conn.drop_all_ruby_temporary_tables
|
433
|
-
|
433
|
+
expect { @conn.select_first("SELECT * FROM #{tmp_table}") }.to raise_error(/table or view does not exist/)
|
434
434
|
end
|
435
435
|
|
436
436
|
it "should drop current session ruby temporary tables" do
|
437
437
|
tmp_table = "ruby_#{@conn.session_id}_222_333"
|
438
438
|
@conn.exec "CREATE GLOBAL TEMPORARY TABLE #{tmp_table} (dummy CHAR(1))"
|
439
|
-
|
439
|
+
expect { @conn.select_first("SELECT * FROM #{tmp_table}") }.not_to raise_error
|
440
440
|
@conn.drop_session_ruby_temporary_tables
|
441
|
-
|
441
|
+
expect { @conn.select_first("SELECT * FROM #{tmp_table}") }.to raise_error(/table or view does not exist/)
|
442
442
|
end
|
443
443
|
|
444
444
|
it "should not drop other session ruby temporary tables" do
|
445
445
|
tmp_table = "ruby_#{@conn.session_id+1}_222_333"
|
446
446
|
@conn.exec "CREATE GLOBAL TEMPORARY TABLE #{tmp_table} (dummy CHAR(1))"
|
447
|
-
|
447
|
+
expect { @conn.select_first("SELECT * FROM #{tmp_table}") }.not_to raise_error
|
448
448
|
@conn.drop_session_ruby_temporary_tables
|
449
|
-
|
449
|
+
expect { @conn.select_first("SELECT * FROM #{tmp_table}") }.not_to raise_error
|
450
450
|
end
|
451
451
|
|
452
452
|
end
|
@@ -470,10 +470,10 @@ describe "Connection" do
|
|
470
470
|
it "should drop current session ruby temporary tables" do
|
471
471
|
tmp_table = "ruby_#{@conn.session_id}_222_333"
|
472
472
|
@conn.exec "CREATE GLOBAL TEMPORARY TABLE #{tmp_table} (dummy CHAR(1))"
|
473
|
-
|
473
|
+
expect { @conn.select_first("SELECT * FROM #{tmp_table}") }.not_to raise_error
|
474
474
|
@conn.logoff
|
475
475
|
reconnect_connection
|
476
|
-
|
476
|
+
expect { @conn.select_first("SELECT * FROM #{tmp_table}") }.to raise_error(/table or view does not exist/)
|
477
477
|
end
|
478
478
|
|
479
479
|
it "should rollback any uncommited transactions" do
|
@@ -486,7 +486,7 @@ describe "Connection" do
|
|
486
486
|
# logoff will drop ruby temporary tables, it should do rollback before drop table
|
487
487
|
@conn.logoff
|
488
488
|
reconnect_connection
|
489
|
-
@conn.select_first("SELECT * FROM test_dummy_table").
|
489
|
+
expect(@conn.select_first("SELECT * FROM test_dummy_table")).to eq nil
|
490
490
|
@conn.autocommit = old_autocommit
|
491
491
|
end
|
492
492
|
|