Closed kubo closed 3 years ago
ODPI-C version: 4.1.0 Oracle client version: 21.1
dpiJsonNode node, *topNode; dpiDataBuffer value; node.oracleTypeNum = DPI_ORACLE_TYPE_NUMBER; node.nativeTypeNum = DPI_NATIVE_TYPE_DOUBLE; node.value = &value; node.value->asDouble = 1.0; dpiJson_setValue(json, &node); dpiJson_getValue(json, DPI_JSON_OPT_DEFAULT, &topNode); fprintf(stderr, "%f\n", topNode->value->asDouble); node.value->asDouble = 2.0; dpiJson_setValue(json, &node); dpiJson_getValue(json, DPI_JSON_OPT_DEFAULT, &topNode); fprintf(stderr, "%f\n", topNode->value->asDouble);
The above code should print:
1.000000 2.000000
However it printed:
1.000000 1.000000
I noticed that once non-null value is set to json->topNode, dpiJson_getValue() returns same top node even after another JSON value is set by dpiJson_setValue(). https://github.com/oracle/odpi/blob/v4.1.0/src/dpiJson.c#L733-L744
json->topNode
dpiJson_getValue()
dpiJson_setValue()
Yet another but related issue:
dpiJsonNode node, *topNode; dpiDataBuffer value; node.oracleTypeNum = DPI_ORACLE_TYPE_NUMBER; node.nativeTypeNum = DPI_NATIVE_TYPE_DOUBLE; node.value = &value; node.value->asDouble = 1.0; dpiJson_setValue(json, &node); // Get number as double dpiJson_getValue(json, DPI_JSON_OPT_DEFAULT, &topNode); fprintf(stderr, "native_type: %d\n", topNode->nativeTypeNum); // Get number as string dpiJson_getValue(json, DPI_JSON_OPT_NUMBER_AS_STRING, &topNode); fprintf(stderr, "native_type: %d\n", topNode->nativeTypeNum);
native_type: 3003 native_type: 3004
native_type: 3003 native_type: 3003
Thanks, @kubo. I've just pushed a patch that should correct that for you!
Thanks. It works fine for me.
ODPI-C version: 4.1.0 Oracle client version: 21.1
The above code should print:
However it printed:
I noticed that once non-null value is set to
json->topNode
,dpiJson_getValue()
returns same top node even after another JSON value is set bydpiJson_setValue()
. https://github.com/oracle/odpi/blob/v4.1.0/src/dpiJson.c#L733-L744Yet another but related issue:
The above code should print:
However it printed: