Skip to content

Commit 726490d

Browse files
feat: add CreateStatsStmt transformation method to wrap expressions in StatsElem nodes for PG14 compatibility
Co-Authored-By: Dan Lynch <[email protected]>
1 parent f4c8006 commit 726490d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2701,6 +2701,46 @@ export class V13ToV14Transformer {
27012701
return { StatsElem: result };
27022702
}
27032703

2704+
CreateStatsStmt(node: any, context: TransformerContext): any {
2705+
const result: any = {};
2706+
2707+
if (node.defnames !== undefined) {
2708+
result.defnames = Array.isArray(node.defnames)
2709+
? node.defnames.map((item: any) => this.transform(item as any, context))
2710+
: this.transform(node.defnames as any, context);
2711+
}
2712+
2713+
if (node.stat_types !== undefined) {
2714+
result.stat_types = Array.isArray(node.stat_types)
2715+
? node.stat_types.map((item: any) => this.transform(item as any, context))
2716+
: this.transform(node.stat_types as any, context);
2717+
}
2718+
2719+
if (node.exprs !== undefined) {
2720+
result.exprs = Array.isArray(node.exprs)
2721+
? node.exprs.map((expr: any) => {
2722+
return { StatsElem: { expr: this.transform(expr as any, context) } };
2723+
})
2724+
: [{ StatsElem: { expr: this.transform(node.exprs as any, context) } }];
2725+
}
2726+
2727+
if (node.relations !== undefined) {
2728+
result.relations = Array.isArray(node.relations)
2729+
? node.relations.map((item: any) => this.transform(item as any, context))
2730+
: this.transform(node.relations as any, context);
2731+
}
2732+
2733+
if (node.stxcomment !== undefined) {
2734+
result.stxcomment = node.stxcomment;
2735+
}
2736+
2737+
if (node.if_not_exists !== undefined) {
2738+
result.if_not_exists = node.if_not_exists;
2739+
}
2740+
2741+
return { CreateStatsStmt: result };
2742+
}
2743+
27042744
CreateStmt(node: any, context: TransformerContext): any {
27052745
const result: any = {};
27062746

0 commit comments

Comments
 (0)