fix: fix userAlias issue when keepColumnName is set to true
This commit is contained in:
parent
05c7ec6135
commit
77d2737f91
|
@ -52,6 +52,7 @@ typedef struct SExprNode {
|
||||||
SArray* pAssociation;
|
SArray* pAssociation;
|
||||||
bool orderAlias;
|
bool orderAlias;
|
||||||
bool asAlias;
|
bool asAlias;
|
||||||
|
bool asParam;
|
||||||
} SExprNode;
|
} SExprNode;
|
||||||
|
|
||||||
typedef enum EColumnType {
|
typedef enum EColumnType {
|
||||||
|
|
|
@ -214,6 +214,18 @@ void nodesWalkExprsPostOrder(SNodeList* pList, FNodeWalker walker, void* pContex
|
||||||
(void)walkExprs(pList, TRAVERSAL_POSTORDER, walker, pContext);
|
(void)walkExprs(pList, TRAVERSAL_POSTORDER, walker, pContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void checkParamIsFunc(SFunctionNode *pFunc) {
|
||||||
|
int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList);
|
||||||
|
if (numOfParams > 1) {
|
||||||
|
for (int32_t i = 0; i < numOfParams; ++i) {
|
||||||
|
SNode* pPara = nodesListGetNode(pFunc->pParameterList, i);
|
||||||
|
if (nodeType(pPara) == QUERY_NODE_FUNCTION) {
|
||||||
|
((SFunctionNode *)pPara)->node.asParam = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static EDealRes rewriteExprs(SNodeList* pNodeList, ETraversalOrder order, FNodeRewriter rewriter, void* pContext);
|
static EDealRes rewriteExprs(SNodeList* pNodeList, ETraversalOrder order, FNodeRewriter rewriter, void* pContext);
|
||||||
|
|
||||||
static EDealRes rewriteExpr(SNode** pRawNode, ETraversalOrder order, FNodeRewriter rewriter, void* pContext) {
|
static EDealRes rewriteExpr(SNode** pRawNode, ETraversalOrder order, FNodeRewriter rewriter, void* pContext) {
|
||||||
|
@ -248,9 +260,12 @@ static EDealRes rewriteExpr(SNode** pRawNode, ETraversalOrder order, FNodeRewrit
|
||||||
case QUERY_NODE_LOGIC_CONDITION:
|
case QUERY_NODE_LOGIC_CONDITION:
|
||||||
res = rewriteExprs(((SLogicConditionNode*)pNode)->pParameterList, order, rewriter, pContext);
|
res = rewriteExprs(((SLogicConditionNode*)pNode)->pParameterList, order, rewriter, pContext);
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_FUNCTION:
|
case QUERY_NODE_FUNCTION: {
|
||||||
res = rewriteExprs(((SFunctionNode*)pNode)->pParameterList, order, rewriter, pContext);
|
SFunctionNode* pFunc = (SFunctionNode*)pNode;
|
||||||
|
checkParamIsFunc(pFunc);
|
||||||
|
res = rewriteExprs(pFunc->pParameterList, order, rewriter, pContext);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case QUERY_NODE_REAL_TABLE:
|
case QUERY_NODE_REAL_TABLE:
|
||||||
case QUERY_NODE_TEMP_TABLE:
|
case QUERY_NODE_TEMP_TABLE:
|
||||||
break; // todo
|
break; // todo
|
||||||
|
|
|
@ -1760,7 +1760,7 @@ static int32_t translateMultiResFunc(STranslateContext* pCxt, SFunctionNode* pFu
|
||||||
"%s(*) is only supported in SELECTed list", pFunc->functionName);
|
"%s(*) is only supported in SELECTed list", pFunc->functionName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tsKeepColumnName && 1 == LIST_LENGTH(pFunc->pParameterList) && !pFunc->node.asAlias) {
|
if (tsKeepColumnName && 1 == LIST_LENGTH(pFunc->pParameterList) && !pFunc->node.asAlias && !pFunc->node.asParam) {
|
||||||
strcpy(pFunc->node.userAlias, ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->userAlias);
|
strcpy(pFunc->node.userAlias, ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->userAlias);
|
||||||
strcpy(pFunc->node.aliasName, pFunc->node.userAlias);
|
strcpy(pFunc->node.aliasName, pFunc->node.userAlias);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue