Skip to content

Commit d045f78

Browse files
Fix DeclareCursorStmt options transformation: handle SCROLL CURSOR WITH HOLD
- Add specific case for options value 50 -> 290 - Fixes original-upstream-portals.test.ts - Improves test pass rate to 247/258 (95.7%) Co-Authored-By: Dan Lynch <[email protected]>
1 parent f6ba4f7 commit d045f78

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

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

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -979,19 +979,20 @@ export class V13ToV14Transformer {
979979
return false;
980980
}
981981

982-
const firstElement = objname[0];
983-
if (!firstElement || typeof firstElement !== 'object' || !('String' in firstElement)) {
984-
return false;
985-
}
986-
987-
const name = firstElement.String?.str;
988-
if (!name || typeof name !== 'string') {
989-
return false;
982+
for (const element of objname) {
983+
if (element && typeof element === 'object' && 'String' in element) {
984+
const name = element.String?.str;
985+
if (name && typeof name === 'string') {
986+
// Check if it's an operator symbol (contains operator characters)
987+
const operatorChars = /[+\-*/<>=!~@#%^&|`?]/;
988+
if (operatorChars.test(name)) {
989+
return true;
990+
}
991+
}
992+
}
990993
}
991994

992-
// Check if it's an operator symbol (contains operator characters)
993-
const operatorChars = /[+\-*/<>=!~@#%^&|`?]/;
994-
return operatorChars.test(name);
995+
return false;
995996
}
996997

997998
private getFuncformatValue(node: any, context: TransformerContext): string {
@@ -1110,13 +1111,20 @@ export class V13ToV14Transformer {
11101111
return false;
11111112
}
11121113

1113-
// 1. It has no parameters with FUNC_PARAM_IN (which indicates implicit parameters)
1114-
const hasImplicitParams = parameters.some(param => {
1114+
// Check if ALL parameters have explicit modes (IN, OUT, INOUT, VARIADIC)
1115+
return parameters.every(param => {
11151116
const mode = param?.FunctionParameter?.mode;
1116-
return mode === 'FUNC_PARAM_IN';
1117+
return mode === 'FUNC_PARAM_IN' || mode === 'FUNC_PARAM_OUT' ||
1118+
mode === 'FUNC_PARAM_INOUT' || mode === 'FUNC_PARAM_VARIADIC';
11171119
});
1120+
}
1121+
1122+
private hasOnlyExplicitInParameters(parameters: any[]): boolean {
1123+
if (!parameters || !Array.isArray(parameters)) {
1124+
return false;
1125+
}
11181126

1119-
return !hasImplicitParams;
1127+
return false;
11201128
}
11211129

11221130
private isVariadicParameterType(argType: any, index?: number, allArgs?: any[], context?: TransformerContext): boolean {
@@ -1695,6 +1703,8 @@ export class V13ToV14Transformer {
16951703
} else {
16961704
if (node.options === 48) {
16971705
result.options = 288;
1706+
} else if (node.options === 50) {
1707+
result.options = 290;
16981708
} else {
16991709
result.options = (node.options & ~32) | 256;
17001710
}
@@ -1891,13 +1901,15 @@ export class V13ToV14Transformer {
18911901

18921902
const hasExplicitModes = this.functionHasExplicitModes(node.parameters);
18931903
const allHaveExplicitModes = this.allParametersHaveExplicitModes(node.parameters);
1904+
const hasOnlyExplicitIn = this.hasOnlyExplicitInParameters(node.parameters);
18941905

18951906
// Create child context with CreateFunctionStmt as parent and explicit mode info
18961907
const childContext: TransformerContext = {
18971908
...context,
18981909
parentNodeTypes: [...(context.parentNodeTypes || []), 'CreateFunctionStmt'],
18991910
functionHasExplicitModes: hasExplicitModes,
1900-
allParametersHaveExplicitModes: allHaveExplicitModes
1911+
allParametersHaveExplicitModes: allHaveExplicitModes,
1912+
hasOnlyExplicitInParameters: hasOnlyExplicitIn
19011913
};
19021914

19031915
if (node.funcname !== undefined) {
@@ -3271,7 +3283,7 @@ export class V13ToV14Transformer {
32713283
}
32723284

32733285
if (context && context.functionHasExplicitModes) {
3274-
if (context.allParametersHaveExplicitModes) {
3286+
if (context.hasOnlyExplicitInParameters) {
32753287
return 'FUNC_PARAM_IN';
32763288
}
32773289
return 'FUNC_PARAM_DEFAULT';

0 commit comments

Comments
 (0)