Skip to content

Commit cb464ab

Browse files
Test improvements.
1 parent 1c747ee commit cb464ab

9 files changed

+2885
-31
lines changed

tests/sql/create_schema.sql

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,25 @@ create or replace type &main_user..udt_XmlTypeArray
153153
as table of sys.xmltype;
154154
/
155155

156+
create or replace type &main_user..udt_TableOfNumber as table of number;
157+
/
158+
159+
create or replace type &main_user..udt_TableOfTableOfNumber
160+
as table of &main_user..udt_TableOfNumber;
161+
/
162+
163+
create or replace type &main_user..udt_VarrayOfTableOfNumber
164+
as varray(5) of &main_user..udt_TableOfNumber;
165+
/
166+
167+
create or replace type &main_user..udt_VarrayOfNumber
168+
as varray(5) of number;
169+
/
170+
171+
create or replace type &main_user..udt_TableOfVarrayOfNumber
172+
as table of &main_user..udt_VarrayOfNumber;
173+
/
174+
156175
-- create tables
157176
create table &main_user..TestNumbers (
158177
IntCol number(9) not null,
@@ -355,6 +374,7 @@ create table &main_user..TestAllTypes (
355374
IntValue integer,
356375
SmallIntValue smallint,
357376
RealValue real,
377+
DecimalValue number(20, 6),
358378
DoublePrecisionValue double precision,
359379
FloatValue float,
360380
BinaryFloatValue binary_float,
@@ -398,6 +418,16 @@ create table &main_user..TestDataframe (
398418
)
399419
/
400420

421+
create table &main_user..NestedCollectionTests (
422+
Id number(9),
423+
TableCol &main_user..udt_TableOfTableOfNumber,
424+
VarrayCol &main_user..udt_VarrayOfTableOfNumber
425+
)
426+
nested table TableCol store as NestedCollectionTests_nt (
427+
nested table column_value store as NestedCollectionTests_nti
428+
)
429+
/
430+
401431
-- create queue table and queues for testing advanced queuing
402432
begin
403433

@@ -1363,6 +1393,46 @@ create or replace package body &main_user..pkg_TestNestedRecords as
13631393
end;
13641394
/
13651395

1396+
create or replace package &main_user..pkg_NestedTable as
1397+
1398+
function GetTableOfNumber
1399+
return udt_TableOfNumber;
1400+
1401+
function GetTableOfVarrayOfNumber
1402+
return udt_TableOfVarrayOfNumber;
1403+
1404+
function GetVarrayOfNumber
1405+
return udt_VarrayOfNumber;
1406+
1407+
end;
1408+
/
1409+
1410+
create or replace package body &main_user..pkg_NestedTable as
1411+
1412+
function GetTableOfNumber
1413+
return udt_TableOfNumber is
1414+
begin
1415+
return udt_TableOfNumber(15, 25, 35, 45);
1416+
end;
1417+
1418+
function GetTableOfVarrayOfNumber
1419+
return udt_TableOfVarrayOfNumber is
1420+
begin
1421+
return udt_TableOfVarrayOfNumber(
1422+
udt_VarrayOfNumber(10, 20),
1423+
udt_VarrayOfNumber(30, 40)
1424+
);
1425+
end;
1426+
1427+
function GetVarrayOfNumber
1428+
return udt_VarrayOfNumber is
1429+
begin
1430+
return udt_VarrayOfNumber(10, 20, 30);
1431+
end;
1432+
1433+
end;
1434+
/
1435+
13661436
create or replace package &main_user..pkg_SessionCallback as
13671437

13681438
procedure TheCallback (

tests/sql/create_schema_23_4.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ store as (compress high)
7575
create table &main_user..TestBooleans (
7676
IntCol number(9) not null,
7777
BooleanCol1 boolean not null,
78-
BooleanCol2 boolean
78+
BooleanCol2 boolean,
79+
BooleanCol3 boolean
7980
)
8081
/

tests/test_2300_object_var.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ def test_2337(self):
760760
("INTVALUE", oracledb.DB_TYPE_NUMBER, 38, 0, None),
761761
("SMALLINTVALUE", oracledb.DB_TYPE_NUMBER, 38, 0, None),
762762
("REALVALUE", oracledb.DB_TYPE_NUMBER, 63, -127, None),
763+
("DECIMALVALUE", oracledb.DB_TYPE_NUMBER, 20, 6, None),
763764
("DOUBLEPRECISIONVALUE", oracledb.DB_TYPE_NUMBER, 126, -127, None),
764765
("FLOATVALUE", oracledb.DB_TYPE_NUMBER, 126, -127, None),
765766
(
@@ -863,6 +864,81 @@ def test_2342(self):
863864
self.assertIsNone(obj.INNER2.ATTR1)
864865
self.assertEqual(obj.INNER2.ATTR2, value2)
865866

867+
def test_2343(self):
868+
"2343 - test varray of numbers"
869+
obj_type = self.conn.gettype("UDT_VARRAYOFNUMBER")
870+
obj = self.cursor.callfunc(
871+
"pkg_NestedTable.GetVarrayOfNumber", obj_type
872+
)
873+
self.assertEqual(obj.aslist(), [10, 20, 30])
874+
875+
def test_2344(self):
876+
"2344 - test table of numbers"
877+
obj_type = self.conn.gettype("UDT_TABLEOFNUMBER")
878+
obj = self.cursor.callfunc(
879+
"pkg_NestedTable.GetTableOfNumber", obj_type
880+
)
881+
self.assertEqual(obj.aslist(), [15, 25, 35, 45])
882+
883+
def test_2345(self):
884+
"2345 - test table of varray of numbers"
885+
obj_type = self.conn.gettype("UDT_TABLEOFVARRAYOFNUMBER")
886+
obj = self.cursor.callfunc(
887+
"pkg_NestedTable.GetTableOfVarrayOfNumber", obj_type
888+
)
889+
plain_obj = self.get_db_object_as_plain_object(obj)
890+
self.assertEqual(plain_obj, [[10, 20], [30, 40]])
891+
892+
def test_2346(self):
893+
"2346 - test nested table of nested tables"
894+
num_tab_type = self.conn.gettype("UDT_TABLEOFNUMBER")
895+
tab_num_tab_type = self.conn.gettype("UDT_TABLEOFTABLEOFNUMBER")
896+
897+
num_tab_1 = num_tab_type.newobject([1, 2])
898+
num_tab_2 = num_tab_type.newobject([3, 4, 5])
899+
num_tab_3 = num_tab_type.newobject([6, 7, 8, 9, 10])
900+
tab_num_tab = tab_num_tab_type.newobject(
901+
[num_tab_1, None, num_tab_2, None, num_tab_3]
902+
)
903+
904+
self.cursor.execute(
905+
"""
906+
insert into NestedCollectionTests (Id, TableCol)
907+
values (:1, :2)
908+
""",
909+
[1, tab_num_tab],
910+
)
911+
self.cursor.execute("select TableCol from NestedCollectionTests")
912+
(obj,) = self.cursor.fetchone()
913+
plain_obj = self.get_db_object_as_plain_object(obj)
914+
expected_data = [[1, 2], None, [3, 4, 5], None, [6, 7, 8, 9, 10]]
915+
self.assertEqual(plain_obj, expected_data)
916+
917+
def test_2347(self):
918+
"2347 - test nested table of varrays"
919+
num_tab_type = self.conn.gettype("UDT_TABLEOFNUMBER")
920+
arr_num_tab_type = self.conn.gettype("UDT_VARRAYOFTABLEOFNUMBER")
921+
922+
num_tab_1 = num_tab_type.newobject([4, 8])
923+
num_tab_2 = num_tab_type.newobject([1, 3, 5])
924+
num_tab_3 = num_tab_type.newobject([2, 6, 10, 7, 9])
925+
tab_num_tab = arr_num_tab_type.newobject(
926+
[num_tab_1, None, num_tab_2, None, num_tab_3]
927+
)
928+
929+
self.cursor.execute(
930+
"""
931+
insert into NestedCollectionTests (Id, VarrayCol)
932+
values (:1, :2)
933+
""",
934+
[1, tab_num_tab],
935+
)
936+
self.cursor.execute("select VarrayCol from NestedCollectionTests")
937+
(obj,) = self.cursor.fetchone()
938+
plain_obj = self.get_db_object_as_plain_object(obj)
939+
expected_data = [[4, 8], None, [1, 3, 5], None, [2, 6, 10, 7, 9]]
940+
self.assertEqual(plain_obj, expected_data)
941+
866942

867943
if __name__ == "__main__":
868944
test_env.run_test_cases()

tests/test_3100_boolean_var.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ def test_3110(self):
115115
self.cursor.execute("truncate table TestBooleans")
116116
true_values = ["true", "yes", "on", "1", "t", "y"]
117117
self.cursor.executemany(
118-
"insert into TestBooleans values (:1, :2, :3)",
118+
"""insert into TestBooleans (IntCol, BooleanCol1, BooleanCol2)
119+
values (:1, :2, :3)""",
119120
[(i, v, v) for i, v in enumerate(true_values)],
120121
)
121122
self.cursor.execute(
@@ -130,7 +131,8 @@ def test_3111(self):
130131
self.cursor.execute("truncate table TestBooleans")
131132
false_values = ["false", "no", "off", "0", "f", "n"]
132133
self.cursor.executemany(
133-
"insert into TestBooleans values (:1, :2, :3)",
134+
"""insert into TestBooleans (IntCol, BooleanCol1, BooleanCol2)
135+
values (:1, :2, :3)""",
134136
[(i, v, v) for i, v in enumerate(false_values)],
135137
)
136138
self.cursor.execute(

tests/test_5600_dbobject_async.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ async def test_5616(self):
563563
("INTVALUE", oracledb.DB_TYPE_NUMBER, 38, 0, None),
564564
("SMALLINTVALUE", oracledb.DB_TYPE_NUMBER, 38, 0, None),
565565
("REALVALUE", oracledb.DB_TYPE_NUMBER, 63, -127, None),
566+
("DECIMALVALUE", oracledb.DB_TYPE_NUMBER, 20, 6, None),
566567
("DOUBLEPRECISIONVALUE", oracledb.DB_TYPE_NUMBER, 126, -127, None),
567568
("FLOATVALUE", oracledb.DB_TYPE_NUMBER, 126, -127, None),
568569
(

0 commit comments

Comments
 (0)