private Expression readCoalesceExpression ( ) { Expression c = null ; // turn into a CASEWHEN read ( ) ; readThis ( Tokens . OPENBRACKET ) ; Expression leaf = null ; while ( true ) { Expression current = XreadValueExpression ( ) ; if ( leaf != null && token . tokenType == Tokens . CLOSEBRACKET ) { readThis ( Tokens . CLOSEBRACKET ) ; leaf . setLeftNode ( current ) ; break ; } Expression condition = new ExpressionLogical ( OpTypes . IS_NULL , current ) ; Expression alternatives = new ExpressionOp ( OpTypes . ALTERNATIVE , new ExpressionValue ( ( Object ) null , ( Type ) null ) , current ) ; Expression casewhen = new ExpressionOp ( OpTypes . CASEWHEN , condition , alternatives ) ; if ( c == null ) { c = casewhen ; } else { leaf . setLeftNode ( casewhen ) ; } leaf = alternatives ; readThis ( Tokens . COMMA ) ; } return c ; }
Reads a COALESE or IFNULL expression