[pypy-svn] r69590 - in pypy/trunk/pypy/module/oracle: . test

afa at codespeak.net afa at codespeak.net
Tue Nov 24 16:56:24 CET 2009


Author: afa
Date: Tue Nov 24 16:56:24 2009
New Revision: 69590

Modified:
   pypy/trunk/pypy/module/oracle/__init__.py
   pypy/trunk/pypy/module/oracle/interp_error.py
   pypy/trunk/pypy/module/oracle/interp_variable.py
   pypy/trunk/pypy/module/oracle/test/test_cursorvar.py
Log:
Implement ref cursors retrieved from a PL/SQL package.


Modified: pypy/trunk/pypy/module/oracle/__init__.py
==============================================================================
--- pypy/trunk/pypy/module/oracle/__init__.py	(original)
+++ pypy/trunk/pypy/module/oracle/__init__.py	Tue Nov 24 16:56:24 2009
@@ -14,6 +14,7 @@
         'LONG_STRING': 'interp_variable.VT_LongString',
         'LONG_BINARY': 'interp_variable.VT_LongBinary',
         'FIXED_CHAR': 'interp_variable.VT_FixedChar',
+        'CURSOR': 'interp_variable.VT_Cursor',
         'Variable': 'interp_variable.W_Variable',
         'Timestamp': 'interp_error.get(space).w_DateTimeType',
         'Date': 'interp_error.get(space).w_DateType',

Modified: pypy/trunk/pypy/module/oracle/interp_error.py
==============================================================================
--- pypy/trunk/pypy/module/oracle/interp_error.py	(original)
+++ pypy/trunk/pypy/module/oracle/interp_error.py	Tue Nov 24 16:56:24 2009
@@ -75,7 +75,7 @@
                 pass
 
     def desc_str(self):
-        return self.message
+        return self.w_message
 
 W_Error.typedef = TypeDef(
     'Error',

Modified: pypy/trunk/pypy/module/oracle/interp_variable.py
==============================================================================
--- pypy/trunk/pypy/module/oracle/interp_variable.py	(original)
+++ pypy/trunk/pypy/module/oracle/interp_variable.py	Tue Nov 24 16:56:24 2009
@@ -835,6 +835,12 @@
                 i)
             dataptr[0] = tempCursor.handle
 
+    def getValueProc(self, space, pos):
+        from pypy.module.oracle import interp_cursor
+        w_cursor = self.cursors_w[pos]
+        space.interp_w(interp_cursor.W_Cursor, w_cursor).statementType = -1
+        return w_cursor
+
     def setValueProc(self, space, pos, w_value):
         from pypy.module.oracle import interp_cursor
         w_CursorType = space.gettypeobject(interp_cursor.W_Cursor.typedef)

Modified: pypy/trunk/pypy/module/oracle/test/test_cursorvar.py
==============================================================================
--- pypy/trunk/pypy/module/oracle/test/test_cursorvar.py	(original)
+++ pypy/trunk/pypy/module/oracle/test/test_cursorvar.py	Tue Nov 24 16:56:24 2009
@@ -17,3 +17,29 @@
                 [('NUMBERCOL', oracle.NUMBER, 127, 2, 0, -127, 1)])
         data = cursor.fetchall()
         assert data == [(1,)]
+
+    def test_bind_frompackage(self):
+        cur = self.cnx.cursor()
+        # create package
+        try:
+            cur.execute("drop package pypy_temp_cursorpkg")
+        except oracle.DatabaseError:
+            pass
+        cur.execute("""
+            create package pypy_temp_cursorpkg as
+                type refcur is ref cursor;
+                procedure test_cursor(cur out refcur);
+            end;""")
+        cur.execute("""
+            create package body pypy_temp_cursorpkg as
+                procedure test_cursor(cur out refcur) is
+                begin
+                    open cur for
+                      select level-1 intcol
+                      from dual connect by level-1<42;
+                end;
+            end;""")
+        cursor = self.cnx.cursor()
+        cur.callproc("pypy_temp_cursorpkg.test_cursor", (cursor,))
+        data = cursor.fetchall()
+        assert data == [(x,) for x in range(42)]



More information about the Pypy-commit mailing list