Skip to content

Commit 5adabf6

Browse files
feat: add XmlExpr context exclusion for funcformat to handle XML function calls
Co-Authored-By: Dan Lynch <[email protected]>
1 parent db817f0 commit 5adabf6

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

packages/transform/src/transformers/v13-to-v14.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ export class V13ToV14Transformer {
172172
return false;
173173
}
174174

175-
if (this.isInTypeCastContext(context) && this.isAggregateFunction(context)) {
175+
if (this.isInTypeCastContext(context)) {
176+
return false;
177+
}
178+
179+
if (this.isInXmlExprContext(context)) {
176180
return false;
177181
}
178182

@@ -249,18 +253,11 @@ export class V13ToV14Transformer {
249253
);
250254
}
251255

252-
private isAggregateFunction(context: TransformerContext): boolean {
253-
if (context.currentNode && 'FuncCall' in context.currentNode) {
254-
const funcCall = context.currentNode.FuncCall;
255-
if (funcCall?.funcname && Array.isArray(funcCall.funcname)) {
256-
const lastName = funcCall.funcname[funcCall.funcname.length - 1];
257-
if (lastName && 'String' in lastName) {
258-
const name = lastName.String.str || lastName.String.sval;
259-
return ['avg', 'sum', 'count', 'min', 'max', 'stddev', 'variance'].includes(name);
260-
}
261-
}
262-
}
263-
return false;
256+
private isInXmlExprContext(context: TransformerContext): boolean {
257+
const path = context.path || [];
258+
return path.some((node: any) =>
259+
node && typeof node === 'object' && 'XmlExpr' in node
260+
);
264261
}
265262

266263
CallStmt(node: PG13.CallStmt, context: TransformerContext): any {

0 commit comments

Comments
 (0)