diff --git a/ExternalObjectVar.c b/ExternalObjectVar.c index 9c4c21f..a50fddb 100644 --- a/ExternalObjectVar.c +++ b/ExternalObjectVar.c @@ -256,19 +256,18 @@ static PyObject *ExternalObjectVar_GetAttributeValue( { dvoid *valueIndicator, *value; OCIInd scalarValueIndicator; - ub4 nameLength; + udt_StringBuffer buffer; sword status; OCIType *tdo; - char *name; // get the value for the attribute - name = PyString_AS_STRING(attribute->name); - nameLength = PyString_GET_SIZE(attribute->name); + if (StringBuffer_Fill(&buffer, attribute->name) < 0) + return NULL; status = OCIObjectGetAttr(self->objectType->environment->handle, self->objectType->environment->errorHandle, self->instance, - self->indicator, self->objectType->tdo, (const OraText**) &name, - &nameLength, 1, 0, 0, &scalarValueIndicator, &valueIndicator, - &value, &tdo); + self->indicator, self->objectType->tdo, + (const OraText**) &buffer.ptr, (ub4*) &buffer.size, 1, 0, 0, + &scalarValueIndicator, &valueIndicator, &value, &tdo); if (Environment_CheckForError(self->objectType->environment, status, "ExternalObjectVar_GetAttributeValue(): getting value") < 0) return NULL; diff --git a/ObjectType.c b/ObjectType.c index b5d6387..375d753 100644 --- a/ObjectType.c +++ b/ObjectType.c @@ -295,7 +295,7 @@ static int ObjectType_Initialize( if (Environment_CheckForError(self->environment, status, "ObjectType_Initialize(): get schema name") < 0) return -1; - self->schema = PyString_FromStringAndSize(name, size); + self->schema = cxString_FromEncodedString(name, size); if (!self->schema) return -1; @@ -305,7 +305,7 @@ static int ObjectType_Initialize( if (Environment_CheckForError(self->environment, status, "ObjectType_Initialize(): get name") < 0) return -1; - self->name = PyString_FromStringAndSize(name, size); + self->name = cxString_FromEncodedString(name, size); if (!self->name) return -1; @@ -433,7 +433,7 @@ static int ObjectAttribute_Initialize( if (Environment_CheckForError(connection->environment, status, "ObjectAttribute_Initialize(): get name") < 0) return -1; - self->name = PyString_FromStringAndSize(name, size); + self->name = cxString_FromEncodedString(name, size); if (!self->name) return -1; diff --git a/test/ObjectVar.py b/test/ObjectVar.py index 0bebac1..49977e4 100644 --- a/test/ObjectVar.py +++ b/test/ObjectVar.py @@ -38,3 +38,16 @@ class TestObjectVar(BaseTestCase): cx_Oracle.Timestamp(2007, 6, 21, 0, 0, 0), cx_Oracle.Timestamp(2007, 12, 13, 7, 30, 45)), None) + def testObjectType(self): + "test object type data" + self.cursor.execute(""" + select ObjectCol + from TestObjects + where ObjectCol is not null + and rownum <= 1""") + objValue, = self.cursor.fetchone() + self.failUnlessEqual(objValue.type.schema, + self.connection.username.upper()) + self.failUnlessEqual(objValue.type.name, "UDT_OBJECT") + self.failUnlessEqual(objValue.type.attributes[0].name, "NUMBERVALUE") + diff --git a/test/uObjectVar.py b/test/uObjectVar.py index 4d50f10..6e709d0 100644 --- a/test/uObjectVar.py +++ b/test/uObjectVar.py @@ -38,3 +38,16 @@ class TestObjectVar(BaseTestCase): cx_Oracle.Timestamp(2007, 6, 21, 0, 0, 0), cx_Oracle.Timestamp(2007, 12, 13, 7, 30, 45)), None) + def testObjectType(self): + "test object type data" + self.cursor.execute(u""" + select ObjectCol + from TestObjects + where ObjectCol is not null + and rownum <= 1""") + objValue, = self.cursor.fetchone() + self.failUnlessEqual(objValue.type.schema, + self.connection.username.upper()) + self.failUnlessEqual(objValue.type.name, u"UDT_OBJECT") + self.failUnlessEqual(objValue.type.attributes[0].name, "NUMBERVALUE") +