@@ -13,10 +13,11 @@ use crate::{exceptions::rust_errors::RustPSQLDriverPyResult, value_converter::po
1313fn row_to_dict < ' a > (
1414 py : Python < ' a > ,
1515 postgres_row : & ' a Row ,
16+ custom_decoders : & Option < Py < PyDict > > ,
1617) -> RustPSQLDriverPyResult < pyo3:: Bound < ' a , PyDict > > {
1718 let python_dict = PyDict :: new_bound ( py) ;
1819 for ( column_idx, column) in postgres_row. columns ( ) . iter ( ) . enumerate ( ) {
19- let python_type = postgres_to_py ( py, postgres_row, column, column_idx) ?;
20+ let python_type = postgres_to_py ( py, postgres_row, column, column_idx, custom_decoders ) ?;
2021 python_dict. set_item ( column. name ( ) . to_object ( py) , python_type) ?;
2122 }
2223 Ok ( python_dict)
@@ -55,10 +56,14 @@ impl PSQLDriverPyQueryResult {
5556 /// postgres type to python or set new key-value pair
5657 /// in python dict.
5758 #[ allow( clippy:: needless_pass_by_value) ]
58- pub fn result ( & self , py : Python < ' _ > ) -> RustPSQLDriverPyResult < Py < PyAny > > {
59+ pub fn result (
60+ & self ,
61+ py : Python < ' _ > ,
62+ custom_decoders : Option < Py < PyDict > > ,
63+ ) -> RustPSQLDriverPyResult < Py < PyAny > > {
5964 let mut result: Vec < pyo3:: Bound < ' _ , PyDict > > = vec ! [ ] ;
6065 for row in & self . inner {
61- result. push ( row_to_dict ( py, row) ?) ;
66+ result. push ( row_to_dict ( py, row, & custom_decoders ) ?) ;
6267 }
6368 Ok ( result. to_object ( py) )
6469 }
@@ -77,7 +82,7 @@ impl PSQLDriverPyQueryResult {
7782 ) -> RustPSQLDriverPyResult < Py < PyAny > > {
7883 let mut res: Vec < Py < PyAny > > = vec ! [ ] ;
7984 for row in & self . inner {
80- let pydict: pyo3:: Bound < ' _ , PyDict > = row_to_dict ( py, row) ?;
85+ let pydict: pyo3:: Bound < ' _ , PyDict > = row_to_dict ( py, row, & None ) ?;
8186 let convert_class_inst = as_class. call_bound ( py, ( ) , Some ( & pydict) ) ?;
8287 res. push ( convert_class_inst) ;
8388 }
@@ -117,7 +122,7 @@ impl PSQLDriverSinglePyQueryResult {
117122 /// postgres type to python, can not set new key-value pair
118123 /// in python dict or there are no result.
119124 pub fn result ( & self , py : Python < ' _ > ) -> RustPSQLDriverPyResult < Py < PyAny > > {
120- Ok ( row_to_dict ( py, & self . inner ) ?. to_object ( py) )
125+ Ok ( row_to_dict ( py, & self . inner , & None ) ?. to_object ( py) )
121126 }
122127
123128 /// Convert result from database to any class passed from Python.
@@ -133,7 +138,7 @@ impl PSQLDriverSinglePyQueryResult {
133138 py : Python < ' a > ,
134139 as_class : Py < PyAny > ,
135140 ) -> RustPSQLDriverPyResult < Py < PyAny > > {
136- let pydict: pyo3:: Bound < ' _ , PyDict > = row_to_dict ( py, & self . inner ) ?;
141+ let pydict: pyo3:: Bound < ' _ , PyDict > = row_to_dict ( py, & self . inner , & None ) ?;
137142 Ok ( as_class. call_bound ( py, ( ) , Some ( & pydict) ) ?)
138143 }
139144}
0 commit comments