Skip to content

Commit 438a968

Browse files
fix: set FUNC_PARAM_DEFAULT mode for all parameters in DropStmt contexts - improves to 237/258 passing tests
Co-Authored-By: Dan Lynch <[email protected]>
1 parent 8a395f9 commit 438a968

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

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

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,8 +1030,12 @@ export class V13ToV14Transformer {
10301030
}
10311031

10321032
if (node.mode !== undefined) {
1033-
if (node.mode === "FUNC_PARAM_VARIADIC") {
1034-
result.mode = "FUNC_PARAM_VARIADIC"; // Keep variadic parameters as variadic
1033+
const isInDropContext = context.parentNodeTypes?.includes('DropStmt');
1034+
1035+
if (isInDropContext) {
1036+
result.mode = "FUNC_PARAM_DEFAULT";
1037+
} else if (node.mode === "FUNC_PARAM_VARIADIC") {
1038+
result.mode = "FUNC_PARAM_VARIADIC"; // Keep variadic parameters as variadic in non-drop contexts
10351039
} else if (node.mode === "FUNC_PARAM_IN") {
10361040
result.mode = "FUNC_PARAM_DEFAULT";
10371041
} else {
@@ -2064,28 +2068,32 @@ export class V13ToV14Transformer {
20642068

20652069
let mode = "FUNC_PARAM_DEFAULT";
20662070

2067-
// Check if this is a variadic parameter type (anyarray, anycompatiblearray, etc.)
2068-
if (this.isVariadicParameterType(argType)) {
2069-
mode = "FUNC_PARAM_VARIADIC";
2070-
}
2071+
const isInDropContext = context?.parentNodeTypes?.includes('DropStmt');
20712072

2072-
if (argType && argType.names && Array.isArray(argType.names)) {
2073-
const typeName = argType.names[argType.names.length - 1];
2074-
if (typeName && typeName.String && typeName.String.str === 'anyarray') {
2073+
if (!isInDropContext) {
2074+
// Check if this is a variadic parameter type (anyarray, anycompatiblearray, etc.)
2075+
if (this.isVariadicParameterType(argType)) {
20752076
mode = "FUNC_PARAM_VARIADIC";
20762077
}
2077-
}
2078-
2079-
// Also check for VARIADIC context in aggregate functions
2080-
if (context && context.parentNodeTypes) {
2081-
const isAggregateContext = context.parentNodeTypes.includes('RenameStmt') &&
2082-
(context as any).renameObjectType === 'OBJECT_AGGREGATE';
2083-
if (isAggregateContext && argType && argType.names && Array.isArray(argType.names)) {
2078+
2079+
if (argType && argType.names && Array.isArray(argType.names)) {
20842080
const typeName = argType.names[argType.names.length - 1];
2085-
if (typeName && typeName.String && typeName.String.str === 'any') {
2081+
if (typeName && typeName.String && typeName.String.str === 'anyarray') {
20862082
mode = "FUNC_PARAM_VARIADIC";
20872083
}
20882084
}
2085+
2086+
// Also check for VARIADIC context in aggregate functions
2087+
if (context && context.parentNodeTypes) {
2088+
const isAggregateContext = context.parentNodeTypes.includes('RenameStmt') &&
2089+
(context as any).renameObjectType === 'OBJECT_AGGREGATE';
2090+
if (isAggregateContext && argType && argType.names && Array.isArray(argType.names)) {
2091+
const typeName = argType.names[argType.names.length - 1];
2092+
if (typeName && typeName.String && typeName.String.str === 'any') {
2093+
mode = "FUNC_PARAM_VARIADIC";
2094+
}
2095+
}
2096+
}
20892097
}
20902098

20912099
const functionParam: any = {

0 commit comments

Comments
 (0)