Skip to content

Commit db90b54

Browse files
fix: prioritize shouldCreateObjfuncargs logic for CreateCastStmt contexts
Co-Authored-By: Dan Lynch <[email protected]>
1 parent af195a4 commit db90b54

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,8 +924,14 @@ export class V13ToV14Transformer {
924924
: [this.transform(result.objargs, context)];
925925
}
926926

927-
if (result.objfuncargs !== undefined) {
928-
const shouldPreserveObjfuncargs = this.shouldPreserveObjfuncargs(context);
927+
// Handle objfuncargs based on context
928+
const shouldCreateObjfuncargs = this.shouldCreateObjfuncargs(context);
929+
const shouldPreserveObjfuncargs = this.shouldPreserveObjfuncargs(context);
930+
931+
if (shouldCreateObjfuncargs) {
932+
// For CreateCastStmt contexts, always set empty objfuncargs
933+
result.objfuncargs = [];
934+
} else if (result.objfuncargs !== undefined) {
929935
if (shouldPreserveObjfuncargs) {
930936
result.objfuncargs = Array.isArray(result.objfuncargs)
931937
? result.objfuncargs.map((item: any) => this.transform(item, context))
@@ -939,6 +945,17 @@ export class V13ToV14Transformer {
939945
}
940946

941947
private shouldCreateObjfuncargs(context: TransformerContext): boolean {
948+
if (!context.parentNodeTypes || context.parentNodeTypes.length === 0) {
949+
return false;
950+
}
951+
952+
// CreateCastStmt contexts need empty objfuncargs added in PG14
953+
for (const parentType of context.parentNodeTypes) {
954+
if (parentType === 'CreateCastStmt') {
955+
return true;
956+
}
957+
}
958+
942959
return false;
943960
}
944961

0 commit comments

Comments
 (0)