Skip to content

Commit

Permalink
Add support for getting/setting raw attributes of objects, as requested
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-tuininga committed Nov 2, 2018
1 parent e988d74 commit 851c9a4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
15 changes: 8 additions & 7 deletions test/ObjectVar.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ def testFetchData(self):
('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 ', 'N First Row',
'N First ', 2, 5, 12.125, 0.5, 12.5, 25.25, 50.125,
cx_Oracle.Timestamp(2007, 3, 6, 0, 0, 0),
'N First ', b'Raw Data 1', 2, 5, 12.125, 0.5, 12.5, 25.25,
50.125, cx_Oracle.Timestamp(2007, 3, 6, 0, 0, 0),
cx_Oracle.Timestamp(2008, 9, 12, 16, 40),
cx_Oracle.Timestamp(2009, 10, 13, 17, 50),
cx_Oracle.Timestamp(2010, 11, 14, 18, 55),
Expand All @@ -134,8 +134,8 @@ def testFetchData(self):
[5, 10, None, 20])
self.__TestData(2, None, [3, None, 9, 12, 15])
self.__TestData(3, (3, 'Third row', 'Third ', 'N Third Row',
'N Third ', 4, 10, 6.5, 0.75, 43.25, 86.5, 192.125,
cx_Oracle.Timestamp(2007, 6, 21, 0, 0, 0),
'N Third ', b'Raw Data 3', 4, 10, 6.5, 0.75, 43.25, 86.5,
192.125, cx_Oracle.Timestamp(2007, 6, 21, 0, 0, 0),
cx_Oracle.Timestamp(2007, 12, 13, 7, 30, 45),
cx_Oracle.Timestamp(2017, 6, 21, 23, 18, 45),
cx_Oracle.Timestamp(2017, 7, 21, 8, 27, 13),
Expand All @@ -153,7 +153,7 @@ def testGetObjectType(self):
self.assertEqual(typeObj.name, "UDT_OBJECT")
expectedAttributeNames = ["NUMBERVALUE", "STRINGVALUE",
"FIXEDCHARVALUE", "NSTRINGVALUE", "NFIXEDCHARVALUE",
"INTVALUE", "SMALLINTVALUE", "REALVALUE",
"RAWVALUE", "INTVALUE", "SMALLINTVALUE", "REALVALUE",
"DOUBLEPRECISIONVALUE", "FLOATVALUE", "BINARYFLOATVALUE",
"BINARYDOUBLEVALUE", "DATEVALUE", "TIMESTAMPVALUE",
"TIMESTAMPTZVALUE", "TIMESTAMPLTZVALUE", "CLOBVALUE",
Expand Down Expand Up @@ -202,6 +202,7 @@ def testRoundTripObject(self):
obj.FIXEDCHARVALUE = "Fixed str"
obj.NSTRINGVALUE = "A NCHAR string"
obj.NFIXEDCHARVALUE = "Fixed N"
obj.RAWVALUE = b"Raw Value"
obj.INTVALUE = 27
obj.SMALLINTVALUE = 13
obj.REALVALUE = 184.875
Expand All @@ -228,8 +229,8 @@ def testRoundTripObject(self):
from TestObjects
where IntCol = 4""")
self.__TestData(4, (5, 'A string', 'Fixed str ', 'A NCHAR string',
'Fixed N ', 27, 13, 184.875, 1.375, 23.75, 14.25, 29.1625,
cx_Oracle.Timestamp(2017, 5, 9, 0, 0, 0),
'Fixed N ', b'Raw Value', 27, 13, 184.875, 1.375, 23.75,
14.25, 29.1625, cx_Oracle.Timestamp(2017, 5, 9, 0, 0, 0),
cx_Oracle.Timestamp(2017, 5, 9, 9, 41, 13),
cx_Oracle.Timestamp(1986, 8, 2, 15, 27, 38),
cx_Oracle.Timestamp(1999, 11, 12, 23, 5, 2),
Expand Down
9 changes: 6 additions & 3 deletions test/sql/SetupTest.sql
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ create type &main_user..udt_Object as object (
FixedCharValue char(10),
NStringValue nvarchar2(60),
NFixedCharValue nchar(10),
RawValue raw(16),
IntValue integer,
SmallIntValue smallint,
RealValue real,
Expand Down Expand Up @@ -351,7 +352,8 @@ end;

insert into &main_user..TestObjects values (1,
&main_user..udt_Object(1, 'First row', 'First', 'N First Row', 'N First',
2, 5, 12.125, 0.5, 12.5, 25.25, 50.125, to_date(20070306, 'YYYYMMDD'),
'52617720446174612031', 2, 5, 12.125, 0.5, 12.5, 25.25, 50.125,
to_date(20070306, 'YYYYMMDD'),
to_timestamp('20080912 16:40:00', 'YYYYMMDD HH24:MI:SS'),
to_timestamp_tz('20091013 17:50:00 00:00',
'YYYYMMDD HH24:MI:SS TZH:TZM'),
Expand All @@ -370,7 +372,8 @@ insert into &main_user..TestObjects values (2, null,

insert into &main_user..TestObjects values (3,
&main_user..udt_Object(3, 'Third row', 'Third', 'N Third Row', 'N Third',
4, 10, 6.5, 0.75, 43.25, 86.5, 192.125, to_date(20070621, 'YYYYMMDD'),
'52617720446174612033', 4, 10, 6.5, 0.75, 43.25, 86.5, 192.125,
to_date(20070621, 'YYYYMMDD'),
to_timestamp('20071213 07:30:45', 'YYYYMMDD HH24:MI:SS'),
to_timestamp_tz('20170621 23:18:45 00:00',
'YYYYMMDD HH24:MI:SS TZH:TZM'),
Expand Down Expand Up @@ -879,7 +882,7 @@ create or replace package body &main_user..pkg_TestBindObject as
begin
a_Object := udt_Object(a_NumberValue, a_StringValue, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null);
null, null, null, null, null, null, null);
end;

end;
Expand Down

0 comments on commit 851c9a4

Please sign in to comment.