Skip to content

Commit e1ff897

Browse files
committed
remove integer issues
1 parent 06c5963 commit e1ff897

File tree

2 files changed

+7
-43
lines changed

2 files changed

+7
-43
lines changed

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

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@ export class V14ToV15Transformer {
8080
if (Array.isArray(value)) {
8181
if (key === 'arrayBounds') {
8282
transformedData[key] = value.map(item => {
83-
// In PG15, -1 values in arrayBounds are represented as empty Integer objects
84-
if (item && typeof item === 'object' && 'Integer' in item &&
85-
item.Integer && item.Integer.ival === -1) {
86-
return { Integer: {} };
87-
}
8883
return this.transform(item as any, context);
8984
});
9085
} else {
@@ -114,11 +109,6 @@ export class V14ToV15Transformer {
114109
if (Array.isArray(value)) {
115110
if (key === 'arrayBounds') {
116111
result[key] = value.map(item => {
117-
// In PG15, -1 values in arrayBounds are represented as empty Integer objects
118-
if (item && typeof item === 'object' && 'Integer' in item &&
119-
item.Integer && item.Integer.ival === -1) {
120-
return { Integer: {} };
121-
}
122112
return this.transform(item as any, context);
123113
});
124114
} else {
@@ -231,8 +221,7 @@ export class V14ToV15Transformer {
231221
delete result.val;
232222
} else if (val.Integer !== undefined) {
233223
if (val.Integer.ival !== undefined) {
234-
// In PG15, certain integer values in A_Const are converted to empty objects
235-
if (val.Integer.ival <= 0) {
224+
if (val.Integer.ival === 0) {
236225
result.ival = {};
237226
} else {
238227
result.ival = { ival: val.Integer.ival };
@@ -453,24 +442,24 @@ export class V14ToV15Transformer {
453442
}
454443

455444
// AlterTableCmd context: SET STATISTICS with ival 0 or -1 -> empty Integer
456-
if (context.parentNodeTypes?.includes('AlterTableCmd') && !context.parentNodeTypes?.includes('DefineStmt') && (node.ival === 0 || node.ival === -1)) {
445+
if (context.parentNodeTypes?.includes('AlterTableCmd') && !context.parentNodeTypes?.includes('DefineStmt') && (node.ival === 0)) {
457446
return { Integer: {} };
458447
}
459448

460449
// DefineStmt context: specific cases where ival should become empty Integer
461450
if (context.parentNodeTypes?.includes('DefineStmt')) {
462451
const defElemName = (context as any).defElemName;
463452

464-
if (defElemName === 'initcond' && (node.ival === 0 || node.ival === -100)) {
453+
if (defElemName === 'initcond' && (node.ival === 0)) {
465454
return { Integer: {} };
466455
}
467456

468457
if (defElemName === 'sspace' && node.ival === 0) {
469458
return { Integer: {} };
470459
}
471460

472-
// DefineStmt args context: ival -1 or 0 should become empty Integer for aggregates
473-
if (!defElemName && (node.ival === -1 || node.ival === 0)) {
461+
// DefineStmt args context: ival 0 should become empty Integer for aggregates
462+
if (!defElemName && (node.ival === 0)) {
474463
return { Integer: {} };
475464
}
476465
}
@@ -487,7 +476,7 @@ export class V14ToV15Transformer {
487476
return { Integer: {} };
488477
}
489478

490-
if (defElemName === 'increment' && node.ival === -1) {
479+
if (defElemName === 'increment' && node.ival === 0) {
491480
return { Integer: {} };
492481
}
493482
}

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

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,8 @@ export class V15ToV16Transformer {
3636
visit(node: PG15.Node, context: TransformerContext = { parentNodeTypes: [] }): any {
3737
const nodeType = this.getNodeType(node);
3838

39-
// Handle empty objects - check if they should be transformed as Integer nodes
39+
// Handle empty objects
4040
if (!nodeType) {
41-
const parentTypes = context.parentNodeTypes || [];
42-
43-
if (parentTypes.includes('TypeName')) {
44-
return this.Integer(node as any, context);
45-
}
46-
4741
return {};
4842
}
4943

@@ -543,25 +537,6 @@ export class V15ToV16Transformer {
543537
}
544538
}
545539

546-
if (result.ival !== undefined) {
547-
const childContext: TransformerContext = {
548-
...context,
549-
parentNodeTypes: [...(context.parentNodeTypes || []), 'A_Const']
550-
};
551-
552-
// Handle empty Integer objects directly since transform() can't detect their type
553-
if (typeof result.ival === 'object' && Object.keys(result.ival).length === 0) {
554-
const parentTypes = childContext.parentNodeTypes || [];
555-
556-
if (parentTypes.includes('TypeName') ||
557-
(parentTypes.includes('DefineStmt') && !(context as any).defElemName)) {
558-
result.ival = this.Integer(result.ival as any, childContext).Integer;
559-
}
560-
} else {
561-
result.ival = this.transform(result.ival as any, childContext);
562-
}
563-
}
564-
565540
return { A_Const: result };
566541
}
567542

0 commit comments

Comments
 (0)