Convert object type handling to use new cxString functions and add test case
to ensure that it was done correctly.
This commit is contained in:
parent
bef9439b3e
commit
d50847e92b
@ -256,19 +256,18 @@ static PyObject *ExternalObjectVar_GetAttributeValue(
|
|||||||
{
|
{
|
||||||
dvoid *valueIndicator, *value;
|
dvoid *valueIndicator, *value;
|
||||||
OCIInd scalarValueIndicator;
|
OCIInd scalarValueIndicator;
|
||||||
ub4 nameLength;
|
udt_StringBuffer buffer;
|
||||||
sword status;
|
sword status;
|
||||||
OCIType *tdo;
|
OCIType *tdo;
|
||||||
char *name;
|
|
||||||
|
|
||||||
// get the value for the attribute
|
// get the value for the attribute
|
||||||
name = PyString_AS_STRING(attribute->name);
|
if (StringBuffer_Fill(&buffer, attribute->name) < 0)
|
||||||
nameLength = PyString_GET_SIZE(attribute->name);
|
return NULL;
|
||||||
status = OCIObjectGetAttr(self->objectType->environment->handle,
|
status = OCIObjectGetAttr(self->objectType->environment->handle,
|
||||||
self->objectType->environment->errorHandle, self->instance,
|
self->objectType->environment->errorHandle, self->instance,
|
||||||
self->indicator, self->objectType->tdo, (const OraText**) &name,
|
self->indicator, self->objectType->tdo,
|
||||||
&nameLength, 1, 0, 0, &scalarValueIndicator, &valueIndicator,
|
(const OraText**) &buffer.ptr, (ub4*) &buffer.size, 1, 0, 0,
|
||||||
&value, &tdo);
|
&scalarValueIndicator, &valueIndicator, &value, &tdo);
|
||||||
if (Environment_CheckForError(self->objectType->environment, status,
|
if (Environment_CheckForError(self->objectType->environment, status,
|
||||||
"ExternalObjectVar_GetAttributeValue(): getting value") < 0)
|
"ExternalObjectVar_GetAttributeValue(): getting value") < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@ -295,7 +295,7 @@ static int ObjectType_Initialize(
|
|||||||
if (Environment_CheckForError(self->environment, status,
|
if (Environment_CheckForError(self->environment, status,
|
||||||
"ObjectType_Initialize(): get schema name") < 0)
|
"ObjectType_Initialize(): get schema name") < 0)
|
||||||
return -1;
|
return -1;
|
||||||
self->schema = PyString_FromStringAndSize(name, size);
|
self->schema = cxString_FromEncodedString(name, size);
|
||||||
if (!self->schema)
|
if (!self->schema)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -305,7 +305,7 @@ static int ObjectType_Initialize(
|
|||||||
if (Environment_CheckForError(self->environment, status,
|
if (Environment_CheckForError(self->environment, status,
|
||||||
"ObjectType_Initialize(): get name") < 0)
|
"ObjectType_Initialize(): get name") < 0)
|
||||||
return -1;
|
return -1;
|
||||||
self->name = PyString_FromStringAndSize(name, size);
|
self->name = cxString_FromEncodedString(name, size);
|
||||||
if (!self->name)
|
if (!self->name)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -433,7 +433,7 @@ static int ObjectAttribute_Initialize(
|
|||||||
if (Environment_CheckForError(connection->environment, status,
|
if (Environment_CheckForError(connection->environment, status,
|
||||||
"ObjectAttribute_Initialize(): get name") < 0)
|
"ObjectAttribute_Initialize(): get name") < 0)
|
||||||
return -1;
|
return -1;
|
||||||
self->name = PyString_FromStringAndSize(name, size);
|
self->name = cxString_FromEncodedString(name, size);
|
||||||
if (!self->name)
|
if (!self->name)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|||||||
@ -38,3 +38,16 @@ class TestObjectVar(BaseTestCase):
|
|||||||
cx_Oracle.Timestamp(2007, 6, 21, 0, 0, 0),
|
cx_Oracle.Timestamp(2007, 6, 21, 0, 0, 0),
|
||||||
cx_Oracle.Timestamp(2007, 12, 13, 7, 30, 45)), None)
|
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")
|
||||||
|
|
||||||
|
|||||||
@ -38,3 +38,16 @@ class TestObjectVar(BaseTestCase):
|
|||||||
cx_Oracle.Timestamp(2007, 6, 21, 0, 0, 0),
|
cx_Oracle.Timestamp(2007, 6, 21, 0, 0, 0),
|
||||||
cx_Oracle.Timestamp(2007, 12, 13, 7, 30, 45)), None)
|
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")
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user