ruby-plsql 0.5.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +5 -5
  2. data/.github/stale.yml +37 -0
  3. data/.github/workflows/rubocop.yml +37 -0
  4. data/.github/workflows/test.yml +69 -0
  5. data/.rubocop.yml +147 -0
  6. data/.travis.yml +88 -0
  7. data/.travis/oracle/download.sh +15 -0
  8. data/.travis/oracle/install.sh +32 -0
  9. data/.travis/setup_accounts.sh +9 -0
  10. data/Gemfile +17 -9
  11. data/History.txt +76 -0
  12. data/README.md +29 -6
  13. data/Rakefile +31 -26
  14. data/VERSION +1 -1
  15. data/Vagrantfile +4 -4
  16. data/ci/network/admin/tnsnames.ora +7 -0
  17. data/ci/setup_accounts.sh +9 -0
  18. data/gemfiles/Gemfile.activerecord-5.0 +21 -0
  19. data/gemfiles/Gemfile.activerecord-5.1 +21 -0
  20. data/gemfiles/Gemfile.activerecord-5.2 +21 -0
  21. data/gemfiles/Gemfile.activerecord-6.0 +21 -0
  22. data/gemfiles/Gemfile.activerecord-6.1 +21 -0
  23. data/gemfiles/Gemfile.activerecord-main +21 -0
  24. data/lib/plsql/connection.rb +19 -22
  25. data/lib/plsql/helpers.rb +1 -3
  26. data/lib/plsql/jdbc_connection.rb +70 -68
  27. data/lib/plsql/oci8_patches.rb +2 -2
  28. data/lib/plsql/oci_connection.rb +62 -77
  29. data/lib/plsql/package.rb +61 -46
  30. data/lib/plsql/procedure.rb +358 -78
  31. data/lib/plsql/procedure_call.rb +508 -463
  32. data/lib/plsql/schema.rb +96 -101
  33. data/lib/plsql/sequence.rb +10 -13
  34. data/lib/plsql/sql_statements.rb +9 -11
  35. data/lib/plsql/table.rb +60 -63
  36. data/lib/plsql/type.rb +71 -76
  37. data/lib/plsql/variable.rb +90 -94
  38. data/lib/plsql/version.rb +1 -1
  39. data/lib/plsql/view.rb +16 -19
  40. data/ruby-plsql.gemspec +55 -35
  41. data/spec/plsql/connection_spec.rb +72 -66
  42. data/spec/plsql/package_spec.rb +63 -14
  43. data/spec/plsql/procedure_spec.rb +603 -261
  44. data/spec/plsql/schema_spec.rb +47 -23
  45. data/spec/plsql/sequence_spec.rb +2 -2
  46. data/spec/plsql/sql_statements_spec.rb +6 -6
  47. data/spec/plsql/table_spec.rb +84 -79
  48. data/spec/plsql/type_spec.rb +24 -30
  49. data/spec/plsql/variable_spec.rb +80 -88
  50. data/spec/plsql/version_spec.rb +4 -4
  51. data/spec/plsql/view_spec.rb +42 -42
  52. data/spec/spec_helper.rb +38 -35
  53. data/spec/support/create_arunit_user.sql +2 -0
  54. data/spec/support/custom_config.rb.sample +14 -0
  55. data/spec/support/test_db.rb +12 -13
  56. data/spec/support/unlock_and_setup_hr_user.sql +2 -0
  57. metadata +111 -34
@@ -1,15 +1,15 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe "Schema" do
4
-
4
+
5
5
  it "should create Schema object" do
6
6
  expect(plsql.class).to eq(PLSQL::Schema)
7
7
  end
8
-
8
+
9
9
  end
10
10
 
11
11
  describe "Schema connection" do
12
-
12
+
13
13
  before(:each) do
14
14
  @conn = get_connection
15
15
  end
@@ -31,12 +31,19 @@ describe "Schema connection" do
31
31
  plsql(:hr).connection = @conn
32
32
  expect(plsql(:hr).connection.raw_connection).to eq(@conn)
33
33
  end
34
-
34
+
35
35
  it "should return schema name" do
36
36
  plsql.connection = @conn
37
37
  expect(plsql.schema_name).to eq(DATABASE_USERS_AND_PASSWORDS[0][0].upcase)
38
38
  end
39
39
 
40
+ it "should match altered current_schema in database session" do
41
+ plsql.connection = @conn
42
+ expected_current_schema = DATABASE_USERS_AND_PASSWORDS[1][0]
43
+ plsql.execute "ALTER SESSION set current_schema=#{expected_current_schema}"
44
+ expect(plsql.schema_name).to eq(expected_current_schema.upcase)
45
+ end
46
+
40
47
  it "should return new schema name after reconnection" do
41
48
  plsql.connection = @conn
42
49
  expect(plsql.schema_name).to eq(DATABASE_USERS_AND_PASSWORDS[0][0].upcase)
@@ -71,38 +78,38 @@ describe "Connection with connect!" do
71
78
  end
72
79
 
73
80
  it "should connect with username, password, host, port and database name" do
74
- plsql.connect! @username, @password, :host => @host, :port => @port, :database => @database_service
81
+ plsql.connect! @username, @password, host: @host, port: @port, database: @database_service
75
82
  expect(plsql.connection).not_to be_nil
76
83
  expect(plsql.schema_name).to eq(@username.upcase)
77
84
  end
78
85
 
79
86
  it "should connect with username, password, host, database name and default port" do
80
87
  skip "Non-default port used for test database" unless @port == 1521
81
- plsql.connect! @username, @password, :host => @host, :database => @database_service
88
+ plsql.connect! @username, @password, host: @host, database: @database_service
82
89
  expect(plsql.connection).not_to be_nil
83
90
  expect(plsql.schema_name).to eq(@username.upcase)
84
91
  end
85
92
 
86
93
  it "should not connect with wrong port number" do
87
94
  expect {
88
- plsql.connect! @username, @password, :host => @host, :port => 9999, :database => @database
89
- }.to raise_error(/no listener|could not establish the connection/)
95
+ plsql.connect! @username, @password, host: @host, port: 9999, database: @database
96
+ }.to raise_error(/ORA-12541|could not establish the connection/)
90
97
  end
91
98
 
92
99
  it "should connect with one Hash parameter" do
93
- plsql.connect! :username => @username, :password => @password, :database => @database
100
+ plsql.connect! username: @username, password: @password, database: @database
94
101
  expect(plsql.connection).not_to be_nil
95
102
  expect(plsql.schema_name).to eq(@username.upcase)
96
103
  end
97
104
 
98
- it "should set session time zone from TZ environment variable" do
105
+ it "should set session time zone from ORA_SDTZ environment variable" do
99
106
  plsql.connect! @username, @password, @database
100
- expect(plsql.connection.time_zone).to eq(ENV['TZ'])
101
- end
107
+ expect(plsql.connection.time_zone).to eq(ENV["ORA_SDTZ"])
108
+ end if ENV["ORA_SDTZ"]
102
109
 
103
110
  it "should set session time zone from :time_zone parameter" do
104
- plsql.connect! :username => @username, :password => @password, :database => @database, :time_zone => 'EET'
105
- expect(plsql.connection.time_zone).to eq('EET')
111
+ plsql.connect! username: @username, password: @password, database: @database, time_zone: "EET"
112
+ expect(plsql.connection.time_zone).to eq("EET")
106
113
  end
107
114
 
108
115
  end
@@ -125,7 +132,7 @@ describe "Named Schema" do
125
132
  end
126
133
 
127
134
  it "should return schema name" do
128
- expect(plsql.hr.schema_name).to eq('HR')
135
+ expect(plsql.hr.schema_name).to eq("HR")
129
136
  end
130
137
 
131
138
  it "should not find named schema if specified twice" do
@@ -139,8 +146,8 @@ describe "Schema commit and rollback" do
139
146
  plsql.connection = @conn = get_connection
140
147
  plsql.connection.autocommit = false
141
148
  plsql.execute "CREATE TABLE test_commit (dummy VARCHAR2(100))"
142
- @data = {:dummy => 'test'}
143
- @data2 = {:dummy => 'test2'}
149
+ @data = { dummy: "test" }
150
+ @data2 = { dummy: "test2" }
144
151
  end
145
152
 
146
153
  after(:all) do
@@ -167,10 +174,10 @@ describe "Schema commit and rollback" do
167
174
 
168
175
  it "should create savepoint and rollback to savepoint" do
169
176
  plsql.test_commit.insert @data
170
- plsql.savepoint 'test'
177
+ plsql.savepoint "test"
171
178
  plsql.test_commit.insert @data2
172
179
  expect(plsql.test_commit.all).to eq([@data, @data2])
173
- plsql.rollback_to 'test'
180
+ plsql.rollback_to "test"
174
181
  expect(plsql.test_commit.all).to eq([@data])
175
182
  end
176
183
 
@@ -199,7 +206,7 @@ describe "ActiveRecord connection" do
199
206
  end
200
207
 
201
208
  it "should return schema name" do
202
- expect(plsql.schema_name).to eq('HR')
209
+ expect(plsql.schema_name).to eq("HR")
203
210
  end
204
211
 
205
212
  it "should use ActiveRecord::Base.default_timezone as default" do
@@ -213,13 +220,30 @@ describe "ActiveRecord connection" do
213
220
 
214
221
  it "should accept inherited ActiveRecord class" do
215
222
  plsql.activerecord_class = TestBaseModel
216
- expect(plsql.schema_name).to eq('HR')
223
+ expect(plsql.schema_name).to eq("HR")
217
224
  end
218
225
 
219
226
  it "should accept subclass of inherited ActiveRecord class" do
220
227
  plsql.activerecord_class = TestModel
221
- expect(plsql.schema_name).to eq('HR')
228
+ expect(plsql.schema_name).to eq("HR")
229
+ end
230
+
231
+ it "should safely close cursors in threaded environment" do
232
+ if (plsql.connection.database_version <=> [18, 0, 0, 0]) >= 0
233
+ expect {
234
+ t1 = Thread.new { plsql.dbms_session.sleep(1) }.tap { |t| t.abort_on_exception = true }
235
+ t2 = Thread.new { plsql.dbms_session.sleep(2) }.tap { |t| t.abort_on_exception = true }
236
+ [t2, t1].each { |t| t.join }
237
+ }.not_to raise_error
238
+ else
239
+ expect {
240
+ t1 = Thread.new { plsql.dbms_lock.sleep(1) }.tap { |t| t.abort_on_exception = true }
241
+ t2 = Thread.new { plsql.dbms_lock.sleep(2) }.tap { |t| t.abort_on_exception = true }
242
+ [t2, t1].each { |t| t.join }
243
+ }.not_to raise_error
244
+ end
222
245
  end
246
+
223
247
  end if defined?(ActiveRecord)
224
248
 
225
249
  describe "DBMS_OUTPUT logging" do
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe "Table" do
4
4
  before(:all) do
@@ -64,4 +64,4 @@ describe "Table" do
64
64
  end
65
65
  end
66
66
 
67
- end
67
+ end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe "SQL statements /" do
4
4
  before(:all) do
@@ -21,7 +21,7 @@ describe "SQL statements /" do
21
21
  CREATE TABLE test_employees (
22
22
  employee_id NUMBER(15),
23
23
  first_name VARCHAR2(50),
24
- last_name VARCHAR2(50),
24
+ last_name VARCHAR(50),
25
25
  hire_date DATE
26
26
  )
27
27
  SQL
@@ -35,10 +35,10 @@ describe "SQL statements /" do
35
35
  SQL
36
36
  @employees = (1..10).map do |i|
37
37
  {
38
- :employee_id => i,
39
- :first_name => "First #{i}",
40
- :last_name => "Last #{i}",
41
- :hire_date => Time.local(2000,01,i)
38
+ employee_id: i,
39
+ first_name: "First #{i}",
40
+ last_name: "Last #{i}",
41
+ hire_date: Time.local(2000, 01, i)
42
42
  }
43
43
  end
44
44
  plsql.connection.prefetch_rows = 100
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe "Table" do
4
4
  before(:all) do
@@ -8,7 +8,7 @@ describe "Table" do
8
8
  CREATE TABLE test_employees (
9
9
  employee_id NUMBER(15) NOT NULL,
10
10
  first_name VARCHAR2(50),
11
- last_name VARCHAR2(50),
11
+ last_name VARCHAR(50),
12
12
  hire_date DATE,
13
13
  created_at TIMESTAMP,
14
14
  status VARCHAR2(1) DEFAULT 'N'
@@ -35,7 +35,7 @@ describe "Table" do
35
35
  CREATE TABLE test_employees2 (
36
36
  employee_id NUMBER(15) NOT NULL,
37
37
  first_name VARCHAR2(50),
38
- last_name VARCHAR2(50),
38
+ last_name VARCHAR(50),
39
39
  hire_date DATE DEFAULT SYSDATE,
40
40
  address t_address,
41
41
  phones t_phones
@@ -43,28 +43,28 @@ describe "Table" do
43
43
  SQL
44
44
  @employees = (1..10).map do |i|
45
45
  {
46
- :employee_id => i,
47
- :first_name => "First #{i}",
48
- :last_name => "Last #{i}",
49
- :hire_date => Time.local(2000,01,i),
50
- :created_at => Time.local(2000,01,i,9,15,30,i),
51
- :status => 'A'
46
+ employee_id: i,
47
+ first_name: "First #{i}",
48
+ last_name: "Last #{i}",
49
+ hire_date: Time.local(2000, 01, i),
50
+ created_at: Time.local(2000, 01, i, 9, 15, 30, i),
51
+ status: "A"
52
52
  }
53
53
  end
54
54
  @employees_all_fields = [:employee_id, :first_name, :last_name, :hire_date, :created_at, :status]
55
- @employees_all_values = @employees.map{|e| @employees_all_fields.map{|f| e[f]}}
55
+ @employees_all_values = @employees.map { |e| @employees_all_fields.map { |f| e[f] } }
56
56
  @employees_some_fields = [:employee_id, :first_name, :last_name]
57
- @employees_some_values = @employees.map{|e| @employees_some_fields.map{|f| e[f]}}
58
- @employee_default_values = {:hire_date => nil, :created_at => nil, :status => 'N'}
57
+ @employees_some_values = @employees.map { |e| @employees_some_fields.map { |f| e[f] } }
58
+ @employee_default_values = { hire_date: nil, created_at: nil, status: "N" }
59
59
 
60
60
  @employees2 = (1..10).map do |i|
61
61
  {
62
- :employee_id => i,
63
- :first_name => "First #{i}",
64
- :last_name => "Last #{i}",
65
- :hire_date => Time.local(2000,01,i),
66
- :address => {:street => "Street #{i}", :city => "City #{i}", :country => "County #{i}"},
67
- :phones => [{:type => "mobile", :phone_number => "Mobile#{i}"}, {:type => "fixed", :phone_number => "Fixed#{i}"}]
62
+ employee_id: i,
63
+ first_name: "First #{i}",
64
+ last_name: "Last #{i}",
65
+ hire_date: Time.local(2000, 01, i),
66
+ address: { street: "Street #{i}", city: "City #{i}", country: "County #{i}" },
67
+ phones: [{ type: "mobile", phone_number: "Mobile#{i}" }, { type: "fixed", phone_number: "Fixed#{i}" }]
68
68
  }
69
69
  end
70
70
  end
@@ -137,49 +137,49 @@ describe "Table" do
137
137
  end
138
138
 
139
139
  it "should get columns metadata for table" do
140
- expect(plsql.test_employees.columns).to eq({
141
- :employee_id => {
142
- :position=>1, :data_type=>"NUMBER", :data_length=>22, :data_precision=>15, :data_scale=>0, :char_used=>nil,
143
- :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil, :nullable => false, :data_default => nil},
144
- :first_name => {
145
- :position=>2, :data_type=>"VARCHAR2", :data_length=>50, :data_precision=>nil, :data_scale=>nil, :char_used=>"B",
146
- :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil, :nullable => true, :data_default => nil},
147
- :last_name => {
148
- :position=>3, :data_type=>"VARCHAR2", :data_length=>50, :data_precision=>nil, :data_scale=>nil, :char_used=>"B",
149
- :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil, :nullable => true, :data_default => nil},
150
- :hire_date => {
151
- :position=>4, :data_type=>"DATE", :data_length=>7, :data_precision=>nil, :data_scale=>nil, :char_used=>nil,
152
- :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil, :nullable => true, :data_default => nil},
153
- :created_at => {
154
- :position=>5, :data_type=>"TIMESTAMP", :data_length=>11, :data_precision=>nil, :data_scale=>6, :char_used=>nil,
155
- :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil, :nullable => true, :data_default => nil},
156
- :status => {
157
- :position=>6, :data_type=>"VARCHAR2", :data_length=>1, :data_precision=>nil, :data_scale=>nil, :char_used=>"B",
158
- :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil, :nullable => true, :data_default => "'N'"}
159
- })
140
+ expect(plsql.test_employees.columns).to eq(
141
+ employee_id: {
142
+ position: 1, data_type: "NUMBER", data_length: 22, data_precision: 15, data_scale: 0, char_used: nil,
143
+ type_owner: nil, type_name: nil, sql_type_name: nil, nullable: false, data_default: nil },
144
+ first_name: {
145
+ position: 2, data_type: "VARCHAR2", data_length: 50, data_precision: nil, data_scale: nil, char_used: "B",
146
+ type_owner: nil, type_name: nil, sql_type_name: nil, nullable: true, data_default: nil },
147
+ last_name: {
148
+ position: 3, data_type: "VARCHAR2", data_length: 50, data_precision: nil, data_scale: nil, char_used: "B",
149
+ type_owner: nil, type_name: nil, sql_type_name: nil, nullable: true, data_default: nil },
150
+ hire_date: {
151
+ position: 4, data_type: "DATE", data_length: 7, data_precision: nil, data_scale: nil, char_used: nil,
152
+ type_owner: nil, type_name: nil, sql_type_name: nil, nullable: true, data_default: nil },
153
+ created_at: {
154
+ position: 5, data_type: "TIMESTAMP", data_length: 11, data_precision: nil, data_scale: 6, char_used: nil,
155
+ type_owner: nil, type_name: nil, sql_type_name: nil, nullable: true, data_default: nil },
156
+ status: {
157
+ position: 6, data_type: "VARCHAR2", data_length: 1, data_precision: nil, data_scale: nil, char_used: "B",
158
+ type_owner: nil, type_name: nil, sql_type_name: nil, nullable: true, data_default: "'N'" }
159
+ )
160
160
  end
161
161
 
162
162
  it "should get columns metadata for table with object columns" do
163
- expect(plsql.test_employees2.columns).to eq({
164
- :employee_id => {
165
- :position=>1, :data_type=>"NUMBER", :data_length=>22, :data_precision=>15, :data_scale=>0, :char_used=>nil,
166
- :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil, :nullable => false, :data_default => nil},
167
- :first_name => {
168
- :position=>2, :data_type=>"VARCHAR2", :data_length=>50, :data_precision=>nil, :data_scale=>nil, :char_used=>"B",
169
- :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil, :nullable => true, :data_default => nil},
170
- :last_name => {
171
- :position=>3, :data_type=>"VARCHAR2", :data_length=>50, :data_precision=>nil, :data_scale=>nil, :char_used=>"B",
172
- :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil, :nullable => true, :data_default => nil},
173
- :hire_date => {
174
- :position=>4, :data_type=>"DATE", :data_length=>7, :data_precision=>nil, :data_scale=>nil, :char_used=>nil,
175
- :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil, :nullable => true, :data_default => "SYSDATE"},
176
- :address => {
177
- :position=>5, :data_type=>"OBJECT", :data_length=>nil, :data_precision=>nil, :data_scale=>nil,
178
- :char_used=>nil, :type_owner=>"HR", :type_name=>"T_ADDRESS", :sql_type_name=>"HR.T_ADDRESS", :nullable => true, :data_default => nil},
179
- :phones => {
180
- :position=>6, :data_type=>"TABLE", :data_length=>nil, :data_precision=>nil, :data_scale=>nil, :char_used=>nil,
181
- :type_owner=>"HR", :type_name=>"T_PHONES", :sql_type_name=>"HR.T_PHONES", :nullable => true, :data_default => nil}
182
- })
163
+ expect(plsql.test_employees2.columns).to eq(
164
+ employee_id: {
165
+ position: 1, data_type: "NUMBER", data_length: 22, data_precision: 15, data_scale: 0, char_used: nil,
166
+ type_owner: nil, type_name: nil, sql_type_name: nil, nullable: false, data_default: nil },
167
+ first_name: {
168
+ position: 2, data_type: "VARCHAR2", data_length: 50, data_precision: nil, data_scale: nil, char_used: "B",
169
+ type_owner: nil, type_name: nil, sql_type_name: nil, nullable: true, data_default: nil },
170
+ last_name: {
171
+ position: 3, data_type: "VARCHAR2", data_length: 50, data_precision: nil, data_scale: nil, char_used: "B",
172
+ type_owner: nil, type_name: nil, sql_type_name: nil, nullable: true, data_default: nil },
173
+ hire_date: {
174
+ position: 4, data_type: "DATE", data_length: 7, data_precision: nil, data_scale: nil, char_used: nil,
175
+ type_owner: nil, type_name: nil, sql_type_name: nil, nullable: true, data_default: "SYSDATE" },
176
+ address: {
177
+ position: 5, data_type: "OBJECT", data_length: nil, data_precision: nil, data_scale: nil,
178
+ char_used: nil, type_owner: "HR", type_name: "T_ADDRESS", sql_type_name: "HR.T_ADDRESS", nullable: true, data_default: nil },
179
+ phones: {
180
+ position: 6, data_type: "TABLE", data_length: nil, data_precision: nil, data_scale: nil, char_used: nil,
181
+ type_owner: "HR", type_name: "T_PHONES", sql_type_name: "HR.T_PHONES", nullable: true, data_default: nil }
182
+ )
183
183
  end
184
184
 
185
185
  end
@@ -192,12 +192,12 @@ describe "Table" do
192
192
 
193
193
  it "should insert a record in table using partial list of columns" do
194
194
  plsql.test_employees.insert @employees.first.except(:hire_date)
195
- expect(plsql.test_employees.all).to eq([@employees.first.merge(:hire_date => nil)])
195
+ expect(plsql.test_employees.all).to eq([@employees.first.merge(hire_date: nil)])
196
196
  end
197
197
 
198
198
  it "should insert default value from table definition if value not provided" do
199
199
  plsql.test_employees.insert @employees.first.except(:status)
200
- expect(plsql.test_employees.all).to eq([@employees.first.merge(:status => 'N')])
200
+ expect(plsql.test_employees.all).to eq([@employees.first.merge(status: "N")])
201
201
  end
202
202
 
203
203
  it "should insert array of records in table" do
@@ -215,6 +215,11 @@ describe "Table" do
215
215
  expect(plsql.test_employees2.all("ORDER BY employee_id")).to eq(@employees2)
216
216
  end
217
217
 
218
+ it "should insert with case-insensetive table name" do
219
+ plsql.test_employees.insert @employees.first.map { |k, v| [k.upcase.to_sym, v] }.to_h
220
+ expect(plsql.test_employees.all).to eq([@employees.first])
221
+ end
222
+
218
223
  end
219
224
 
220
225
  describe "insert values" do
@@ -245,7 +250,7 @@ describe "Table" do
245
250
 
246
251
  it "should insert many records with list of some fields and array of values" do
247
252
  plsql.test_employees.insert_values @employees_some_fields, *@employees_some_values
248
- expect(plsql.test_employees.all).to eq(@employees.map{|e| e.merge(@employee_default_values)})
253
+ expect(plsql.test_employees.all).to eq(@employees.map { |e| e.merge(@employee_default_values) })
249
254
  end
250
255
 
251
256
  end
@@ -263,17 +268,17 @@ describe "Table" do
263
268
  it "should select all records in table" do
264
269
  expect(plsql.test_employees.select(:all, "ORDER BY employee_id")).to eq(@employees)
265
270
  expect(plsql.test_employees.all("ORDER BY employee_id")).to eq(@employees)
266
- expect(plsql.test_employees.all(:order_by => :employee_id)).to eq(@employees)
271
+ expect(plsql.test_employees.all(order_by: :employee_id)).to eq(@employees)
267
272
  end
268
273
 
269
274
  it "should select record in table using WHERE condition" do
270
275
  expect(plsql.test_employees.select(:first, "WHERE employee_id = :1", @employees.first[:employee_id])).to eq(@employees.first)
271
276
  expect(plsql.test_employees.first("WHERE employee_id = :1", @employees.first[:employee_id])).to eq(@employees.first)
272
- expect(plsql.test_employees.first(:employee_id => @employees.first[:employee_id])).to eq(@employees.first)
277
+ expect(plsql.test_employees.first(employee_id: @employees.first[:employee_id])).to eq(@employees.first)
273
278
  end
274
279
 
275
280
  it "should select records in table using WHERE condition and ORDER BY sorting" do
276
- expect(plsql.test_employees.all(:employee_id => @employees.first[:employee_id], :order_by => :employee_id)).to eq([@employees.first])
281
+ expect(plsql.test_employees.all(employee_id: @employees.first[:employee_id], order_by: :employee_id)).to eq([@employees.first])
277
282
  end
278
283
 
279
284
  it "should select record in table using :column => nil condition" do
@@ -282,7 +287,7 @@ describe "Table" do
282
287
  employee[:hire_date] = nil
283
288
  plsql.test_employees.insert employee
284
289
  expect(plsql.test_employees.first("WHERE hire_date IS NULL")).to eq(employee)
285
- expect(plsql.test_employees.first(:hire_date => nil)).to eq(employee)
290
+ expect(plsql.test_employees.first(hire_date: nil)).to eq(employee)
286
291
  end
287
292
 
288
293
  it "should select record in table using :column => :is_null condition" do
@@ -290,7 +295,7 @@ describe "Table" do
290
295
  employee[:employee_id] = employee[:employee_id] + 1
291
296
  employee[:hire_date] = nil
292
297
  plsql.test_employees.insert employee
293
- expect(plsql.test_employees.first(:hire_date => :is_null)).to eq(employee)
298
+ expect(plsql.test_employees.first(hire_date: :is_null)).to eq(employee)
294
299
  end
295
300
 
296
301
  it "should select record in table using :column => :is_not_null condition" do
@@ -298,7 +303,7 @@ describe "Table" do
298
303
  employee[:employee_id] = employee[:employee_id] + 1
299
304
  employee[:hire_date] = nil
300
305
  plsql.test_employees.insert employee
301
- expect(plsql.test_employees.all(:hire_date => :is_not_null, :order_by => :employee_id)).to eq(@employees)
306
+ expect(plsql.test_employees.all(hire_date: :is_not_null, order_by: :employee_id)).to eq(@employees)
302
307
  end
303
308
 
304
309
  it "should count records in table" do
@@ -317,26 +322,26 @@ describe "Table" do
317
322
  it "should update a record in table" do
318
323
  employee_id = @employees.first[:employee_id]
319
324
  plsql.test_employees.insert @employees.first
320
- plsql.test_employees.update :first_name => 'Test', :where => {:employee_id => employee_id}
321
- expect(plsql.test_employees.first(:employee_id => employee_id)[:first_name]).to eq('Test')
325
+ plsql.test_employees.update first_name: "Test", where: { employee_id: employee_id }
326
+ expect(plsql.test_employees.first(employee_id: employee_id)[:first_name]).to eq("Test")
322
327
  end
323
328
 
324
329
  it "should update a record in table using String WHERE condition" do
325
330
  employee_id = @employees.first[:employee_id]
326
331
  plsql.test_employees.insert @employees
327
- plsql.test_employees.update :first_name => 'Test', :where => "employee_id = #{employee_id}"
328
- expect(plsql.test_employees.first(:employee_id => employee_id)[:first_name]).to eq('Test')
332
+ plsql.test_employees.update first_name: "Test", where: "employee_id = #{employee_id}"
333
+ expect(plsql.test_employees.first(employee_id: employee_id)[:first_name]).to eq("Test")
329
334
  # all other records should not be changed
330
335
  plsql.test_employees.all("WHERE employee_id > :1", employee_id) do |employee|
331
- expect(employee[:first_name]).not_to eq('Test')
336
+ expect(employee[:first_name]).not_to eq("Test")
332
337
  end
333
338
  end
334
339
 
335
340
  it "should update all records in table" do
336
341
  plsql.test_employees.insert @employees
337
- plsql.test_employees.update :first_name => 'Test'
342
+ plsql.test_employees.update first_name: "Test"
338
343
  plsql.test_employees.all do |employee|
339
- expect(employee[:first_name]).to eq('Test')
344
+ expect(employee[:first_name]).to eq("Test")
340
345
  end
341
346
  end
342
347
 
@@ -344,8 +349,8 @@ describe "Table" do
344
349
  employee = @employees2[0]
345
350
  employee2 = @employees2[1]
346
351
  plsql.test_employees2.insert employee
347
- plsql.test_employees2.update :address => employee2[:address], :phones => employee2[:phones], :where => {:employee_id => employee[:employee_id]}
348
- updated_employee = plsql.test_employees2.first(:employee_id => employee[:employee_id])
352
+ plsql.test_employees2.update address: employee2[:address], phones: employee2[:phones], where: { employee_id: employee[:employee_id] }
353
+ updated_employee = plsql.test_employees2.first(employee_id: employee[:employee_id])
349
354
  expect(updated_employee[:address]).to eq(employee2[:address])
350
355
  expect(updated_employee[:phones]).to eq(employee2[:phones])
351
356
  end
@@ -356,9 +361,9 @@ describe "Table" do
356
361
  it "should delete record from table" do
357
362
  employee_id = @employees.first[:employee_id]
358
363
  plsql.test_employees.insert @employees
359
- plsql.test_employees.delete :employee_id => employee_id
360
- expect(plsql.test_employees.first(:employee_id => employee_id)).to be_nil
361
- expect(plsql.test_employees.all(:order_by => :employee_id)).to eq(@employees[1, @employees.size-1])
364
+ plsql.test_employees.delete employee_id: employee_id
365
+ expect(plsql.test_employees.first(employee_id: employee_id)).to be_nil
366
+ expect(plsql.test_employees.all(order_by: :employee_id)).to eq(@employees[1, @employees.size - 1])
362
367
  end
363
368
 
364
369
  it "should delete all records from table" do