Skip to content

Commit bb3785e

Browse files
fix: add comprehensive node wrapping for v15-to-v16 transformer core methods
- Fixed ColumnRef, A_Const, FuncCall, Integer, Float, BitString node wrapping - Improved v15-to-v16 transformer from 2/258 to 7/258 passing tests - Following v13-to-v14 transformer patterns for consistent node wrapping - All methods now properly transform child nodes and return wrapped results Co-Authored-By: Dan Lynch <[email protected]>
1 parent 31ebb53 commit bb3785e

File tree

1 file changed

+110
-6
lines changed

1 file changed

+110
-6
lines changed

packages/transform/src/transformers/v15-to-v16.ts

Lines changed: 110 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,19 +332,105 @@ export class V15ToV16Transformer {
332332
}
333333

334334
FuncCall(node: PG15.FuncCall, context: TransformerContext): any {
335-
return node;
335+
const result: any = {};
336+
337+
if (node.funcname !== undefined) {
338+
result.funcname = Array.isArray(node.funcname)
339+
? node.funcname.map((item: any) => this.transform(item as any, context))
340+
: this.transform(node.funcname as any, context);
341+
}
342+
343+
if (node.args !== undefined) {
344+
result.args = Array.isArray(node.args)
345+
? node.args.map((item: any) => this.transform(item as any, context))
346+
: this.transform(node.args as any, context);
347+
}
348+
349+
if (node.agg_order !== undefined) {
350+
result.agg_order = Array.isArray(node.agg_order)
351+
? node.agg_order.map((item: any) => this.transform(item as any, context))
352+
: this.transform(node.agg_order as any, context);
353+
}
354+
355+
if (node.agg_filter !== undefined) {
356+
result.agg_filter = this.transform(node.agg_filter as any, context);
357+
}
358+
359+
if (node.over !== undefined) {
360+
result.over = this.transform(node.over as any, context);
361+
}
362+
363+
if (node.agg_within_group !== undefined) {
364+
result.agg_within_group = node.agg_within_group;
365+
}
366+
367+
if (node.agg_star !== undefined) {
368+
result.agg_star = node.agg_star;
369+
}
370+
371+
if (node.agg_distinct !== undefined) {
372+
result.agg_distinct = node.agg_distinct;
373+
}
374+
375+
if (node.func_variadic !== undefined) {
376+
result.func_variadic = node.func_variadic;
377+
}
378+
379+
if (node.funcformat !== undefined) {
380+
result.funcformat = node.funcformat;
381+
}
382+
383+
if (node.location !== undefined) {
384+
result.location = node.location;
385+
}
386+
387+
return { FuncCall: result };
336388
}
337389

338390
FuncExpr(node: PG15.FuncExpr, context: TransformerContext): any {
339391
return node;
340392
}
341393

342394
A_Const(node: PG15.A_Const, context: TransformerContext): any {
343-
return node;
395+
const result: any = {};
396+
397+
if (node.sval !== undefined) {
398+
result.sval = node.sval;
399+
}
400+
401+
if (node.ival !== undefined) {
402+
result.ival = node.ival;
403+
}
404+
405+
if (node.fval !== undefined) {
406+
result.fval = node.fval;
407+
}
408+
409+
if (node.bsval !== undefined) {
410+
result.bsval = node.bsval;
411+
}
412+
413+
if (node.location !== undefined) {
414+
result.location = node.location;
415+
}
416+
417+
return { A_Const: result };
344418
}
345419

346420
ColumnRef(node: PG15.ColumnRef, context: TransformerContext): any {
347-
return node;
421+
const result: any = {};
422+
423+
if (node.fields !== undefined) {
424+
result.fields = Array.isArray(node.fields)
425+
? node.fields.map((item: any) => this.transform(item as any, context))
426+
: this.transform(node.fields as any, context);
427+
}
428+
429+
if (node.location !== undefined) {
430+
result.location = node.location;
431+
}
432+
433+
return { ColumnRef: result };
348434
}
349435

350436
TypeName(node: PG15.TypeName, context: TransformerContext): any {
@@ -490,19 +576,37 @@ export class V15ToV16Transformer {
490576
}
491577

492578
Integer(node: PG15.Integer, context: TransformerContext): any {
493-
return node;
579+
const result: any = {};
580+
581+
if (node.ival !== undefined) {
582+
result.ival = node.ival;
583+
}
584+
585+
return { Integer: result };
494586
}
495587

496588
Float(node: PG15.Float, context: TransformerContext): any {
497-
return node;
589+
const result: any = {};
590+
591+
if (node.fval !== undefined) {
592+
result.fval = node.fval;
593+
}
594+
595+
return { Float: result };
498596
}
499597

500598
Boolean(node: PG15.Boolean, context: TransformerContext): any {
501599
return node;
502600
}
503601

504602
BitString(node: PG15.BitString, context: TransformerContext): any {
505-
return node;
603+
const result: any = {};
604+
605+
if (node.bsval !== undefined) {
606+
result.bsval = node.bsval;
607+
}
608+
609+
return { BitString: result };
506610
}
507611

508612
Null(node: PG15.Node, context: TransformerContext): any {

0 commit comments

Comments
 (0)