ruby-plsql 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,10 +6,11 @@ describe "Table" do
6
6
  plsql.connection.autocommit = false
7
7
  plsql.execute <<-SQL
8
8
  CREATE TABLE test_employees (
9
- employee_id NUMBER(15),
9
+ employee_id NUMBER(15) NOT NULL,
10
10
  first_name VARCHAR2(50),
11
11
  last_name VARCHAR2(50),
12
12
  hire_date DATE,
13
+ created_at TIMESTAMP,
13
14
  status VARCHAR2(1) DEFAULT 'N'
14
15
  )
15
16
  SQL
@@ -32,10 +33,10 @@ describe "Table" do
32
33
  SQL
33
34
  plsql.execute <<-SQL
34
35
  CREATE TABLE test_employees2 (
35
- employee_id NUMBER(15),
36
+ employee_id NUMBER(15) NOT NULL,
36
37
  first_name VARCHAR2(50),
37
38
  last_name VARCHAR2(50),
38
- hire_date DATE,
39
+ hire_date DATE DEFAULT SYSDATE,
39
40
  address t_address,
40
41
  phones t_phones
41
42
  )
@@ -46,14 +47,15 @@ describe "Table" do
46
47
  :first_name => "First #{i}",
47
48
  :last_name => "Last #{i}",
48
49
  :hire_date => Time.local(2000,01,i),
50
+ :created_at => Time.local(2000,01,i,9,15,30,i),
49
51
  :status => 'A'
50
52
  }
51
53
  end
52
- @employees_all_fields = [:employee_id, :first_name, :last_name, :hire_date, :status]
54
+ @employees_all_fields = [:employee_id, :first_name, :last_name, :hire_date, :created_at, :status]
53
55
  @employees_all_values = @employees.map{|e| @employees_all_fields.map{|f| e[f]}}
54
56
  @employees_some_fields = [:employee_id, :first_name, :last_name]
55
57
  @employees_some_values = @employees.map{|e| @employees_some_fields.map{|f| e[f]}}
56
- @employee_default_values = {:hire_date => nil, :status => 'N'}
58
+ @employee_default_values = {:hire_date => nil, :created_at => nil, :status => 'N'}
57
59
 
58
60
  @employees2 = (1..10).map do |i|
59
61
  {
@@ -131,38 +133,52 @@ describe "Table" do
131
133
  describe "columns" do
132
134
 
133
135
  it "should get column names for table" do
134
- plsql.test_employees.column_names.should == [:employee_id, :first_name, :last_name, :hire_date, :status]
136
+ plsql.test_employees.column_names.should == @employees_all_fields
135
137
  end
136
138
 
137
139
  it "should get columns metadata for table" do
138
140
  plsql.test_employees.columns.should == {
139
- :employee_id =>
140
- {:position=>1, :data_type=>"NUMBER", :data_length=>22, :data_precision=>15, :data_scale=>0, :char_used=>nil, :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil},
141
- :first_name =>
142
- {:position=>2, :data_type=>"VARCHAR2", :data_length=>50, :data_precision=>nil, :data_scale=>nil, :char_used=>"B", :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil},
143
- :last_name =>
144
- {:position=>3, :data_type=>"VARCHAR2", :data_length=>50, :data_precision=>nil, :data_scale=>nil, :char_used=>"B", :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil},
145
- :hire_date =>
146
- {:position=>4, :data_type=>"DATE", :data_length=>7, :data_precision=>nil, :data_scale=>nil, :char_used=>nil, :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil},
147
- :status =>
148
- {:position=>5, :data_type=>"VARCHAR2", :data_length=>1, :data_precision=>nil, :data_scale=>nil, :char_used=>"B", :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil}
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'"}
149
159
  }
150
160
  end
151
161
 
152
162
  it "should get columns metadata for table with object columns" do
153
163
  plsql.test_employees2.columns.should == {
154
- :employee_id =>
155
- {:position=>1, :data_type=>"NUMBER", :data_length=>22, :data_precision=>15, :data_scale=>0, :char_used=>nil, :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil},
156
- :first_name =>
157
- {:position=>2, :data_type=>"VARCHAR2", :data_length=>50, :data_precision=>nil, :data_scale=>nil, :char_used=>"B", :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil},
158
- :last_name =>
159
- {:position=>3, :data_type=>"VARCHAR2", :data_length=>50, :data_precision=>nil, :data_scale=>nil, :char_used=>"B", :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil},
160
- :hire_date =>
161
- {:position=>4, :data_type=>"DATE", :data_length=>7, :data_precision=>nil, :data_scale=>nil, :char_used=>nil, :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil},
162
- :address =>
163
- {:position=>5, :data_type=>"OBJECT", :data_length=>nil, :data_precision=>nil, :data_scale=>nil, :char_used=>nil, :type_owner=>"HR", :type_name=>"T_ADDRESS", :sql_type_name=>"HR.T_ADDRESS"},
164
- :phones =>
165
- {:position=>6, :data_type=>"TABLE", :data_length=>nil, :data_precision=>nil, :data_scale=>nil, :char_used=>nil, :type_owner=>"HR", :type_name=>"T_PHONES", :sql_type_name=>"HR.T_PHONES"}
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}
166
182
  }
167
183
  end
168
184
 
@@ -256,6 +272,10 @@ describe "Table" do
256
272
  plsql.test_employees.first(:employee_id => @employees.first[:employee_id]).should == @employees.first
257
273
  end
258
274
 
275
+ it "should select records in table using WHERE condition and ORBER BY sorting" do
276
+ plsql.test_employees.all(:employee_id => @employees.first[:employee_id], :order_by => :employee_id).should == [@employees.first]
277
+ end
278
+
259
279
  it "should select record in table using :column => nil condition" do
260
280
  employee = @employees.last
261
281
  employee[:employee_id] = employee[:employee_id] + 1
@@ -5,12 +5,67 @@ describe "Type" do
5
5
  plsql.connection = get_connection
6
6
  plsql.execute "DROP TYPE t_employee" rescue nil
7
7
  plsql.execute "DROP TYPE t_phones" rescue nil
8
+ plsql.execute "DROP TYPE t_phone" rescue nil
8
9
  plsql.execute <<-SQL
9
10
  CREATE OR REPLACE TYPE t_address AS OBJECT (
10
11
  street VARCHAR2(50),
11
12
  city VARCHAR2(50),
12
- country VARCHAR2(50)
13
- )
13
+ country VARCHAR2(50),
14
+ CONSTRUCTOR FUNCTION t_address(p_full_address VARCHAR2)
15
+ RETURN SELF AS RESULT,
16
+ MEMBER FUNCTION display_address(p_separator VARCHAR2 DEFAULT ',') RETURN VARCHAR2,
17
+ MEMBER FUNCTION display_address(p_uppercase BOOLEAN, p_separator VARCHAR2 DEFAULT ',') RETURN VARCHAR2,
18
+ MEMBER PROCEDURE set_country(p_country VARCHAR2),
19
+ MEMBER PROCEDURE set_country2(p_country VARCHAR2, x_display_address OUT VARCHAR2),
20
+ STATIC FUNCTION create_address(p_full_address VARCHAR2) RETURN t_address
21
+ );
22
+ SQL
23
+ plsql.execute <<-SQL
24
+ CREATE OR REPLACE TYPE BODY t_address AS
25
+ CONSTRUCTOR FUNCTION t_address(p_full_address VARCHAR2)
26
+ RETURN SELF AS RESULT
27
+ AS
28
+ l_comma1_pos INTEGER;
29
+ l_comma2_pos INTEGER;
30
+ BEGIN
31
+ l_comma1_pos := INSTR(p_full_address, ',', 1, 1);
32
+ l_comma2_pos := INSTR(p_full_address, ',', 1, 2);
33
+ SELF.street := TRIM(SUBSTR(p_full_address, 1, l_comma1_pos - 1));
34
+ SELF.city := TRIM(SUBSTR(p_full_address, l_comma1_pos+1, l_comma2_pos - l_comma1_pos - 1));
35
+ SELF.country := TRIM(SUBSTR(p_full_address, l_comma2_pos+1));
36
+ RETURN;
37
+ END;
38
+ MEMBER FUNCTION display_address(p_separator VARCHAR2) RETURN VARCHAR2 IS
39
+ l_separator VARCHAR2(10) := p_separator;
40
+ BEGIN
41
+ IF SUBSTR(l_separator,-1) != ' ' THEN
42
+ l_separator := l_separator || ' ';
43
+ END IF;
44
+ RETURN SELF.street || l_separator || SELF.city || l_separator || SELF.country;
45
+ END;
46
+ MEMBER FUNCTION display_address(p_uppercase BOOLEAN, p_separator VARCHAR2) RETURN VARCHAR2 IS
47
+ l_separator VARCHAR2(10) := p_separator;
48
+ BEGIN
49
+ IF p_uppercase THEN
50
+ RETURN UPPER(SELF.display_address(p_separator));
51
+ ELSE
52
+ RETURN SELF.display_address(p_separator);
53
+ END IF;
54
+ END;
55
+ MEMBER PROCEDURE set_country(p_country VARCHAR2) IS
56
+ BEGIN
57
+ SELF.country := p_country;
58
+ END;
59
+ MEMBER PROCEDURE set_country2(p_country VARCHAR2, x_display_address OUT VARCHAR2) IS
60
+ BEGIN
61
+ SELF.country := p_country;
62
+ x_display_address := SELF.display_address();
63
+ END;
64
+ STATIC FUNCTION create_address(p_full_address VARCHAR2) RETURN t_address IS
65
+ BEGIN
66
+ RETURN t_address(p_full_address);
67
+ END;
68
+ END;
14
69
  SQL
15
70
  plsql.execute <<-SQL
16
71
  CREATE OR REPLACE TYPE t_phone AS OBJECT (
@@ -130,4 +185,120 @@ describe "Type" do
130
185
 
131
186
  end
132
187
 
188
+ describe "object instance" do
189
+ before(:all) do
190
+ @phone_attributes = {:type => 'mobile', :phone_number => '123456'}
191
+ @address_attributes = {:street => 'Street', :city => 'City', :country => 'Country'}
192
+ @full_address = "#{@address_attributes[:street]}, #{@address_attributes[:city]}, #{@address_attributes[:country]}"
193
+ end
194
+
195
+ it "should get new object instance using named parameters" do
196
+ plsql.t_phone(@phone_attributes).should == @phone_attributes
197
+ end
198
+
199
+ it "should be an ObjectInstance" do
200
+ plsql.t_phone(@phone_attributes).should be_a(PLSQL::ObjectInstance)
201
+ end
202
+
203
+ it "should get new object instance using sequential parameters" do
204
+ plsql.t_phone(@phone_attributes[:type], @phone_attributes[:phone_number]).should == @phone_attributes
205
+ end
206
+
207
+ it "should get new object instance using custom constructor" do
208
+ plsql.t_address(@full_address).should == @address_attributes
209
+ plsql.t_address(:p_full_address => @full_address).should == @address_attributes
210
+ end
211
+
212
+ it "should get new object instance using default constructor when custom constructor exists" do
213
+ plsql.t_address(@address_attributes).should == @address_attributes
214
+ plsql.t_address(@address_attributes[:street], @address_attributes[:city], @address_attributes[:country]).should == @address_attributes
215
+ end
216
+
217
+ it "should get new empty collection of objects instance" do
218
+ plsql.t_phones.new.should == []
219
+ plsql.t_phones([]).should == []
220
+ end
221
+
222
+ it "should get new collection of objects instances" do
223
+ phone = plsql.t_phone(@phone_attributes)
224
+ plsql.t_phones([phone, phone]).should == [phone, phone]
225
+ plsql.t_phones(phone, phone).should == [phone, phone]
226
+ plsql.t_phones(@phone_attributes, @phone_attributes).should == [phone, phone]
227
+ end
228
+
229
+ end
230
+
231
+ describe "member procedures" do
232
+ before(:all) do
233
+ @address_attributes = {:street => 'Street', :city => 'City', :country => 'Country'}
234
+ @full_address = "#{@address_attributes[:street]}, #{@address_attributes[:city]}, #{@address_attributes[:country]}"
235
+ end
236
+
237
+ it "should call object instance member function without parameters" do
238
+ plsql.t_address(@address_attributes).display_address.should == @full_address
239
+ end
240
+
241
+ it "should call object instance member function with parameters" do
242
+ plsql.t_address(@address_attributes).display_address(',').should == @full_address
243
+ end
244
+
245
+ it "should call object instance member function with named parameters" do
246
+ plsql.t_address(@address_attributes).display_address(:p_separator => ',').should == @full_address
247
+ end
248
+
249
+ it "should call object overloaded instance member function" do
250
+ plsql.t_address(@address_attributes).display_address(true).should == @full_address.upcase
251
+ plsql.t_address(@address_attributes).display_address(true, ',').should == @full_address.upcase
252
+ end
253
+
254
+ it "should call object instance member function with explicit first SELF parameter" do
255
+ plsql.t_address.display_address(@address_attributes, ',').should == @full_address
256
+ end
257
+
258
+ it "should call object instance member function with explicit named SELF parameter" do
259
+ plsql.t_address.display_address(:self => @address_attributes, :p_separator => ',').should == @full_address
260
+ end
261
+
262
+ it "should call object instance member procedure" do
263
+ other_country = "Other"
264
+ plsql.t_address(@address_attributes).set_country(other_country).should == @address_attributes.merge(:country => other_country)
265
+ end
266
+
267
+ it "should call object instance member procedure with output parameters" do
268
+ other_country = "Other"
269
+ plsql.t_address(@address_attributes).set_country2(other_country).should ==
270
+ [@address_attributes.merge(:country => other_country),
271
+ {:x_display_address => "#{@address_attributes[:street]}, #{@address_attributes[:city]}, #{other_country}"}]
272
+ end
273
+
274
+ it "should raise error if invalid member procedure is called" do
275
+ lambda do
276
+ plsql.t_address(@address_attributes).invalid_procedure
277
+ end.should raise_error(ArgumentError)
278
+ end
279
+
280
+ end
281
+
282
+ describe "static procedures" do
283
+ before(:all) do
284
+ @address_attributes = {:street => 'Street', :city => 'City', :country => 'Country'}
285
+ @full_address = "#{@address_attributes[:street]}, #{@address_attributes[:city]}, #{@address_attributes[:country]}"
286
+ end
287
+
288
+ it "should call object type static function" do
289
+ plsql.t_address.create_address(@full_address).should == @address_attributes
290
+ end
291
+
292
+ it "should call object type static function with named parameters" do
293
+ plsql.t_address.create_address(:p_full_address => @full_address).should == @address_attributes
294
+ end
295
+
296
+ it "should raise error if invalid static procedure is called" do
297
+ lambda do
298
+ plsql.t_address.invalid_procedure
299
+ end.should raise_error(ArgumentError)
300
+ end
301
+
302
+ end
303
+
133
304
  end
@@ -21,6 +21,8 @@ describe "Package variables /" do
21
21
  varchar2_default varchar2(50) := 'default' ;
22
22
  varchar2_default2 varchar2(50) DEFAULT 'default';
23
23
  varchar2_default3 varchar2(50) NOT NULL := 'default';
24
+ varchar2_3_char VARCHAR2(3 CHAR);
25
+ varchar2_3_byte VARCHAR2(3 BYTE);
24
26
  char_variable char(10) ;
25
27
  nvarchar2_variable NVARCHAR2(50);
26
28
  nchar_variable NCHAR(10);
@@ -53,6 +55,19 @@ describe "Package variables /" do
53
55
  plsql.test_package.varchar2_default3.should == 'default'
54
56
  end
55
57
 
58
+ it "should set and get VARCHAR2(n CHAR) variable" do
59
+ plsql.test_package.varchar2_3_char = 'āčē'
60
+ plsql.test_package.varchar2_3_char.should == 'āčē'
61
+ lambda { plsql.test_package.varchar2_3_char = 'aceg' }.should raise_error(/buffer too small/)
62
+ end
63
+
64
+ it "should set and get VARCHAR2(n BYTE) variable" do
65
+ plsql.test_package.varchar2_3_byte = 'ace'
66
+ plsql.test_package.varchar2_3_byte.should == 'ace'
67
+ lambda { plsql.test_package.varchar2_3_byte = 'āce' }.should raise_error(/buffer too small/)
68
+ lambda { plsql.test_package.varchar2_3_byte = 'aceg' }.should raise_error(/buffer too small/)
69
+ end
70
+
56
71
  it "should set and get CHAR variable" do
57
72
  plsql.test_package.char_variable = 'abc'
58
73
  plsql.test_package.char_variable.should == 'abc' + ' '*7
@@ -356,6 +371,7 @@ describe "Package variables /" do
356
371
  plsql.execute <<-SQL
357
372
  CREATE OR REPLACE PACKAGE test_package IS
358
373
  g_employee t_employee;
374
+ g_employee2 hr.t_employee;
359
375
  g_phones t_phones;
360
376
  END;
361
377
  SQL
@@ -379,6 +395,11 @@ describe "Package variables /" do
379
395
  plsql.test_package.g_employee.should == @employee
380
396
  end
381
397
 
398
+ it "should set and get object type variable when schema prefix is used with type" do
399
+ plsql.hr.test_package.g_employee2 = @employee
400
+ plsql.hr.test_package.g_employee2.should == @employee
401
+ end
402
+
382
403
  it "should set and get collection type variable" do
383
404
  plsql.test_package.g_phones = @phones
384
405
  plsql.test_package.g_phones.should == @phones
@@ -6,7 +6,7 @@ describe "View" do
6
6
  plsql.connection.autocommit = false
7
7
  plsql.execute <<-SQL
8
8
  CREATE TABLE test_employees (
9
- employee_id NUMBER(15),
9
+ employee_id NUMBER(15) NOT NULL,
10
10
  first_name VARCHAR2(50),
11
11
  last_name VARCHAR2(50),
12
12
  hire_date DATE,
@@ -97,16 +97,21 @@ describe "View" do
97
97
 
98
98
  it "should get columns metadata for view" do
99
99
  plsql.test_employees_v.columns.should == {
100
- :employee_id =>
101
- {:position=>1, :data_type=>"NUMBER", :data_length=>22, :data_precision=>15, :data_scale=>0, :char_used=>nil, :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil},
102
- :first_name =>
103
- {:position=>2, :data_type=>"VARCHAR2", :data_length=>50, :data_precision=>nil, :data_scale=>nil, :char_used=>"B", :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil},
104
- :last_name =>
105
- {:position=>3, :data_type=>"VARCHAR2", :data_length=>50, :data_precision=>nil, :data_scale=>nil, :char_used=>"B", :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil},
106
- :hire_date =>
107
- {:position=>4, :data_type=>"DATE", :data_length=>7, :data_precision=>nil, :data_scale=>nil, :char_used=>nil, :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil},
108
- :status =>
109
- {:position=>5, :data_type=>"VARCHAR2", :data_length=>1, :data_precision=>nil, :data_scale=>nil, :char_used=>"B", :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil}
100
+ :employee_id => {
101
+ :position=>1, :data_type=>"NUMBER", :data_length=>22, :data_precision=>15, :data_scale=>0, :char_used=>nil,
102
+ :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil, :nullable => false, :data_default => nil},
103
+ :first_name => {
104
+ :position=>2, :data_type=>"VARCHAR2", :data_length=>50, :data_precision=>nil, :data_scale=>nil, :char_used=>"B",
105
+ :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil, :nullable => true, :data_default => nil},
106
+ :last_name => {
107
+ :position=>3, :data_type=>"VARCHAR2", :data_length=>50, :data_precision=>nil, :data_scale=>nil, :char_used=>"B",
108
+ :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil, :nullable => true, :data_default => nil},
109
+ :hire_date => {
110
+ :position=>4, :data_type=>"DATE", :data_length=>7, :data_precision=>nil, :data_scale=>nil, :char_used=>nil,
111
+ :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil, :nullable => true, :data_default => nil},
112
+ :status => {
113
+ :position=>5, :data_type=>"VARCHAR2", :data_length=>1, :data_precision=>nil, :data_scale=>nil, :char_used=>"B",
114
+ :type_owner=>nil, :type_name=>nil, :sql_type_name=>nil, :nullable => true, :data_default => nil}
110
115
  }
111
116
  end
112
117
 
data/spec/spec_helper.rb CHANGED
@@ -2,18 +2,22 @@ require "rubygems"
2
2
  gem "rspec"
3
3
  require "spec"
4
4
 
5
- gem "activerecord"
6
- require "active_record"
7
- gem "activerecord-oracle_enhanced-adapter"
5
+ unless ENV['NO_ACTIVERECORD']
6
+ # avoid loading activerecord 3.0 beta
7
+ gem "activerecord", "= 2.3.5"
8
+ require "active_record"
9
+ gem "activerecord-oracle_enhanced-adapter", "= 1.2.4"
10
+ else
11
+ puts "Without ActiveRecord"
12
+ end
8
13
 
9
14
  if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby'
10
- # gem "ruby-oci8", "=2.0.2"
11
15
  gem "ruby-oci8", ">=2.0.3"
12
16
  end
13
17
 
14
18
  $:.unshift(File.dirname(__FILE__) + '/../lib')
15
19
 
16
- require "ruby_plsql"
20
+ require "ruby-plsql"
17
21
 
18
22
  DATABASE_NAME = ENV['DATABASE_NAME'] || 'orcl'
19
23
  DATABASE_HOST = ENV['DATABASE_HOST'] || 'localhost'
@@ -54,3 +58,13 @@ CONNECTION_PARAMS = {
54
58
  :username => DATABASE_USERS_AND_PASSWORDS[0][0],
55
59
  :password => DATABASE_USERS_AND_PASSWORDS[0][1]
56
60
  }
61
+
62
+ class Hash
63
+ def except(*blacklist)
64
+ self.reject {|key, value| blacklist.include?(key) }
65
+ end unless method_defined?(:except)
66
+
67
+ def only(*whitelist)
68
+ self.reject {|key, value| !whitelist.include?(key) }
69
+ end unless method_defined?(:only)
70
+ end