Skip to content

Commit 070ed8a

Browse files
committed
Do not remove option properties when converting for preloadData
1 parent f55c18f commit 070ed8a

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

columnencoder.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -640,10 +640,11 @@ ColumnEncoder::colVec ColumnEncoder::columnNamesEncoded()
640640

641641
void ColumnEncoder::_convertPreloadingDataOption(Json::Value & options, const std::string& optionName, colsPlusTypes& colTypes)
642642
{
643-
Json::Value newOption = Json::arrayValue,
644-
typeList = options[optionName]["types"],
645-
valueList = options[optionName]["value"];
646643
std::string optionKey = options[optionName].isMember("optionKey") ? options[optionName]["optionKey"].asString() : "";
644+
bool keepOriginalOption = (!optionKey.empty() && options[optionName].size() > 3); // The option has other members: this must be kept
645+
Json::Value typeList = options[optionName]["types"],
646+
valueList = options[optionName]["value"],
647+
newOption = keepOriginalOption ? options[optionName] : Json::arrayValue;
647648

648649
bool useSingleVal = false;
649650

@@ -662,6 +663,9 @@ void ColumnEncoder::_convertPreloadingDataOption(Json::Value & options, const st
662663
typeList.append(type);
663664
}
664665

666+
if (keepOriginalOption)
667+
newOption[optionKey] = Json::arrayValue;
668+
665669
// The valueList can be either;
666670
// . a list of strings, if it is a list of variables without interaction
667671
// . a list of array of strings if it is a list of variables with interaction
@@ -673,7 +677,7 @@ void ColumnEncoder::_convertPreloadingDataOption(Json::Value & options, const st
673677
{
674678
Json::Value jsonType = typeList.size() > i ? typeList[i] : Json::nullValue,
675679
jsonValueOrg = valueList[i],
676-
jsonValue = optionKey.empty() ? jsonValueOrg : jsonValueOrg[optionKey];
680+
jsonValue = (optionKey.empty() || keepOriginalOption || !jsonValueOrg.isMember(optionKey)) ? jsonValueOrg : jsonValueOrg[optionKey];
677681

678682
if (jsonValue.isString())
679683
{
@@ -691,6 +695,8 @@ void ColumnEncoder::_convertPreloadingDataOption(Json::Value & options, const st
691695

692696
if (optionKey.empty())
693697
newOption.append(columnNameWithType);
698+
else if (keepOriginalOption)
699+
newOption[optionKey].append(columnNameWithType);
694700
else
695701
{
696702
// Reuse original jsonValue in order to get the other members of the object
@@ -727,6 +733,8 @@ void ColumnEncoder::_convertPreloadingDataOption(Json::Value & options, const st
727733
}
728734
if (optionKey.empty())
729735
newOption.append(newColumnNames);
736+
else if (keepOriginalOption)
737+
newOption[optionKey].append(newColumnNames);
730738
else
731739
{
732740
jsonValueOrg[optionKey] = newColumnNames;
@@ -751,10 +759,15 @@ void ColumnEncoder::_addTypeToColumnNamesInOptionsRecursively(Json::Value & opti
751759
{
752760
if(preloadingData)
753761
_convertPreloadingDataOption(options, optionName, colTypes);
754-
else //make sure "optionnam e".types is available for analyses incapable of preloadingData, this should be considered deprecated
762+
else //make sure "optionname".types is available for analyses incapable of preloadingData, this should be considered deprecated
755763
{
756764
options[optionName + ".types"] = options[optionName]["types"];
757-
options[optionName] = options[optionName]["value"];
765+
766+
std::string optionKey = options[optionName].isMember("optionKey") ? options[optionName]["optionKey"].asString() : "";
767+
bool keepOriginalOption = (!optionKey.empty() && options[optionName].size() > 3); // The option has other members: this must be kept
768+
769+
if (!keepOriginalOption)
770+
options[optionName] = options[optionName]["value"];
758771
}
759772
}
760773
else

0 commit comments

Comments
 (0)