Skip to content

Commit f4c8006

Browse files
fix: add pg_collation_for function with pg_catalog prefix handling for COERCE_SQL_SYNTAX - fixes collate-111.sql
Co-Authored-By: Dan Lynch <[email protected]>
1 parent a39814d commit f4c8006

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,21 @@ export class V13ToV14Transformer {
986986
'collation_for'
987987
];
988988

989+
// Handle pg_collation_for specifically - depends on pg_catalog prefix
990+
if (funcname.toLowerCase() === 'pg_collation_for') {
991+
// Check if the function has pg_catalog prefix by examining the node
992+
if (node && node.funcname && Array.isArray(node.funcname) && node.funcname.length >= 2) {
993+
const firstElement = node.funcname[0];
994+
if (firstElement && typeof firstElement === 'object' && 'String' in firstElement) {
995+
const prefix = firstElement.String.str || firstElement.String.sval;
996+
if (prefix === 'pg_catalog') {
997+
return 'COERCE_SQL_SYNTAX';
998+
}
999+
}
1000+
}
1001+
return 'COERCE_EXPLICIT_CALL';
1002+
}
1003+
9891004
if (explicitCallFunctions.includes(funcname.toLowerCase())) {
9901005
return 'COERCE_EXPLICIT_CALL';
9911006
}

0 commit comments

Comments
 (0)