ruby-plsql 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +5 -5
  2. data/.codeclimate.yml +30 -0
  3. data/.github/stale.yml +37 -0
  4. data/.rubocop.yml +153 -0
  5. data/.travis.yml +20 -6
  6. data/.travis/oracle/download.sh +9 -10
  7. data/.travis/oracle/install.sh +6 -6
  8. data/Gemfile +13 -9
  9. data/History.txt +26 -0
  10. data/README.md +9 -5
  11. data/Rakefile +31 -26
  12. data/VERSION +1 -1
  13. data/Vagrantfile +2 -2
  14. data/gemfiles/Gemfile.activerecord-5.0 +21 -0
  15. data/gemfiles/Gemfile.activerecord-5.1 +21 -0
  16. data/gemfiles/Gemfile.activerecord-5.2 +21 -0
  17. data/lib/plsql/connection.rb +16 -18
  18. data/lib/plsql/helpers.rb +1 -3
  19. data/lib/plsql/jdbc_connection.rb +66 -61
  20. data/lib/plsql/oci8_patches.rb +2 -2
  21. data/lib/plsql/oci_connection.rb +51 -69
  22. data/lib/plsql/package.rb +5 -8
  23. data/lib/plsql/procedure.rb +75 -78
  24. data/lib/plsql/procedure_call.rb +498 -501
  25. data/lib/plsql/schema.rb +95 -100
  26. data/lib/plsql/sequence.rb +10 -13
  27. data/lib/plsql/sql_statements.rb +9 -11
  28. data/lib/plsql/table.rb +59 -63
  29. data/lib/plsql/type.rb +71 -76
  30. data/lib/plsql/variable.rb +89 -94
  31. data/lib/plsql/version.rb +1 -1
  32. data/lib/plsql/view.rb +16 -19
  33. data/ruby-plsql.gemspec +41 -37
  34. data/spec/plsql/connection_spec.rb +67 -67
  35. data/spec/plsql/package_spec.rb +15 -15
  36. data/spec/plsql/procedure_spec.rb +286 -233
  37. data/spec/plsql/schema_spec.rb +22 -23
  38. data/spec/plsql/sequence_spec.rb +2 -2
  39. data/spec/plsql/sql_statements_spec.rb +5 -5
  40. data/spec/plsql/table_spec.rb +77 -77
  41. data/spec/plsql/type_spec.rb +23 -29
  42. data/spec/plsql/variable_spec.rb +59 -59
  43. data/spec/plsql/version_spec.rb +4 -4
  44. data/spec/plsql/view_spec.rb +42 -42
  45. data/spec/spec_helper.rb +37 -29
  46. data/spec/support/test_db.rb +12 -13
  47. metadata +44 -26
  48. data/.travis/oracle/LICENSE +0 -5
  49. data/.travis/oracle/README.md +0 -64
  50. data/.travis/oracle/download.js +0 -100
@@ -1,19 +1,20 @@
1
- # Generated by jeweler
1
+ # Generated by juwelier
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
3
+ # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: ruby-plsql 0.6.0 ruby lib
5
+
6
+ # stub: ruby-plsql 0.7.0 ruby lib
6
7
 
7
8
  Gem::Specification.new do |s|
8
- s.name = "ruby-plsql"
9
- s.version = "0.6.0"
9
+ s.name = "ruby-plsql".freeze
10
+ s.version = "0.7.0"
10
11
 
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib"]
13
- s.authors = ["Raimonds Simanovskis"]
14
- s.date = "2016-03-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"
16
- s.email = "raimonds.simanovskis@gmail.com"
12
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
13
+ s.require_paths = ["lib".freeze]
14
+ s.authors = ["Raimonds Simanovskis".freeze]
15
+ s.date = "2018-09-03"
16
+ s.description = " ruby-plsql gem provides simple Ruby API for calling Oracle PL/SQL procedures.\n It could be used both for accessing Oracle PL/SQL API procedures in legacy applications\n as well as it could be used to create PL/SQL unit tests using Ruby testing libraries.\n".freeze
17
+ s.email = "raimonds.simanovskis@gmail.com".freeze
17
18
  s.extra_rdoc_files = [
18
19
  "README.md"
19
20
  ]
@@ -70,38 +71,41 @@ Gem::Specification.new do |s|
70
71
  "spec/support/test_db.rb",
71
72
  "spec/support/unlock_and_setup_hr_user.sql"
72
73
  ]
73
- s.homepage = "http://github.com/rsim/ruby-plsql"
74
- s.rubygems_version = "2.5.1"
75
- s.summary = "Ruby API for calling Oracle PL/SQL procedures."
74
+ s.homepage = "http://github.com/rsim/ruby-plsql".freeze
75
+ s.licenses = ["MIT".freeze]
76
+ s.rubygems_version = "2.6.4".freeze
77
+ s.summary = "Ruby API for calling Oracle PL/SQL procedures.".freeze
76
78
 
77
79
  if s.respond_to? :specification_version then
78
80
  s.specification_version = 4
79
81
 
80
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
81
- s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
82
- s.add_development_dependency(%q<rspec>, ["~> 3.1"])
83
- s.add_development_dependency(%q<rspec_junit_formatter>, [">= 0"])
84
- s.add_development_dependency(%q<activerecord>, ["< 4.3.0", ">= 3.2.3"])
85
- s.add_development_dependency(%q<activerecord-oracle_enhanced-adapter>, ["< 1.7.0", ">= 1.4.1"])
86
- s.add_development_dependency(%q<simplecov>, [">= 0"])
87
- s.add_development_dependency(%q<ruby-oci8>, ["~> 2.1"])
82
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.2.0") then
83
+ s.add_development_dependency("juwelier".freeze, ["~> 2.0"])
84
+ s.add_development_dependency("rspec_junit_formatter".freeze, [">= 0"])
85
+ s.add_development_dependency("rake".freeze, [">= 10.0"])
86
+ s.add_development_dependency("rspec".freeze, ["~> 3.1"])
87
+ s.add_development_dependency("activerecord".freeze, "~> 5.0")
88
+ s.add_development_dependency("activerecord-oracle_enhanced-adapter".freeze, "~> 1.7")
89
+ s.add_development_dependency("simplecov".freeze, [">= 0"])
90
+ s.add_development_dependency("ruby-oci8".freeze, ["~> 2.1"])
88
91
  else
89
- s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
90
- s.add_dependency(%q<rspec>, ["~> 3.1"])
91
- s.add_dependency(%q<rspec_junit_formatter>, [">= 0"])
92
- s.add_dependency(%q<activerecord>, ["< 4.3.0", ">= 3.2.3"])
93
- s.add_dependency(%q<activerecord-oracle_enhanced-adapter>, ["< 1.7.0", ">= 1.4.1"])
94
- s.add_dependency(%q<simplecov>, [">= 0"])
95
- s.add_dependency(%q<ruby-oci8>, ["~> 2.1"])
92
+ s.add_dependency("juwelier".freeze, ["~> 2.0"])
93
+ s.add_dependency("rspec_junit_formatter".freeze, [">= 0"])
94
+ s.add_dependency("rake".freeze, [">= 10.0"])
95
+ s.add_dependency("rspec".freeze, ["~> 3.1"])
96
+ s.add_dependency("activerecord".freeze, "~> 5.0")
97
+ s.add_dependency("activerecord-oracle_enhanced-adapter".freeze, "~> 1.7")
98
+ s.add_dependency("simplecov".freeze, [">= 0"])
99
+ s.add_dependency("ruby-oci8".freeze, ["~> 2.1"])
96
100
  end
97
101
  else
98
- s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
99
- s.add_dependency(%q<rspec>, ["~> 3.1"])
100
- s.add_dependency(%q<rspec_junit_formatter>, [">= 0"])
101
- s.add_dependency(%q<activerecord>, ["< 4.3.0", ">= 3.2.3"])
102
- s.add_dependency(%q<activerecord-oracle_enhanced-adapter>, ["< 1.7.0", ">= 1.4.1"])
103
- s.add_dependency(%q<simplecov>, [">= 0"])
104
- s.add_dependency(%q<ruby-oci8>, ["~> 2.1"])
102
+ s.add_dependency("juwelier".freeze, ["~> 2.0"])
103
+ s.add_dependency("rspec_junit_formatter".freeze, [">= 0"])
104
+ s.add_dependency("rake".freeze, [">= 10.0"])
105
+ s.add_dependency("rspec".freeze, ["~> 3.1"])
106
+ s.add_dependency("activerecord".freeze, "~> 5.0")
107
+ s.add_dependency("activerecord-oracle_enhanced-adapter".freeze, "~> 1.7")
108
+ s.add_dependency("simplecov".freeze, [">= 0"])
109
+ s.add_dependency("ruby-oci8".freeze, ["~> 2.1"])
105
110
  end
106
111
  end
107
-
@@ -1,12 +1,12 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  describe "Connection" do
6
6
 
7
7
  before(:all) do
8
8
  @raw_conn = get_connection
9
- @conn = PLSQL::Connection.create( @raw_conn )
9
+ @conn = PLSQL::Connection.create(@raw_conn)
10
10
  end
11
11
 
12
12
  after(:all) do
@@ -23,7 +23,7 @@ describe "Connection" do
23
23
  end
24
24
 
25
25
  before(:each) do
26
- @conn1 = PLSQL::Connection.create( @raw_conn1 )
26
+ @conn1 = PLSQL::Connection.create(@raw_conn1)
27
27
  end
28
28
 
29
29
  it "should create connection" do
@@ -52,42 +52,42 @@ describe "Connection" do
52
52
  unless defined?(JRuby)
53
53
  describe "OCI data type conversions" do
54
54
  it "should translate PL/SQL VARCHAR to Ruby String" do
55
- expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR", :data_length => 100)).to eq [String, 100]
56
- expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR", :data_length => nil)).to eq [String, 32767]
55
+ expect(@conn.plsql_to_ruby_data_type(data_type: "VARCHAR", data_length: 100)).to eq [String, 100]
56
+ expect(@conn.plsql_to_ruby_data_type(data_type: "VARCHAR", data_length: nil)).to eq [String, 32767]
57
57
  end
58
58
 
59
59
  it "should translate PL/SQL VARCHAR2 to Ruby String" do
60
- expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR2", :data_length => 100)).to eq [String, 100]
61
- expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR2", :data_length => nil)).to eq [String, 32767]
60
+ expect(@conn.plsql_to_ruby_data_type(data_type: "VARCHAR2", data_length: 100)).to eq [String, 100]
61
+ expect(@conn.plsql_to_ruby_data_type(data_type: "VARCHAR2", data_length: nil)).to eq [String, 32767]
62
62
  end
63
63
 
64
64
  it "should translate PL/SQL CLOB to Ruby String" do
65
- expect(@conn.plsql_to_ruby_data_type(:data_type => "CLOB", :data_length => 100_000)).to eq [OCI8::CLOB, nil]
66
- expect(@conn.plsql_to_ruby_data_type(:data_type => "CLOB", :data_length => nil)).to eq [OCI8::CLOB, nil]
65
+ expect(@conn.plsql_to_ruby_data_type(data_type: "CLOB", data_length: 100_000)).to eq [OCI8::CLOB, nil]
66
+ expect(@conn.plsql_to_ruby_data_type(data_type: "CLOB", data_length: nil)).to eq [OCI8::CLOB, nil]
67
67
  end
68
68
 
69
69
  it "should translate PL/SQL NUMBER to Ruby OraNumber" do
70
- expect(@conn.plsql_to_ruby_data_type(:data_type => "NUMBER", :data_length => 15)).to eq [OraNumber, nil]
70
+ expect(@conn.plsql_to_ruby_data_type(data_type: "NUMBER", data_length: 15)).to eq [OraNumber, nil]
71
71
  end
72
72
 
73
73
  it "should translate PL/SQL DATE to Ruby DateTime" do
74
- expect(@conn.plsql_to_ruby_data_type(:data_type => "DATE", :data_length => nil)).to eq [DateTime, nil]
74
+ expect(@conn.plsql_to_ruby_data_type(data_type: "DATE", data_length: nil)).to eq [DateTime, nil]
75
75
  end
76
76
 
77
77
  it "should translate PL/SQL TIMESTAMP to Ruby Time" do
78
- expect(@conn.plsql_to_ruby_data_type(:data_type => "TIMESTAMP", :data_length => nil)).to eq [Time, nil]
78
+ expect(@conn.plsql_to_ruby_data_type(data_type: "TIMESTAMP", data_length: nil)).to eq [Time, nil]
79
79
  end
80
80
 
81
- it "should not translate Ruby Fixnum when OraNumber type specified" do
81
+ it "should not translate small Ruby Integer when OraNumber type specified" do
82
82
  expect(@conn.ruby_value_to_ora_value(100, OraNumber)).to eql(100)
83
83
  end
84
84
 
85
- it "should translate Ruby Bignum value to OraNumber when OraNumber type specified" do
85
+ it "should not translate big Ruby Integer when OraNumber type specified" do
86
86
  ora_number = @conn.ruby_value_to_ora_value(12345678901234567890, OraNumber)
87
- expect(ora_number.class).to eq OraNumber
87
+ expect(ora_number).to be_an Integer
88
88
  expect(ora_number.to_s).to eq "12345678901234567890"
89
89
  # OraNumber has more numeric comparison methods in ruby-oci8 2.0
90
- expect(ora_number).to eq OraNumber.new("12345678901234567890") if OCI8::VERSION >= '2.0.0'
90
+ expect(ora_number).to eq OraNumber.new("12345678901234567890") if OCI8::VERSION >= "2.0.0"
91
91
  end
92
92
 
93
93
  it "should translate Ruby String value to OCI8::CLOB when OCI8::CLOB type specified" do
@@ -99,7 +99,7 @@ describe "Connection" do
99
99
  expect(ora_value.read).to eq large_text
100
100
  end
101
101
 
102
- it "should translate Oracle OraNumber integer value to Fixnum" do
102
+ it "should translate Oracle OraNumber integer value to Integer" do
103
103
  expect(@conn.ora_value_to_ruby_value(OraNumber.new(100))).to eql(100)
104
104
  end
105
105
 
@@ -108,7 +108,7 @@ describe "Connection" do
108
108
  end
109
109
 
110
110
  # ruby-oci8 2.0 returns DATE as Time or DateTime
111
- if OCI8::VERSION < '2.0.0'
111
+ if OCI8::VERSION < "2.0.0"
112
112
  it "should translate Oracle OraDate value to Time" do
113
113
  now = OraDate.now
114
114
  expect(@conn.ora_value_to_ruby_value(now)).to eql(now.to_time)
@@ -128,35 +128,35 @@ describe "Connection" do
128
128
 
129
129
  describe "JDBC data type conversions" do
130
130
  it "should translate PL/SQL VARCHAR to Ruby String" do
131
- expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR", :data_length => 100)).to eq [String, 100]
132
- expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR", :data_length => nil)).to eq [String, 32767]
131
+ expect(@conn.plsql_to_ruby_data_type(data_type: "VARCHAR", data_length: 100)).to eq [String, 100]
132
+ expect(@conn.plsql_to_ruby_data_type(data_type: "VARCHAR", data_length: nil)).to eq [String, 32767]
133
133
  end
134
134
  it "should translate PL/SQL VARCHAR2 to Ruby String" do
135
- expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR2", :data_length => 100)).to eq [String, 100]
136
- expect(@conn.plsql_to_ruby_data_type(:data_type => "VARCHAR2", :data_length => nil)).to eq [String, 32767]
135
+ expect(@conn.plsql_to_ruby_data_type(data_type: "VARCHAR2", data_length: 100)).to eq [String, 100]
136
+ expect(@conn.plsql_to_ruby_data_type(data_type: "VARCHAR2", data_length: nil)).to eq [String, 32767]
137
137
  end
138
138
 
139
139
  it "should translate PL/SQL NUMBER to Ruby BigDecimal" do
140
- expect(@conn.plsql_to_ruby_data_type(:data_type => "NUMBER", :data_length => 15)).to eq [BigDecimal, nil]
140
+ expect(@conn.plsql_to_ruby_data_type(data_type: "NUMBER", data_length: 15)).to eq [BigDecimal, nil]
141
141
  end
142
142
 
143
143
  it "should translate PL/SQL DATE to Ruby DateTime" do
144
- expect(@conn.plsql_to_ruby_data_type(:data_type => "DATE", :data_length => nil)).to eq [DateTime, nil]
144
+ expect(@conn.plsql_to_ruby_data_type(data_type: "DATE", data_length: nil)).to eq [DateTime, nil]
145
145
  end
146
146
 
147
147
  it "should translate PL/SQL TIMESTAMP to Ruby Time" do
148
- expect(@conn.plsql_to_ruby_data_type(:data_type => "TIMESTAMP", :data_length => nil)).to eq [Time, nil]
148
+ expect(@conn.plsql_to_ruby_data_type(data_type: "TIMESTAMP", data_length: nil)).to eq [Time, nil]
149
149
  end
150
150
 
151
- it "should not translate Ruby Fixnum when BigDecimal type specified" do
151
+ it "should not translate Ruby Integer when BigDecimal type specified" do
152
152
  expect(@conn.ruby_value_to_ora_value(100, BigDecimal)).to eq java.math.BigDecimal.new(100)
153
153
  end
154
154
 
155
155
  it "should translate Ruby String to string value" do
156
- expect(@conn.ruby_value_to_ora_value(1.1, String)).to eq '1.1'
156
+ expect(@conn.ruby_value_to_ora_value(1.1, String)).to eq "1.1"
157
157
  end
158
158
 
159
- it "should translate Ruby Bignum value to BigDecimal when BigDecimal type specified" do
159
+ it "should translate Ruby Integer value to BigDecimal when BigDecimal type specified" do
160
160
  big_decimal = @conn.ruby_value_to_ora_value(12345678901234567890, BigDecimal)
161
161
  expect(big_decimal).to eq java.math.BigDecimal.new("12345678901234567890")
162
162
  end
@@ -175,7 +175,7 @@ describe "Connection" do
175
175
  expect(ora_value).to be_nil
176
176
  end
177
177
 
178
- it "should translate Oracle BigDecimal integer value to Fixnum" do
178
+ it "should translate Oracle BigDecimal integer value to Integer" do
179
179
  expect(@conn.ora_value_to_ruby_value(BigDecimal("100"))).to eql(100)
180
180
  end
181
181
 
@@ -202,87 +202,87 @@ describe "Connection" do
202
202
  describe "SQL SELECT statements" do
203
203
 
204
204
  it "should execute SQL statement and return first result" do
205
- @now = Time.local(2008,05,31,23,22,11)
205
+ @now = Time.local(2008, 05, 31, 23, 22, 11)
206
206
  expect(@conn.select_first("SELECT 'abc',123,123.456,
207
207
  TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}','YYYY-MM-DD HH24:MI:SS')
208
- FROM dual")).to eq ["abc",123,123.456,@now]
208
+ FROM dual")).to eq ["abc", 123, 123.456, @now]
209
209
  end
210
210
 
211
211
  it "should execute SQL statement and return first result as hash" do
212
- @now = Time.local(2008,05,31,23,22,11)
212
+ @now = Time.local(2008, 05, 31, 23, 22, 11)
213
213
  expect(@conn.select_hash_first("SELECT 'abc' a, 123 b, 123.456 c,
214
214
  TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}', 'YYYY-MM-DD HH24:MI:SS') d
215
- FROM dual")).to eq({:a => "abc", :b => 123, :c => 123.456, :d => @now})
215
+ FROM dual")).to eq(a: "abc", b: 123, c: 123.456, d: @now)
216
216
  end
217
217
 
218
218
  it "should execute SQL statement with bind parameters and return first result" do
219
219
  @today = Date.parse("2008-05-31")
220
- @now = Time.local(2008,05,31,23,22,11)
220
+ @now = Time.local(2008, 05, 31, 23, 22, 11)
221
221
  expect(@conn.select_first("SELECT :1,:2,:3,:4,:5 FROM dual",
222
- 'abc',123,123.456,@now,@today)).to eq ["abc",123,123.456,@now,Time.parse(@today.to_s)]
222
+ "abc", 123, 123.456, @now, @today)).to eq ["abc", 123, 123.456, @now, Time.parse(@today.to_s)]
223
223
  end
224
224
 
225
225
  it "should execute SQL statement with NULL values and return first result" do
226
- @now = Time.local(2008,05,31,23,22,11)
226
+ @now = Time.local(2008, 05, 31, 23, 22, 11)
227
227
  expect(@conn.select_first("SELECT NULL,123,123.456,
228
228
  TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}','YYYY-MM-DD HH24:MI:SS')
229
- FROM dual")).to eq [nil,123,123.456,@now]
229
+ FROM dual")).to eq [nil, 123, 123.456, @now]
230
230
  end
231
231
 
232
232
  if defined?(JRuby)
233
233
 
234
234
  it "should execute SQL statement with NULL values as bind parameters and return first result" do
235
235
  @today = Date.parse("2008-05-31")
236
- @now = Time.local(2008,05,31,23,22,11)
236
+ @now = Time.local(2008, 05, 31, 23, 22, 11)
237
237
  expect(@conn.select_first("SELECT :1,:2,:3,:4,:5 FROM dual",
238
- nil,123,123.456,@now,@today)).to eq [nil,123,123.456,@now,Time.parse(@today.to_s)]
238
+ nil, 123, 123.456, @now, @today)).to eq [nil, 123, 123.456, @now, Time.parse(@today.to_s)]
239
239
  end
240
240
 
241
241
  end
242
242
 
243
243
  it "should execute SQL statement and return all results" do
244
- @now = Time.local(2008,05,31,23,22,11)
244
+ @now = Time.local(2008, 05, 31, 23, 22, 11)
245
245
  expect(@conn.select_all("SELECT 'abc',123,123.456,
246
246
  TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}','YYYY-MM-DD HH24:MI:SS')
247
247
  FROM dual
248
248
  UNION ALL SELECT 'abc',123,123.456,
249
249
  TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}','YYYY-MM-DD HH24:MI:SS')
250
- FROM dual")).to eq [["abc",123,123.456,@now],["abc",123,123.456,@now]]
250
+ FROM dual")).to eq [["abc", 123, 123.456, @now], ["abc", 123, 123.456, @now]]
251
251
  end
252
252
 
253
253
  it "should execute SQL statement and return all results as hash" do
254
- @now = Time.local(2008,05,31,23,22,11)
254
+ @now = Time.local(2008, 05, 31, 23, 22, 11)
255
255
  expect(@conn.select_hash_all("SELECT 'abc' a, 123 b, 123.456 c,
256
256
  TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}','YYYY-MM-DD HH24:MI:SS') d
257
257
  FROM dual
258
258
  UNION ALL SELECT 'def' a, 123 b, 123.456 c,
259
259
  TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}','YYYY-MM-DD HH24:MI:SS') d
260
- FROM dual")).to eq [{:a=>"abc",:b=>123,:c=>123.456,:d=>@now},{:a=>"def",:b=>123,:c=>123.456,:d=>@now}]
260
+ FROM dual")).to eq [{ a: "abc", b: 123, c: 123.456, d: @now }, { a: "def", b: 123, c: 123.456, d: @now }]
261
261
  end
262
262
 
263
263
  it "should execute SQL statement with bind parameters and return all results" do
264
- @now = Time.local(2008,05,31,23,22,11)
264
+ @now = Time.local(2008, 05, 31, 23, 22, 11)
265
265
  expect(@conn.select_all("SELECT :1,:2,:3,:4 FROM dual UNION ALL SELECT :1,:2,:3,:4 FROM dual",
266
- 'abc',123,123.456,@now,'abc',123,123.456,@now)).to eq [["abc",123,123.456,@now],["abc",123,123.456,@now]]
266
+ "abc", 123, 123.456, @now, "abc", 123, 123.456, @now)).to eq [["abc", 123, 123.456, @now], ["abc", 123, 123.456, @now]]
267
267
  end
268
268
 
269
269
  it "should execute SQL statement and yield all results in block" do
270
- @now = Time.local(2008,05,31,23,22,11)
270
+ @now = Time.local(2008, 05, 31, 23, 22, 11)
271
271
  expect(@conn.select_all("SELECT 'abc',123,123.456,
272
272
  TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}','YYYY-MM-DD HH24:MI:SS')
273
273
  FROM dual
274
274
  UNION ALL SELECT 'abc',123,123.456,
275
275
  TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}','YYYY-MM-DD HH24:MI:SS')
276
276
  FROM dual") do |r|
277
- expect(r).to eq ["abc",123,123.456,@now]
277
+ expect(r).to eq ["abc", 123, 123.456, @now]
278
278
  end).to eq 2
279
279
  end
280
280
 
281
281
  it "should execute SQL statement with bind parameters and yield all results in block" do
282
- @now = Time.local(2008,05,31,23,22,11)
282
+ @now = Time.local(2008, 05, 31, 23, 22, 11)
283
283
  expect(@conn.select_all("SELECT :1,:2,:3,:4 FROM dual UNION ALL SELECT :1,:2,:3,:4 FROM dual",
284
- 'abc',123,123.456,@now,'abc',123,123.456,@now) do |r|
285
- expect(r).to eq ["abc",123,123.456,@now]
284
+ "abc", 123, 123.456, @now, "abc", 123, 123.456, @now) do |r|
285
+ expect(r).to eq ["abc", 123, 123.456, @now]
286
286
  end).to eq 2
287
287
  end
288
288
 
@@ -291,7 +291,7 @@ describe "Connection" do
291
291
  describe "PL/SQL procedures" do
292
292
  before(:all) do
293
293
  @random = rand(1000)
294
- @now = Time.local(2008,05,31,23,22,11)
294
+ @now = Time.local(2008, 05, 31, 23, 22, 11)
295
295
  sql = <<-SQL
296
296
  CREATE OR REPLACE FUNCTION test_add_random (p_number NUMBER, p_varchar IN OUT VARCHAR2, p_date IN OUT DATE)
297
297
  RETURN NUMBER
@@ -314,10 +314,10 @@ describe "Connection" do
314
314
  END;
315
315
  SQL
316
316
  cursor = @conn.parse(sql)
317
- cursor.bind_param(":result", nil, :data_type => 'NUMBER', :in_out => 'OUT')
318
- cursor.bind_param(":p_number", 100, :data_type => 'NUMBER', :in_out => 'IN')
319
- cursor.bind_param(":p_varchar", "abc", :data_type => 'VARCHAR2', :in_out => 'IN/OUT')
320
- cursor.bind_param(":p_date", @now, :data_type => 'DATE', :in_out => 'IN/OUT')
317
+ cursor.bind_param(":result", nil, data_type: "NUMBER", in_out: "OUT")
318
+ cursor.bind_param(":p_number", 100, data_type: "NUMBER", in_out: "IN")
319
+ cursor.bind_param(":p_varchar", "abc", data_type: "VARCHAR2", in_out: "IN/OUT")
320
+ cursor.bind_param(":p_date", @now, data_type: "DATE", in_out: "IN/OUT")
321
321
  cursor.exec
322
322
  expect(cursor[":result"]).to eq @random + 100
323
323
  expect(cursor[":p_varchar"]).to eq "abc"
@@ -401,21 +401,21 @@ describe "Connection" do
401
401
  end
402
402
 
403
403
  it "should describe local synonym" do
404
- expect(@conn.describe_synonym('HR','SYNONYM_FOR_DUAL')).to eq ['SYS', 'DUAL']
405
- expect(@conn.describe_synonym('hr','synonym_for_dual')).to eq ['SYS', 'DUAL']
406
- expect(@conn.describe_synonym(:hr,:synonym_for_dual)).to eq ['SYS', 'DUAL']
404
+ expect(@conn.describe_synonym("HR", "SYNONYM_FOR_DUAL")).to eq ["SYS", "DUAL"]
405
+ expect(@conn.describe_synonym("hr", "synonym_for_dual")).to eq ["SYS", "DUAL"]
406
+ expect(@conn.describe_synonym(:hr, :synonym_for_dual)).to eq ["SYS", "DUAL"]
407
407
  end
408
408
 
409
409
  it "should return nil on non-existing synonym" do
410
- expect(@conn.describe_synonym('HR','SYNONYM_FOR_XXX')).to be_nil
411
- expect(@conn.describe_synonym('hr','synonym_for_xxx')).to be_nil
412
- expect(@conn.describe_synonym(:hr,:synonym_for_xxx)).to be_nil
410
+ expect(@conn.describe_synonym("HR", "SYNONYM_FOR_XXX")).to be_nil
411
+ expect(@conn.describe_synonym("hr", "synonym_for_xxx")).to be_nil
412
+ expect(@conn.describe_synonym(:hr, :synonym_for_xxx)).to be_nil
413
413
  end
414
414
 
415
415
  it "should describe public synonym" do
416
- expect(@conn.describe_synonym('PUBLIC','DUAL')).to eq ['SYS', 'DUAL']
417
- expect(@conn.describe_synonym('PUBLIC','dual')).to eq ['SYS', 'DUAL']
418
- expect(@conn.describe_synonym('PUBLIC',:dual)).to eq ['SYS', 'DUAL']
416
+ expect(@conn.describe_synonym("PUBLIC", "DUAL")).to eq ["SYS", "DUAL"]
417
+ expect(@conn.describe_synonym("PUBLIC", "dual")).to eq ["SYS", "DUAL"]
418
+ expect(@conn.describe_synonym("PUBLIC", :dual)).to eq ["SYS", "DUAL"]
419
419
  end
420
420
 
421
421
  end
@@ -423,7 +423,7 @@ describe "Connection" do
423
423
  describe "session information" do
424
424
  it "should get database version" do
425
425
  # using Oracle version 10.2.0.4 for unit tests
426
- expect(@conn.database_version).to eq DATABASE_VERSION.split('.').map{|n| n.to_i}
426
+ expect(@conn.database_version).to eq DATABASE_VERSION.split(".").map { |n| n.to_i }
427
427
  end
428
428
 
429
429
  it "should get session ID" do
@@ -453,7 +453,7 @@ describe "Connection" do
453
453
  end
454
454
 
455
455
  it "should not drop other session ruby temporary tables" do
456
- tmp_table = "ruby_#{@conn.session_id+1}_222_333"
456
+ tmp_table = "ruby_#{@conn.session_id + 1}_222_333"
457
457
  @conn.exec "CREATE GLOBAL TEMPORARY TABLE #{tmp_table} (dummy CHAR(1))"
458
458
  expect { @conn.select_first("SELECT * FROM #{tmp_table}") }.not_to raise_error
459
459
  @conn.drop_session_ruby_temporary_tables
@@ -474,7 +474,7 @@ describe "Connection" do
474
474
 
475
475
  def reconnect_connection
476
476
  @raw_conn = get_connection
477
- @conn = PLSQL::Connection.create( @raw_conn )
477
+ @conn = PLSQL::Connection.create(@raw_conn)
478
478
  end
479
479
 
480
480
  it "should drop current session ruby temporary tables" do
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe "Package" do
4
4
  before(:all) do
@@ -21,15 +21,15 @@ describe "Package" do
21
21
  END;
22
22
  SQL
23
23
  end
24
-
24
+
25
25
  after(:all) do
26
26
  plsql.execute "DROP PACKAGE test_package"
27
27
  plsql.logoff
28
28
  end
29
-
29
+
30
30
  before(:each) do
31
31
  end
32
-
32
+
33
33
  it "should find existing package" do
34
34
  expect(PLSQL::Package.find(plsql, :test_package)).not_to be_nil
35
35
  end
@@ -43,7 +43,7 @@ describe "Package" do
43
43
  end
44
44
 
45
45
  it "should execute package function and return correct value" do
46
- expect(plsql.test_package.test_procedure('xxx')).to eq('XXX')
46
+ expect(plsql.test_package.test_procedure("xxx")).to eq("XXX")
47
47
  end
48
48
 
49
49
  it "should report an existing procedure as existing" do
@@ -57,11 +57,11 @@ describe "Package" do
57
57
  it "should search objects via []" do
58
58
  package = PLSQL::Package.find(plsql, :test_package)
59
59
 
60
- [:Test_Procedure, :test_procedure, 'test_procedure', 'TEST_PROCEDURE'].each do |name_variant|
60
+ [:Test_Procedure, :test_procedure, "test_procedure", "TEST_PROCEDURE"].each do |name_variant|
61
61
  expect(package[name_variant]).to be_a PLSQL::Procedure
62
62
  end
63
63
 
64
- [:Test_Variable, :test_variable, 'test_variable', 'TEST_VARIABLE'].each do |name_variant|
64
+ [:Test_Variable, :test_variable, "test_variable", "TEST_VARIABLE"].each do |name_variant|
65
65
  expect(package[name_variant]).to be_a PLSQL::Variable
66
66
  end
67
67
  end
@@ -114,7 +114,7 @@ describe "Package" do
114
114
  end
115
115
 
116
116
  describe "Synonym to package" do
117
-
117
+
118
118
  before(:all) do
119
119
  plsql.connection = get_connection
120
120
  plsql.execute <<-SQL
@@ -135,38 +135,38 @@ describe "Synonym to package" do
135
135
  SQL
136
136
  plsql.execute "CREATE SYNONYM test_pkg_synonym FOR hr.test_package"
137
137
  end
138
-
138
+
139
139
  after(:all) do
140
140
  plsql.execute "DROP SYNONYM test_pkg_synonym" rescue nil
141
141
  plsql.logoff
142
142
  end
143
-
143
+
144
144
  it "should find synonym to package" do
145
145
  expect(PLSQL::Package.find(plsql, :test_pkg_synonym)).not_to be_nil
146
146
  end
147
147
 
148
148
  it "should execute package function using synonym and return correct value" do
149
- expect(plsql.test_pkg_synonym.test_procedure('xxx')).to eq('XXX')
149
+ expect(plsql.test_pkg_synonym.test_procedure("xxx")).to eq("XXX")
150
150
  end
151
151
 
152
152
  end
153
153
 
154
154
  describe "Public synonym to package" do
155
-
155
+
156
156
  before(:all) do
157
157
  plsql.connection = get_connection
158
158
  end
159
-
159
+
160
160
  after(:all) do
161
161
  plsql.logoff
162
162
  end
163
-
163
+
164
164
  it "should find public synonym to package" do
165
165
  expect(PLSQL::Package.find(plsql, :utl_encode)).not_to be_nil
166
166
  end
167
167
 
168
168
  it "should execute package function using public synonym and return correct value" do
169
- expect(plsql.utl_encode.base64_encode('abc')).to eq('4372773D')
169
+ expect(plsql.utl_encode.base64_encode("abc")).to eq("4372773D")
170
170
  end
171
171
 
172
172
  end