@@ -186,9 +186,11 @@ static PyObject *Object_Repr(udt_Object *self)
186
186
// Convert a Python value to an Oracle value.
187
187
//-----------------------------------------------------------------------------
188
188
static int Object_ConvertFromPython (udt_Object * obj , PyObject * value ,
189
- dpiNativeTypeNum * nativeTypeNum , dpiData * data , udt_Buffer * buffer )
189
+ dpiOracleTypeNum oracleTypeNum , dpiNativeTypeNum * nativeTypeNum ,
190
+ dpiData * data , udt_Buffer * buffer )
190
191
{
191
192
PyObject * textValue , * valueType ;
193
+ const char * encoding ;
192
194
udt_Object * otherObj ;
193
195
udt_LOB * lob ;
194
196
int status ;
@@ -214,8 +216,12 @@ static int Object_ConvertFromPython(udt_Object *obj, PyObject *value,
214
216
if (status < 0 )
215
217
return -1 ;
216
218
} else {
217
- if (cxBuffer_FromObject (buffer , value ,
218
- obj -> objectType -> connection -> encodingInfo .encoding ) < 0 )
219
+ if (oracleTypeNum == DPI_ORACLE_TYPE_NCHAR ||
220
+ oracleTypeNum == DPI_ORACLE_TYPE_NVARCHAR ||
221
+ oracleTypeNum == DPI_ORACLE_TYPE_NCLOB )
222
+ encoding = obj -> objectType -> connection -> encodingInfo .nencoding ;
223
+ else encoding = obj -> objectType -> connection -> encodingInfo .encoding ;
224
+ if (cxBuffer_FromObject (buffer , value , encoding ) < 0 )
219
225
return -1 ;
220
226
}
221
227
* nativeTypeNum = DPI_NATIVE_TYPE_BYTES ;
@@ -362,8 +368,8 @@ static int Object_SetAttributeValue(udt_Object *self,
362
368
int status ;
363
369
364
370
cxBuffer_Init (& buffer );
365
- if (Object_ConvertFromPython (self , value , & nativeTypeNum , & data ,
366
- & buffer ) < 0 )
371
+ if (Object_ConvertFromPython (self , value , attribute -> oracleTypeNum ,
372
+ & nativeTypeNum , & data , & buffer ) < 0 )
367
373
return -1 ;
368
374
status = dpiObject_setAttributeValue (self -> handle , attribute -> handle ,
369
375
nativeTypeNum , & data );
@@ -421,7 +427,8 @@ static int Object_InternalAppend(udt_Object *self, PyObject *value)
421
427
int status ;
422
428
423
429
cxBuffer_Init (& buffer );
424
- if (Object_ConvertFromPython (self , value , & nativeTypeNum , & data ,
430
+ if (Object_ConvertFromPython (self , value ,
431
+ self -> objectType -> elementOracleTypeNum , & nativeTypeNum , & data ,
425
432
& buffer ) < 0 )
426
433
return -1 ;
427
434
status = dpiObject_appendElement (self -> handle , nativeTypeNum , & data );
@@ -718,7 +725,8 @@ static PyObject *Object_SetElement(udt_Object *self, PyObject *args)
718
725
if (!PyArg_ParseTuple (args , "iO" , & index , & value ))
719
726
return NULL ;
720
727
cxBuffer_Init (& buffer );
721
- if (Object_ConvertFromPython (self , value , & nativeTypeNum , & data ,
728
+ if (Object_ConvertFromPython (self , value ,
729
+ self -> objectType -> elementOracleTypeNum , & nativeTypeNum , & data ,
722
730
& buffer ) < 0 )
723
731
return NULL ;
724
732
status = dpiObject_setElementValueByIndex (self -> handle , index ,
0 commit comments