[ruby-oci8-commit] [569] trunk/ruby-oci8: Fix to bind object types by name as OCI8:: Cursor#bind_param(pos, val, :named_type, typename).

nobody at rubyforge.org nobody at rubyforge.org
Sun Jun 23 09:40:55 UTC 2013


Revision: 569
Author:   kubo
Date:     2013-06-23 09:40:55 +0000 (Sun, 23 Jun 2013)
Log Message:
-----------
Fix to bind object types by name as OCI8::Cursor#bind_param(pos, val, :named_type, typename).

Modified Paths:
--------------
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/lib/oci8/cursor.rb
    trunk/ruby-oci8/lib/oci8/object.rb
    trunk/ruby-oci8/test/test_object.rb

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2013-06-23 09:24:51 UTC (rev 568)
+++ trunk/ruby-oci8/ChangeLog	2013-06-23 09:40:55 UTC (rev 569)
@@ -1,4 +1,10 @@
 2013-06-23  KUBO Takehiro  <kubo at jiubao.org>
+	* lib/oci8/cursor.rb, lib/oci8/object.rb: fix to bind object types by
+	    name as OCI8::Cursor#bind_param(pos, val, :named_type, typename).
+	* test/test_object.rb: fix to test OCI8::Cursor#bind_param(pos, val,
+	    :named_type, typename).
+
+2013-06-23  KUBO Takehiro  <kubo at jiubao.org>
 	* lib/oci8/metadata.rb: OCI8#describe_synonym and OCI8#describe_any
 	    accept 'PUBLIC.XXX' as a public synonym name.
 	* test/test_metadata.rb: add tests for OCI8#describe_synonym.

Modified: trunk/ruby-oci8/lib/oci8/cursor.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/cursor.rb	2013-06-23 09:24:51 UTC (rev 568)
+++ trunk/ruby-oci8/lib/oci8/cursor.rb	2013-06-23 09:40:55 UTC (rev 569)
@@ -478,6 +478,8 @@
         elsif key.class == Class && key < OCI8::Object::Base
           param = @con.get_tdo_by_class(key)
           key = :named_type
+        elsif key == :named_type
+          param = @con.get_tdo_by_typename(param[:length])
         end
       when OCI8::Metadata::Base
         key = param.data_type

Modified: trunk/ruby-oci8/lib/oci8/object.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/object.rb	2013-06-23 09:24:51 UTC (rev 568)
+++ trunk/ruby-oci8/lib/oci8/object.rb	2013-06-23 09:40:55 UTC (rev 569)
@@ -71,6 +71,29 @@
     OCI8::TDO.new(self, metadata, klass)
   end
 
+  # Returns the type descriptor object which correspond to the given type name.
+  #
+  # @param [String] typename
+  # @return [OCI8::TDO]
+  #
+  # @private
+  def get_tdo_by_typename(typename)
+    tdo = @name_to_tdo && @name_to_tdo[typename]
+    return tdo if tdo
+
+    metadata = describe_any(typename)
+    if metadata.is_a? OCI8::Metadata::Synonym
+      metadata = describe_any(metadata.translated_name)
+    end
+    unless metadata.is_a? OCI8::Metadata::Type
+      raise "unknown typename #{typename}"
+    end
+    tdo = get_tdo_by_metadata(metadata)
+
+    @name_to_tdo[typename] = tdo
+    tdo
+  end
+
   # A helper class to bind arguments.
   #
   # @private

Modified: trunk/ruby-oci8/test/test_object.rb
===================================================================
--- trunk/ruby-oci8/test/test_object.rb	2013-06-23 09:24:51 UTC (rev 568)
+++ trunk/ruby-oci8/test/test_object.rb	2013-06-23 09:40:55 UTC (rev 569)
@@ -447,7 +447,7 @@
 END;
 EOS
     [nil, [], [1, nil, 3]].each do |ary|
-      csr.bind_param(:in, ary, RbTestIntArray)
+      csr.bind_param(:in, ary, :named_type, 'rb_test_int_array')
       csr.bind_param(:cnt, nil, Integer)
       csr.bind_param(:out1, nil, Integer)
       csr.bind_param(:out2, nil, Integer)



More information about the ruby-oci8-commit mailing list