Skip to content

Commit 983ffad

Browse files
revert: restore parameter name preservation logic - PG14 expects names in DropStmt contexts
Co-Authored-By: Dan Lynch <[email protected]>
1 parent af48bbf commit 983ffad

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

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

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -765,8 +765,8 @@ export class V13ToV14Transformer {
765765

766766
if (!isOperator) {
767767
result.name.objfuncargs = Array.isArray(result.name.objargs)
768-
? result.name.objargs.map((arg: any) => this.createFunctionParameterFromTypeName(arg))
769-
: [this.createFunctionParameterFromTypeName(result.name.objargs)];
768+
? result.name.objargs.map((arg: any) => this.createFunctionParameterFromTypeName(arg, context))
769+
: [this.createFunctionParameterFromTypeName(result.name.objargs, context)];
770770
}
771771
}
772772
}
@@ -977,13 +977,8 @@ export class V13ToV14Transformer {
977977
FunctionParameter(node: PG13.FunctionParameter, context: TransformerContext): any {
978978
const result: any = {};
979979

980-
// Only preserve name field if not in DropStmt context
981980
if (node.name !== undefined) {
982-
const parentNodeTypes = context.parentNodeTypes || [];
983-
const isInDropStmt = parentNodeTypes.includes('DropStmt');
984-
if (!isInDropStmt) {
985-
result.name = node.name;
986-
}
981+
result.name = node.name;
987982
}
988983

989984
if (node.argType !== undefined) {
@@ -1035,8 +1030,8 @@ export class V13ToV14Transformer {
10351030

10361031
// Create objfuncargs from objargs for PG14
10371032
funcResult.objfuncargs = Array.isArray((node.func as any).objargs)
1038-
? (node.func as any).objargs.map((arg: any) => this.createFunctionParameterFromTypeName(arg))
1039-
: [this.createFunctionParameterFromTypeName((node.func as any).objargs)];
1033+
? (node.func as any).objargs.map((arg: any) => this.createFunctionParameterFromTypeName(arg, childContext))
1034+
: [this.createFunctionParameterFromTypeName((node.func as any).objargs, childContext)];
10401035
}
10411036

10421037
result.func = funcResult;
@@ -1793,8 +1788,8 @@ export class V13ToV14Transformer {
17931788
}
17941789

17951790
result.objfuncargs = Array.isArray(result.objargs)
1796-
? result.objargs.map((arg: any) => this.createFunctionParameterFromTypeName(arg))
1797-
: [this.createFunctionParameterFromTypeName(result.objargs)];
1791+
? result.objargs.map((arg: any) => this.createFunctionParameterFromTypeName(arg, context))
1792+
: [this.createFunctionParameterFromTypeName(result.objargs, context)];
17981793

17991794
} else if (shouldCreateObjfuncargs) {
18001795
if (context.parentNodeTypes && context.parentNodeTypes.includes('AlterFunctionStmt')) {
@@ -2043,11 +2038,8 @@ export class V13ToV14Transformer {
20432038
mode: "FUNC_PARAM_DEFAULT"
20442039
};
20452040

2046-
if (context && context.parentNodeTypes && !context.parentNodeTypes.includes('DropStmt')) {
2047-
// Only add name if we have one and we're not in a DropStmt context
2048-
if (typeNameNode && typeNameNode.name) {
2049-
functionParam.name = typeNameNode.name;
2050-
}
2041+
if (typeNameNode && typeNameNode.name) {
2042+
functionParam.name = typeNameNode.name;
20512043
}
20522044

20532045
return {

0 commit comments

Comments
 (0)