Skip to content

Commit

Permalink
Added support for smallint and float data types in Oracle objects, as…
Browse files Browse the repository at this point in the history
… requested

(#4).
  • Loading branch information
anthony-tuininga committed Apr 5, 2017
1 parent 6c64e5f commit 7f70d18
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions doc/src/releasenotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Version 6.0 (TBD)
:ref:`subscription objects <subscrobj>`. Use the qos attribute instead.
15) Dropped deprecated parameters cqqos and rowids from the
:meth:`Connection.subscribe()` method.
16) Added support for smallint and float data types in Oracle objects, as
requested (https://github.com/oracle/python-cx_Oracle/issues/4).


5.x releases
Expand Down
9 changes: 5 additions & 4 deletions test/ObjectVar.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ def testFetchData(self):
[ ('INTCOL', cx_Oracle.NUMBER, 10, None, 9, 0, 0),
('OBJECTCOL', cx_Oracle.OBJECT, None, None, None, None, 1),
('ARRAYCOL', cx_Oracle.OBJECT, None, None, None, None, 1) ])
self.__TestData(1, (1, 'First row', 'First ',
self.__TestData(1, (1, 'First row', 'First ', 2, 5, 12.5,
cx_Oracle.Timestamp(2007, 3, 6, 0, 0, 0),
cx_Oracle.Timestamp(2008, 9, 12, 16, 40),
(11, 'Sub object 1'),
[(5, 'first element'), (6, 'second element')]),
[5, 10, None, 20])
self.__TestData(2, None, [3, None, 9, 12, 15])
self.__TestData(3, (3, 'Third row', 'Third ',
self.__TestData(3, (3, 'Third row', 'Third ', 4, 10, 43.25,
cx_Oracle.Timestamp(2007, 6, 21, 0, 0, 0),
cx_Oracle.Timestamp(2007, 12, 13, 7, 30, 45),
(13, 'Sub object 3'),
Expand All @@ -132,8 +132,9 @@ def testGetObjectType(self):
self.assertEqual(typeObj.schema, self.connection.username.upper())
self.assertEqual(typeObj.name, "UDT_OBJECT")
expectedAttributeNames = ["NUMBERVALUE", "STRINGVALUE",
"FIXEDCHARVALUE", "DATEVALUE", "TIMESTAMPVALUE",
"SUBOBJECTVALUE", "SUBOBJECTARRAY"]
"FIXEDCHARVALUE", "INTVALUE", "SMALLINTVALUE", "FLOATVALUE",
"DATEVALUE", "TIMESTAMPVALUE", "SUBOBJECTVALUE",
"SUBOBJECTARRAY"]
actualAttributeNames = [a.name for a in typeObj.attributes]
self.assertEqual(actualAttributeNames, expectedAttributeNames)
typeObj = self.connection.gettype("UDT_OBJECTARRAY")
Expand Down
7 changes: 5 additions & 2 deletions test/SetupTest.sql
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ create type cx_Oracle.udt_Object as object (
NumberValue number,
StringValue varchar2(60),
FixedCharValue char(10),
IntValue integer,
SmallIntValue smallint,
FloatValue float,
DateValue date,
TimestampValue timestamp,
SubObjectValue cx_Oracle.udt_SubObject,
Expand Down Expand Up @@ -272,7 +275,7 @@ end;
/

insert into cx_Oracle.TestObjects values (1,
cx_Oracle.udt_Object(1, 'First row', 'First',
cx_Oracle.udt_Object(1, 'First row', 'First', 2, 5, 12.5,
to_date(20070306, 'YYYYMMDD'),
to_timestamp('20080912 16:40:00', 'YYYYMMDD HH24:MI:SS'),
cx_Oracle.udt_SubObject(11, 'Sub object 1'),
Expand All @@ -285,7 +288,7 @@ insert into cx_Oracle.TestObjects values (2, null,
cx_Oracle.udt_Array(3, null, 9, 12, 15));

insert into cx_Oracle.TestObjects values (3,
cx_Oracle.udt_Object(3, 'Third row', 'Third',
cx_Oracle.udt_Object(3, 'Third row', 'Third', 4, 10, 43.25,
to_date(20070621, 'YYYYMMDD'),
to_timestamp('20071213 07:30:45', 'YYYYMMDD HH24:MI:SS'),
cx_Oracle.udt_SubObject(13, 'Sub object 3'),
Expand Down

0 comments on commit 7f70d18

Please sign in to comment.