Skip to content

Commit 1f784cc

Browse files
CASE THEN/ELSE {value expression} (#7810)
## Rationale There has been a long running issue where some operators in THEN/ELSE expressions have unexpectedly required parentheses. ## Related Pull Requests - <!-- list of links to related pull requests (replace this comment) --> ## Changes - <!-- list of descriptions of changes that are worth noting (replace this comment) --> <!-- list of standard tasks (remove this comment to enable) ## Tasks 📍 - [ ] Claude Code Review - [ ] Manual Testing - [ ] Test Automation - [ ] Verify Fix -->
1 parent 630ce92 commit 1f784cc

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

query/src/org/labkey/query/QueryTestCase.jsp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,8 +911,10 @@ d,seven,twelve,day,month,date,duration,guid
911911
assertFalse(rs.getColumn(1).isHidden());
912912
assertEquals("0.00", rs.getColumn(1).getFormat());
913913
}
914-
}
914+
},
915915
916+
// test operators in THEN expression
917+
new SqlTest("SELECT CASE WHEN 1=1 THEN 'a' || 'b' ELSE 'x' || 'y' END")
916918
);
917919
918920
List<SqlTest> postgres = List.of(

query/src/org/labkey/query/sql/SqlBase.g

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -729,15 +729,15 @@ caseExpression
729729
;
730730

731731
whenClause
732-
: (WHEN^ logicalExpression THEN! unaryExpression)
732+
: (WHEN^ logicalExpression THEN! valueExpression)
733733
;
734734

735735
altWhenClause
736-
: (WHEN^ unaryExpression THEN! unaryExpression)
736+
: (WHEN^ unaryExpression THEN! valueExpression)
737737
;
738738

739739
elseClause
740-
: (ELSE^ unaryExpression)
740+
: (ELSE^ valueExpression)
741741
;
742742

743743

0 commit comments

Comments
 (0)