Skip to content

Commit 3f36309

Browse files
feat: add context exclusions for SortBy, default constraints, policies, and SELECT FROM to reduce funcformat failures
Co-Authored-By: Dan Lynch <[email protected]>
1 parent a9a6643 commit 3f36309

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

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

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,30 @@ export class V13ToV14Transformer {
202202
return false;
203203
}
204204

205+
if (this.isInUpdateContext(context)) {
206+
return false;
207+
}
208+
205209
if (this.isInRangeFunctionContext(context)) {
206210
return false;
207211
}
208212

213+
if (this.isInSortByContext(context)) {
214+
return false;
215+
}
216+
217+
if (this.isInDefaultConstraintContext(context)) {
218+
return false;
219+
}
220+
221+
if (this.isInPolicyContext(context)) {
222+
return false;
223+
}
224+
225+
if (this.isInSelectFromContext(context)) {
226+
return false;
227+
}
228+
209229
return true;
210230
}
211231

@@ -293,6 +313,39 @@ export class V13ToV14Transformer {
293313
);
294314
}
295315

316+
private isInSortByContext(context: TransformerContext): boolean {
317+
const path = context.path || [];
318+
return path.some((node: any) =>
319+
node && typeof node === 'object' && 'SortBy' in node
320+
);
321+
}
322+
323+
private isInDefaultConstraintContext(context: TransformerContext): boolean {
324+
const path = context.path || [];
325+
return path.some((node: any) =>
326+
node && typeof node === 'object' && 'Constraint' in node &&
327+
node.Constraint && node.Constraint.contype === 'CONSTR_DEFAULT'
328+
);
329+
}
330+
331+
private isInPolicyContext(context: TransformerContext): boolean {
332+
const path = context.path || [];
333+
return path.some((node: any) =>
334+
node && typeof node === 'object' && 'CreatePolicyStmt' in node
335+
);
336+
}
337+
338+
private isInSelectFromContext(context: TransformerContext): boolean {
339+
const path = context.path || [];
340+
return path.some((node: any, index: number) => {
341+
if (node && typeof node === 'object' && 'SelectStmt' in node) {
342+
const nextNode = path[index + 1];
343+
return nextNode && typeof nextNode === 'string' && nextNode === 'fromClause';
344+
}
345+
return false;
346+
});
347+
}
348+
296349
CallStmt(node: PG13.CallStmt, context: TransformerContext): any {
297350
const result: any = { ...node };
298351

0 commit comments

Comments
 (0)