Skip to content

Commit 334defb

Browse files
fix: improve VARIADIC parameter detection in createFunctionParameterFromTypeName method
- Add logic to detect VARIADIC parameters based on type names (anyarray, anycompatiblearray, etc.) - Add special handling for aggregate function contexts where 'any' type should be VARIADIC - Fixes create_aggregate test case for ALTER AGGREGATE my_rank rename statement - Maintains 234/258 passing tests Co-Authored-By: Dan Lynch <[email protected]>
1 parent 89a9125 commit 334defb

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2059,9 +2059,28 @@ export class V13ToV14Transformer {
20592059

20602060
const argType = transformedTypeName.TypeName ? transformedTypeName.TypeName : transformedTypeName;
20612061

2062+
let mode = "FUNC_PARAM_DEFAULT";
2063+
2064+
// Check if this is a variadic parameter type (anyarray, anycompatiblearray, etc.)
2065+
if (this.isVariadicParameterType(argType)) {
2066+
mode = "FUNC_PARAM_VARIADIC";
2067+
}
2068+
2069+
// Also check for VARIADIC context in aggregate functions
2070+
if (context && context.parentNodeTypes) {
2071+
const isAggregateContext = context.parentNodeTypes.includes('RenameStmt') &&
2072+
(context as any).renameObjectType === 'OBJECT_AGGREGATE';
2073+
if (isAggregateContext && argType && argType.names && Array.isArray(argType.names)) {
2074+
const typeName = argType.names[argType.names.length - 1];
2075+
if (typeName && typeName.String && typeName.String.str === 'any') {
2076+
mode = "FUNC_PARAM_VARIADIC";
2077+
}
2078+
}
2079+
}
2080+
20622081
const functionParam: any = {
20632082
argType: argType,
2064-
mode: "FUNC_PARAM_DEFAULT"
2083+
mode: mode
20652084
};
20662085

20672086
const shouldAddParameterName = context && context.parentNodeTypes &&

0 commit comments

Comments
 (0)