@@ -9,8 +9,8 @@ use bytes::{BufMut, BytesMut};
99use postgres_protocol:: types;
1010use pyo3:: {
1111 types:: {
12- PyAnyMethods , PyBool , PyBytes , PyDate , PyDateTime , PyDict , PyDictMethods , PyFloat , PyInt ,
13- PyList , PyListMethods , PyString , PyTime , PyTuple ,
12+ PyAnyMethods , PyBool , PyBytes , PyDict , PyDictMethods , PyFloat , PyInt , PyList ,
13+ PyListMethods , PyString , PyTuple , PyTypeMethods ,
1414 } ,
1515 Bound , Py , PyAny , Python , ToPyObject ,
1616} ;
@@ -23,8 +23,8 @@ use crate::{
2323 additional_types:: { RustMacAddr6 , RustMacAddr8 } ,
2424 exceptions:: rust_errors:: { RustPSQLDriverError , RustPSQLDriverPyResult } ,
2525 extra_types:: {
26- BigInt , Integer , PyCustomType , PyJSON , PyJSONB , PyMacAddr6 , PyMacAddr8 , PyText , PyUUID ,
27- PyVarChar , SmallInt ,
26+ BigInt , Integer , PyCustomType , PyJSON , PyJSONB , PyMacAddr6 , PyMacAddr8 , PyText , PyVarChar ,
27+ SmallInt ,
2828 } ,
2929} ;
3030
@@ -303,7 +303,7 @@ pub fn py_to_rust(parameter: &pyo3::Bound<'_, PyAny>) -> RustPSQLDriverPyResult<
303303 return Ok ( PythonDTO :: PyBytes ( parameter. extract :: < Vec < u8 > > ( ) ?) ) ;
304304 }
305305
306- if parameter. is_instance_of :: < PyDateTime > ( ) {
306+ if parameter. get_type ( ) . name ( ) ? == "datetime" {
307307 let timestamp_tz = parameter. extract :: < DateTime < FixedOffset > > ( ) ;
308308 if let Ok ( pydatetime_tz) = timestamp_tz {
309309 return Ok ( PythonDTO :: PyDateTimeTz ( pydatetime_tz) ) ;
@@ -319,8 +319,10 @@ pub fn py_to_rust(parameter: &pyo3::Bound<'_, PyAny>) -> RustPSQLDriverPyResult<
319319 ) ) ;
320320 }
321321
322- if parameter. is_instance_of :: < PyUUID > ( ) {
323- return Ok ( PythonDTO :: PyUUID ( parameter. extract :: < PyUUID > ( ) ?. inner ( ) ) ) ;
322+ if parameter. get_type ( ) . name ( ) ? == "UUID" {
323+ return Ok ( PythonDTO :: PyUUID ( Uuid :: parse_str (
324+ parameter. str ( ) ?. extract :: < & str > ( ) ?,
325+ ) ?) ) ;
324326 }
325327
326328 if parameter. is_instance_of :: < PyText > ( ) {
@@ -364,14 +366,22 @@ pub fn py_to_rust(parameter: &pyo3::Bound<'_, PyAny>) -> RustPSQLDriverPyResult<
364366 return Ok ( PythonDTO :: PyIntI32 ( parameter. extract :: < i32 > ( ) ?) ) ;
365367 }
366368
367- if parameter. is_instance_of :: < PyDate > ( ) {
369+ if parameter. get_type ( ) . name ( ) ? == "date" {
368370 return Ok ( PythonDTO :: PyDate ( parameter. extract :: < NaiveDate > ( ) ?) ) ;
369371 }
370372
371- if parameter. is_instance_of :: < PyTime > ( ) {
373+ // if parameter.is_instance_of::<PyDate>() {
374+ // return Ok(PythonDTO::PyDate(parameter.extract::<NaiveDate>()?));
375+ // }
376+
377+ if parameter. get_type ( ) . name ( ) ? == "time" {
372378 return Ok ( PythonDTO :: PyTime ( parameter. extract :: < NaiveTime > ( ) ?) ) ;
373379 }
374380
381+ // if parameter.is_instance_of::<PyTime>() {
382+ // return Ok(PythonDTO::PyTime(parameter.extract::<NaiveTime>()?));
383+ // }
384+
375385 if parameter. is_instance_of :: < PyList > ( ) | parameter. is_instance_of :: < PyTuple > ( ) {
376386 let mut items = Vec :: new ( ) ;
377387 for inner in parameter. iter ( ) ? {
0 commit comments