rsim / ruby-plsql-spec

Oracle PL/SQL unit testing with Ruby
MIT License
68 stars 25 forks source link

Objects not null when passed as parameter. #7

Closed wcmatthysen closed 8 years ago

wcmatthysen commented 13 years ago

Hi there,

When I create the following PL/SQL type:

CREATE OR REPLACE TYPE PERSON
IS
  OBJECT
  (
    name     VARCHAR2(255),
    surname  VARCHAR2(255),
    age      NUMBER(10, 0)
  );

and the following procedure for testing purposes:

CREATE OR REPLACE PROCEDURE test_person(arg PERSON) AS
BEGIN
  IF arg IS NULL THEN
    RAISE_APPLICATION_ERROR(-20001, 'Person cannot be null.');
  END IF;
END;

and create the following test:

require "spec_helper"

describe "People Suite" do
  it "should break when called with a NULL parameter" do
    lambda do
      plsql.test_person(NULL)
    end.should raise_error(/ORA-20001/)
  end
end

I get the following error when I call the test_person procedure:

Failures:

1) People Suite should break when called with a NULL parameter Failure/Error: lambda do expected Exception with message matching /ORA-20001/ but nothing was raised

./spec/Test_spec.rb:5

I would have suspected the test_person to throw an exception when calling with a NULL parameter but it did not. Any help would be very much appreciated.

Regards,

Wiehann

rsim commented 13 years ago

This is issue with ruby-oci8 gem which does not allow to bind NULL value to object type argument - see http://rubyforge.org/forum/message.php?msg_id=91602

I asked ruby-oci8 maintainer one more time to think about possible solution :)

wcmatthysen commented 13 years ago

Thanks Raimonds, I will watch the rubyforge forums for this. Should I leave this ticket open for the time-being? The reason I ask is that it is actually a ruby-oci8 issue and not a ruby-plsql-spec issue.

rsim commented 13 years ago

You can leave this open so that it will remind me this issue as well :) Maybe I will think of some workaround for this ruby-oci8 issue.

rsim commented 13 years ago

I tested with latest ruby-oci8 development version (with patch from Kubo) and now it works that you can pass NULL values to object type parameters.

To try it out you need to get the latest development version of ruby-oci8 and install it as gem:

svn checkout http://ruby-oci8.rubyforge.org/svn/trunk/ruby-oci8
cd ruby-oci8
gem build ruby-oci8.gemspec
gem install ruby-oci8-2.1.x.gem

To be sure that in your tests you are using this version 2.1.x try this

puts OCI8::VERSION
jgebal commented 8 years ago

is it resolved?

jgebal commented 8 years ago

Just tested it - it's resolved. Can be closed.