Skip to content

Commit 1d00a98

Browse files
committed
working on some more esoteric record type configurations
1 parent 49216ba commit 1d00a98

4 files changed

Lines changed: 27 additions & 3 deletions

File tree

‎python_plsql/client.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,11 @@ def to_record(value, record):
289289
def list_converter(value):
290290
if value.type.elementType:
291291
attributes = value.type.elementType.attributes
292-
record = plsql_record(attributes)
293-
return [to_record(val, record) for val in value.aslist()]
292+
if attributes:
293+
record = plsql_record(attributes)
294+
return [to_record(val, record) for val in value.aslist()]
295+
296+
return [list_converter(val) for val in value.aslist()]
294297
return value.aslist()
295298

296299

@@ -349,7 +352,7 @@ def python_type(
349352
}
350353

351354
try:
352-
return type_mapping[plsql_type.datatype]
355+
return cursor.var(type_mapping[plsql_type.datatype])
353356
except KeyError:
354357
converter = converters[plsql_type.datatype]
355358

‎tests/func/test_return_values.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
("ret_record_of_records", (42, (42, 84, 126), (42, 84, 126))),
2020
("ret_nested", [i * 2 for i in range(1, 11)]),
2121
("ret_nested_of_records", [(42, 84, 126) for i in range(1, 11)]),
22+
pytest.param(
23+
"ret_nested_of_nested",
24+
[[i * 2 for i in range(1, 11)] for i in range(1, 11)],
25+
marks=pytest.mark.skip(reason="Memory access violation"),
26+
),
2227
("ret_plsql_table", {i: i for i in range(1, 11)}),
2328
("ret_plsql_table_of_records", {i: (42, 84, 126) for i in range(1, 11)}),
2429
],

‎tests/sql/package/test_return-b.sql‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ CREATE OR REPLACE PACKAGE BODY test_return AS
104104
RETURN vt_nested_of_records;
105105
END ret_nested_of_records;
106106

107+
FUNCTION ret_nested_of_nested
108+
RETURN tt_nested_of_nested IS
109+
vt_nested_of_nested tt_nested_of_nested := tt_nested_of_nested();
110+
BEGIN
111+
FOR v_i IN 1 .. 10 LOOP
112+
vt_nested_of_nested.extend;
113+
vt_nested_of_nested(v_i) := ret_nested;
114+
END LOOP;
115+
RETURN vt_nested_of_nested;
116+
END ret_nested_of_nested;
117+
107118
-- 123 VARRAY -- list
108119
--FUNCTION ret_binary_integer
109120
--RETURN BINARY_INTEGER;

‎tests/sql/package/test_return-h.sql‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ CREATE OR REPLACE PACKAGE test_return AS
1616

1717
TYPE tt_nested_of_records IS TABLE OF tr_record;
1818

19+
TYPE tt_nested_of_nested IS TABLE OF tt_nested;
20+
1921
TYPE tt_plsql_table IS TABLE OF PLS_INTEGER INDEX BY PLS_INTEGER;
2022

2123
TYPE tt_plsql_table_of_records IS TABLE OF tr_record INDEX BY PLS_INTEGER;
@@ -76,6 +78,9 @@ CREATE OR REPLACE PACKAGE test_return AS
7678
FUNCTION ret_nested_of_records
7779
RETURN tt_nested_of_records;
7880

81+
FUNCTION ret_nested_of_nested
82+
RETURN tt_nested_of_nested;
83+
7984
-- 123 VARRAY -- list
8085
--FUNCTION ret_binary_integer
8186
--RETURN BINARY_INTEGER;

0 commit comments

Comments
 (0)