Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "odpi"]
path = odpi
url = https://github.com/oracle/odpi.git
url = [email protected]:Elias481/odpi.git
branch = object-raw-attributes
2 changes: 1 addition & 1 deletion odpi
3 changes: 3 additions & 0 deletions src/cxoModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ struct cxoObjectAttr {
dpiOracleTypeNum oracleTypeNum;
cxoTransformNum transformNum;
cxoObjectType *type;
PyTypeObject *varType;
};

struct cxoObjectType {
Expand All @@ -348,6 +349,7 @@ struct cxoObjectType {
dpiOracleTypeNum elementOracleTypeNum;
cxoTransformNum elementTransformNum;
PyObject *elementType;
PyTypeObject *elementVartype;
char isCollection;
};

Expand Down Expand Up @@ -529,6 +531,7 @@ int cxoUtils_processSodaDocArg(cxoSodaDatabase *db, PyObject *arg,

cxoVarType *cxoVarType_fromDataTypeInfo(dpiDataTypeInfo *info);
cxoVarType *cxoVarType_fromPythonType(PyTypeObject *type);
cxoVarType *cxoVarType_fromTransformNum(cxoTransformNum transformNum);
cxoVarType *cxoVarType_fromPythonValue(PyObject *value, int *isArray,
Py_ssize_t *size, Py_ssize_t *numElements, int plsql);

Expand Down
6 changes: 6 additions & 0 deletions src/cxoObjectAttr.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ static PyObject *cxoObjectAttr_repr(cxoObjectAttr*);
//-----------------------------------------------------------------------------
static PyMemberDef cxoObjectAttrMembers[] = {
{ "name", T_OBJECT, offsetof(cxoObjectAttr, name), READONLY },
{ "vartype", T_OBJECT, offsetof(cxoObjectAttr, varType), READONLY },
{ "type", T_OBJECT, offsetof(cxoObjectAttr, type), READONLY },
{ NULL }
};

Expand Down Expand Up @@ -81,6 +83,7 @@ static int cxoObjectAttr_initialize(cxoObjectAttr *attr,
cxoConnection *connection)
{
dpiObjectAttrInfo info;
cxoVarType *vartype;

if (dpiObjectAttr_getInfo(attr->handle, &info) < 0)
return cxoError_raiseAndReturnInt();
Expand All @@ -90,6 +93,9 @@ static int cxoObjectAttr_initialize(cxoObjectAttr *attr,
connection->encodingInfo.encoding, NULL);
if (!attr->name)
return -1;
vartype = cxoVarType_fromTransformNum(attr->transformNum);
if (vartype)
attr->varType = vartype->pythonType;
if (info.typeInfo.objectType) {
attr->type = cxoObjectType_new(connection,
info.typeInfo.objectType);
Expand Down
8 changes: 8 additions & 0 deletions src/cxoObjectType.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ static PyMemberDef cxoObjectTypeMembers[] = {
READONLY },
{ "iscollection", T_BOOL, offsetof(cxoObjectType, isCollection),
READONLY },
{ "elementVartype", T_OBJECT, offsetof(cxoObjectType, elementVartype),
READONLY },
{ NULL }
};

Expand Down Expand Up @@ -105,6 +107,7 @@ static int cxoObjectType_initialize(cxoObjectType *objType,
dpiObjectAttr **attributes;
dpiObjectTypeInfo info;
cxoObjectAttr *attr;
cxoVarType *vartype;
uint16_t i;

// get object type information
Expand All @@ -124,6 +127,11 @@ static int cxoObjectType_initialize(cxoObjectType *objType,
objType->elementOracleTypeNum = info.elementTypeInfo.oracleTypeNum;
objType->elementTransformNum =
cxoTransform_getNumFromDataTypeInfo(&info.elementTypeInfo);

vartype = cxoVarType_fromTransformNum(objType->elementTransformNum);
if (vartype)
objType->elementVartype = vartype->pythonType;

if (info.elementTypeInfo.objectType) {
objType->elementType = (PyObject*) cxoObjectType_new(connection,
info.elementTypeInfo.objectType);
Expand Down
12 changes: 12 additions & 0 deletions src/cxoVarType.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,18 @@ cxoVarType *cxoVarType_fromPythonType(PyTypeObject *type)
return &cxoAllVarTypes[transformNum];
}

//-----------------------------------------------------------------------------
// cxoVarType_fromTransformNum()
// Return a variable type a cxoTransformNum or NULL for
// CXO_TRANSFORM_UNSUPPORTED
//-----------------------------------------------------------------------------
cxoVarType *cxoVarType_fromTransformNum(cxoTransformNum transformNum)
{
if (transformNum == CXO_TRANSFORM_UNSUPPORTED) {
return NULL;
}
return &cxoAllVarTypes[transformNum];
}

//-----------------------------------------------------------------------------
// cxoVarType_calculateSize()
Expand Down