Skip to content

Commit dfdc052

Browse files
committed
debug: add comprehensive debugging to visit and TypeName methods to trace transformation issues
Co-Authored-By: Dan Lynch <[email protected]>
1 parent 9454b0d commit dfdc052

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export class V16ToV17Transformer {
3131
visit(node: PG16.Node, context: TransformerContext = { parentNodeTypes: [] }): any {
3232
const nodeType = this.getNodeType(node);
3333

34+
if (nodeType === 'TypeName') {
35+
console.log('VISIT DEBUG - Processing TypeName node:', JSON.stringify(node, null, 2));
36+
}
37+
3438
// Handle empty objects
3539
if (!nodeType) {
3640
return {};
@@ -44,13 +48,24 @@ export class V16ToV17Transformer {
4448
...context,
4549
parentNodeTypes: [...context.parentNodeTypes, nodeType]
4650
};
51+
52+
if (nodeType === 'TypeName') {
53+
console.log('VISIT DEBUG - About to call TypeName method with data:', JSON.stringify(nodeData, null, 2));
54+
}
55+
4756
const result = (this[methodName] as any)(nodeData, childContext);
4857

58+
if (nodeType === 'TypeName') {
59+
console.log('VISIT DEBUG - TypeName method returned:', JSON.stringify(result, null, 2));
60+
}
4961

5062
return result;
5163
}
5264

5365
// If no specific method, return the node as-is
66+
if (nodeType === 'TypeName') {
67+
console.log('VISIT DEBUG - No TypeName method found, returning node as-is');
68+
}
5469
return node;
5570
}
5671

@@ -442,13 +457,34 @@ export class V16ToV17Transformer {
442457
}
443458

444459
TypeName(node: PG16.TypeName, context: TransformerContext): any {
460+
console.log('TypeName DEBUG - Called with node:', JSON.stringify(node, null, 2));
445461
const result: any = {};
446462

447463
if (node.names !== undefined) {
464+
console.log('TypeName DEBUG - Original node.names:', JSON.stringify(node.names, null, 2));
465+
448466
let names = Array.isArray(node.names)
449467
? node.names.map(item => this.transform(item as any, context))
450468
: this.transform(node.names as any, context);
451469

470+
console.log('TypeName DEBUG - After transformation, names:', JSON.stringify(names, null, 2));
471+
472+
if (Array.isArray(names) && names.length === 1) {
473+
const singleElement = names[0];
474+
console.log('TypeName DEBUG - Single element:', JSON.stringify(singleElement, null, 2));
475+
if (singleElement && typeof singleElement === 'object' && 'String' in singleElement) {
476+
const typeName = singleElement.String.str || singleElement.String.sval;
477+
console.log('TypeName DEBUG - Found single element type:', typeName);
478+
if (typeName === 'json') {
479+
console.log('TypeName DEBUG - Adding pg_catalog prefix for JSON type');
480+
names = [
481+
{ String: { sval: 'pg_catalog' } },
482+
...names
483+
];
484+
console.log('TypeName DEBUG - After adding prefix, names:', JSON.stringify(names, null, 2));
485+
}
486+
}
487+
}
452488

453489
result.names = names;
454490
}

0 commit comments

Comments
 (0)