Skip to content

Commit 3269ba0

Browse files
fix: update A_Const and Integer transformation methods
- Reverted A_Const to handle individual value properties (ival, fval, etc.) - Updated Integer method to use spread operator pattern from v13-to-v14 - Improved test pass rate from 77/258 to 84/258 tests - Fixed TypeScript compilation errors with A_Const val property Co-Authored-By: Dan Lynch <[email protected]>
1 parent 1f734a8 commit 3269ba0

File tree

1 file changed

+93
-19
lines changed

1 file changed

+93
-19
lines changed

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

Lines changed: 93 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -508,24 +508,28 @@ export class V15ToV16Transformer {
508508
A_Const(node: PG15.A_Const, context: TransformerContext): any {
509509
const result: any = {};
510510

511-
if (node.isnull !== undefined && !node.isnull) {
512-
result.isnull = node.isnull;
511+
if (node.ival !== undefined) {
512+
result.ival = this.transform(node.ival as any, context);
513513
}
514514

515-
if (node.sval !== undefined) {
516-
result.sval = node.sval;
515+
if (node.fval !== undefined) {
516+
result.fval = this.transform(node.fval as any, context);
517517
}
518518

519-
if (node.ival !== undefined) {
520-
result.ival = node.ival;
519+
if (node.boolval !== undefined) {
520+
result.boolval = this.transform(node.boolval as any, context);
521521
}
522522

523-
if (node.fval !== undefined) {
524-
result.fval = node.fval;
523+
if (node.sval !== undefined) {
524+
result.sval = this.transform(node.sval as any, context);
525525
}
526526

527527
if (node.bsval !== undefined) {
528-
result.bsval = node.bsval;
528+
result.bsval = this.transform(node.bsval as any, context);
529+
}
530+
531+
if (node.isnull !== undefined) {
532+
result.isnull = node.isnull;
529533
}
530534

531535
if (node.location !== undefined) {
@@ -858,11 +862,7 @@ export class V15ToV16Transformer {
858862
}
859863

860864
Integer(node: PG15.Integer, context: TransformerContext): any {
861-
const result: any = {};
862-
863-
if (node.ival !== undefined) {
864-
result.ival = node.ival;
865-
}
865+
const result: any = { ...node };
866866

867867
return { Integer: result };
868868
}
@@ -2826,23 +2826,97 @@ export class V15ToV16Transformer {
28262826
}
28272827

28282828
CreateTableSpaceStmt(node: PG15.CreateTableSpaceStmt, context: TransformerContext): any {
2829-
return node;
2829+
const result: any = {};
2830+
2831+
if (node.tablespacename !== undefined) {
2832+
result.tablespacename = node.tablespacename;
2833+
}
2834+
2835+
if (node.owner !== undefined) {
2836+
result.owner = this.transform(node.owner as any, context);
2837+
}
2838+
2839+
if (node.location !== undefined) {
2840+
result.location = node.location;
2841+
}
2842+
2843+
if (node.options !== undefined) {
2844+
result.options = Array.isArray(node.options)
2845+
? node.options.map((item: any) => this.transform(item as any, context))
2846+
: this.transform(node.options as any, context);
2847+
}
2848+
2849+
return { CreateTableSpaceStmt: result };
28302850
}
28312851

28322852
DropTableSpaceStmt(node: PG15.DropTableSpaceStmt, context: TransformerContext): any {
2833-
return node;
2853+
const result: any = {};
2854+
2855+
if (node.tablespacename !== undefined) {
2856+
result.tablespacename = node.tablespacename;
2857+
}
2858+
2859+
if (node.missing_ok !== undefined) {
2860+
result.missing_ok = node.missing_ok;
2861+
}
2862+
2863+
return { DropTableSpaceStmt: result };
28342864
}
28352865

28362866
AlterTableSpaceOptionsStmt(node: PG15.AlterTableSpaceOptionsStmt, context: TransformerContext): any {
2837-
return node;
2867+
const result: any = {};
2868+
2869+
if (node.tablespacename !== undefined) {
2870+
result.tablespacename = node.tablespacename;
2871+
}
2872+
2873+
if (node.options !== undefined) {
2874+
result.options = Array.isArray(node.options)
2875+
? node.options.map((item: any) => this.transform(item as any, context))
2876+
: this.transform(node.options as any, context);
2877+
}
2878+
2879+
if (node.isReset !== undefined) {
2880+
result.isReset = node.isReset;
2881+
}
2882+
2883+
return { AlterTableSpaceOptionsStmt: result };
28382884
}
28392885

28402886
CreateExtensionStmt(node: PG15.CreateExtensionStmt, context: TransformerContext): any {
2841-
return node;
2887+
const result: any = {};
2888+
2889+
if (node.extname !== undefined) {
2890+
result.extname = node.extname;
2891+
}
2892+
2893+
if (node.if_not_exists !== undefined) {
2894+
result.if_not_exists = node.if_not_exists;
2895+
}
2896+
2897+
if (node.options !== undefined) {
2898+
result.options = Array.isArray(node.options)
2899+
? node.options.map((item: any) => this.transform(item as any, context))
2900+
: this.transform(node.options as any, context);
2901+
}
2902+
2903+
return { CreateExtensionStmt: result };
28422904
}
28432905

28442906
AlterExtensionStmt(node: PG15.AlterExtensionStmt, context: TransformerContext): any {
2845-
return node;
2907+
const result: any = {};
2908+
2909+
if (node.extname !== undefined) {
2910+
result.extname = node.extname;
2911+
}
2912+
2913+
if (node.options !== undefined) {
2914+
result.options = Array.isArray(node.options)
2915+
? node.options.map((item: any) => this.transform(item as any, context))
2916+
: this.transform(node.options as any, context);
2917+
}
2918+
2919+
return { AlterExtensionStmt: result };
28462920
}
28472921

28482922
CreateFdwStmt(node: PG15.CreateFdwStmt, context: TransformerContext): any {

0 commit comments

Comments
 (0)