@@ -69,6 +69,25 @@ export class V14ToV15Transformer {
6969 if ( typeof node !== 'object' || node === null ) return node ;
7070 if ( Array . isArray ( node ) ) return node . map ( item => this . transform ( item , context ) ) ;
7171
72+ const keys = Object . keys ( node ) ;
73+ if ( keys . length === 1 && typeof node [ keys [ 0 ] ] === 'object' && node [ keys [ 0 ] ] !== null ) {
74+ const nodeType = keys [ 0 ] ;
75+ const nodeData = node [ keys [ 0 ] ] ;
76+
77+ const transformedData : any = { } ;
78+ for ( const [ key , value ] of Object . entries ( nodeData ) ) {
79+ if ( Array . isArray ( value ) ) {
80+ transformedData [ key ] = value . map ( item => this . transform ( item as any , context ) ) ;
81+ } else if ( typeof value === 'object' && value !== null ) {
82+ transformedData [ key ] = this . transform ( value as any , context ) ;
83+ } else {
84+ transformedData [ key ] = value ;
85+ }
86+ }
87+
88+ return { [ nodeType ] : transformedData } ;
89+ }
90+
7291 const result : any = { } ;
7392 for ( const [ key , value ] of Object . entries ( node ) ) {
7493 if ( Array . isArray ( value ) ) {
@@ -107,39 +126,46 @@ export class V14ToV15Transformer {
107126 }
108127
109128 SelectStmt ( node : PG14 . SelectStmt , context : TransformerContext ) : any {
110- return this . transformGenericNode ( node , context ) ;
129+ const result = this . transformGenericNode ( node , context ) ;
130+ return { SelectStmt : result } ;
111131 }
112132
113133 A_Expr ( node : PG14 . A_Expr , context : TransformerContext ) : any {
114- return this . transformGenericNode ( node , context ) ;
134+ const result = this . transformGenericNode ( node , context ) ;
135+ return { A_Expr : result } ;
115136 }
116137
117138 InsertStmt ( node : PG14 . InsertStmt , context : TransformerContext ) : any {
118- return this . transformGenericNode ( node , context ) ;
139+ const result = this . transformGenericNode ( node , context ) ;
140+ return { InsertStmt : result } ;
119141 }
120142
121143 UpdateStmt ( node : PG14 . UpdateStmt , context : TransformerContext ) : any {
122- return this . transformGenericNode ( node , context ) ;
144+ const result = this . transformGenericNode ( node , context ) ;
145+ return { UpdateStmt : result } ;
123146 }
124147
125148 DeleteStmt ( node : PG14 . DeleteStmt , context : TransformerContext ) : any {
126- return this . transformGenericNode ( node , context ) ;
149+ const result = this . transformGenericNode ( node , context ) ;
150+ return { DeleteStmt : result } ;
127151 }
128152
129153 WithClause ( node : PG14 . WithClause , context : TransformerContext ) : any {
130154 return node ;
131155 }
132156
133157 ResTarget ( node : PG14 . ResTarget , context : TransformerContext ) : any {
134- return this . transformGenericNode ( node , context ) ;
158+ const result = this . transformGenericNode ( node , context ) ;
159+ return { ResTarget : result } ;
135160 }
136161
137162 BoolExpr ( node : PG14 . BoolExpr , context : TransformerContext ) : any {
138163 return node ;
139164 }
140165
141166 FuncCall ( node : PG14 . FuncCall , context : TransformerContext ) : any {
142- return this . transformGenericNode ( node , context ) ;
167+ const result = this . transformGenericNode ( node , context ) ;
168+ return { FuncCall : result } ;
143169 }
144170
145171 FuncExpr ( node : PG14 . FuncExpr , context : TransformerContext ) : any {
@@ -168,23 +194,26 @@ export class V14ToV15Transformer {
168194 }
169195 }
170196
171- return result ;
197+ return { A_Const : result } ;
172198 }
173199
174200 ColumnRef ( node : PG14 . ColumnRef , context : TransformerContext ) : any {
175- return this . transformGenericNode ( node , context ) ;
201+ const result = this . transformGenericNode ( node , context ) ;
202+ return { ColumnRef : result } ;
176203 }
177204
178205 TypeName ( node : PG14 . TypeName , context : TransformerContext ) : any {
179- return this . transformGenericNode ( node , context ) ;
206+ const result = this . transformGenericNode ( node , context ) ;
207+ return { TypeName : result } ;
180208 }
181209
182210 Alias ( node : PG14 . Alias , context : TransformerContext ) : any {
183211 return node ;
184212 }
185213
186214 RangeVar ( node : PG14 . RangeVar , context : TransformerContext ) : any {
187- return this . transformGenericNode ( node , context ) ;
215+ const result = this . transformGenericNode ( node , context ) ;
216+ return { RangeVar : result } ;
188217 }
189218
190219 A_ArrayExpr ( node : PG14 . A_ArrayExpr , context : TransformerContext ) : any {
@@ -200,7 +229,8 @@ export class V14ToV15Transformer {
200229 }
201230
202231 A_Star ( node : PG14 . A_Star , context : TransformerContext ) : any {
203- return node ;
232+ const result = this . transformGenericNode ( node , context ) ;
233+ return { A_Star : result } ;
204234 }
205235
206236 CaseExpr ( node : PG14 . CaseExpr , context : TransformerContext ) : any {
@@ -235,7 +265,7 @@ export class V14ToV15Transformer {
235265 delete result . str ;
236266 }
237267
238- return result ;
268+ return { String : result } ;
239269 }
240270
241271 Integer ( node : PG14 . Integer , context : TransformerContext ) : any {
@@ -250,7 +280,7 @@ export class V14ToV15Transformer {
250280 delete result . str ;
251281 }
252282
253- return result ;
283+ return { Float : result } ;
254284 }
255285
256286 BitString ( node : PG14 . BitString , context : TransformerContext ) : any {
@@ -261,23 +291,26 @@ export class V14ToV15Transformer {
261291 delete result . str ;
262292 }
263293
264- return result ;
294+ return { BitString : result } ;
265295 }
266296
267297 Null ( node : PG14 . Node , context : TransformerContext ) : any {
268298 return node ;
269299 }
270300
271301 List ( node : PG14 . List , context : TransformerContext ) : any {
272- return this . transformGenericNode ( node , context ) ;
302+ const result = this . transformGenericNode ( node , context ) ;
303+ return { List : result } ;
273304 }
274305
275306 CreateStmt ( node : PG14 . CreateStmt , context : TransformerContext ) : any {
276- return this . transformGenericNode ( node , context ) ;
307+ const result = this . transformGenericNode ( node , context ) ;
308+ return { CreateStmt : result } ;
277309 }
278310
279311 ColumnDef ( node : PG14 . ColumnDef , context : TransformerContext ) : any {
280- return node ;
312+ const result = this . transformGenericNode ( node , context ) ;
313+ return { ColumnDef : result } ;
281314 }
282315
283316 Constraint ( node : PG14 . Constraint , context : TransformerContext ) : any {
@@ -421,7 +454,8 @@ export class V14ToV15Transformer {
421454 }
422455
423456 DropStmt ( node : PG14 . DropStmt , context : TransformerContext ) : any {
424- return this . transformGenericNode ( node , context ) ;
457+ const result = this . transformGenericNode ( node , context ) ;
458+ return { DropStmt : result } ;
425459 }
426460
427461 TruncateStmt ( node : PG14 . TruncateStmt , context : TransformerContext ) : any {
@@ -441,27 +475,37 @@ export class V14ToV15Transformer {
441475 }
442476
443477 AlterTableStmt ( node : PG14 . AlterTableStmt , context : TransformerContext ) : any {
444- return this . transformGenericNode ( node , context ) ;
478+ const result = this . transformGenericNode ( node , context ) ;
479+ return { AlterTableStmt : result } ;
445480 }
446481
447482 AlterTableCmd ( node : PG14 . AlterTableCmd , context : TransformerContext ) : any {
448483 return node ;
449484 }
450485
451486 CreateFunctionStmt ( node : PG14 . CreateFunctionStmt , context : TransformerContext ) : any {
452- return this . transformGenericNode ( node , context ) ;
487+ const result = this . transformGenericNode ( node , context ) ;
488+ return { CreateFunctionStmt : result } ;
453489 }
454490
455491 FunctionParameter ( node : PG14 . FunctionParameter , context : TransformerContext ) : any {
456- return this . transformGenericNode ( node , context ) ;
492+ const result = this . transformGenericNode ( node , context ) ;
493+ return { FunctionParameter : result } ;
494+ }
495+
496+ CompositeTypeStmt ( node : PG14 . CompositeTypeStmt , context : TransformerContext ) : any {
497+ const result = this . transformGenericNode ( node , context ) ;
498+ return { CompositeTypeStmt : result } ;
457499 }
458500
459501 CreateEnumStmt ( node : PG14 . CreateEnumStmt , context : TransformerContext ) : any {
460- return node ;
502+ const result = this . transformGenericNode ( node , context ) ;
503+ return { CreateEnumStmt : result } ;
461504 }
462505
463506 CreateDomainStmt ( node : PG14 . CreateDomainStmt , context : TransformerContext ) : any {
464- return node ;
507+ const result = this . transformGenericNode ( node , context ) ;
508+ return { CreateDomainStmt : result } ;
465509 }
466510
467511 CreateRoleStmt ( node : PG14 . CreateRoleStmt , context : TransformerContext ) : any {
@@ -649,7 +693,8 @@ export class V14ToV15Transformer {
649693 }
650694
651695 ObjectWithArgs ( node : PG14 . ObjectWithArgs , context : TransformerContext ) : any {
652- return this . transformGenericNode ( node , context ) ;
696+ const result = this . transformGenericNode ( node , context ) ;
697+ return { ObjectWithArgs : result } ;
653698 }
654699
655700 AlterOperatorStmt ( node : PG14 . AlterOperatorStmt , context : TransformerContext ) : any {
@@ -788,9 +833,6 @@ export class V14ToV15Transformer {
788833 return node ;
789834 }
790835
791- CompositeTypeStmt ( node : PG14 . CompositeTypeStmt , context : TransformerContext ) : any {
792- return node ;
793- }
794836
795837 CreateRangeStmt ( node : PG14 . CreateRangeStmt , context : TransformerContext ) : any {
796838 return node ;
0 commit comments