use of net.sf.jsqlparser.expression.Expression in project JSqlParser by JSQLParser.
the class StatementDeParserTest method shouldUseProvidedDeParserWhenDeParsingSetStatement.
@Test
@SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
public void shouldUseProvidedDeParserWhenDeParsingSetStatement() {
String name = "name";
Expression expression = mock(Expression.class);
SetStatement setStatement = new SetStatement(name, expression);
statementDeParser.visit(setStatement);
then(expression).should().accept(expressionDeParser);
}
use of net.sf.jsqlparser.expression.Expression in project JSqlParser by JSQLParser.
the class StatementDeParserTest method shouldUseProvidedDeParserWhenDeParsingExecute.
@Test
@SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
public void shouldUseProvidedDeParserWhenDeParsingExecute() {
Execute execute = new Execute();
ExpressionList exprList = new ExpressionList();
List<Expression> expressions = new ArrayList<Expression>();
Expression expression1 = mock(Expression.class);
Expression expression2 = mock(Expression.class);
execute.setExprList(exprList);
exprList.setExpressions(expressions);
expressions.add(expression1);
expressions.add(expression2);
statementDeParser.visit(execute);
then(expression1).should().accept(expressionDeParser);
then(expression2).should().accept(expressionDeParser);
}
use of net.sf.jsqlparser.expression.Expression in project JSqlParser by JSQLParser.
the class StatementDeParserTest method shouldUseProvidedDeparsersWhenDeParsingUpsertWithExpressionList.
@Test
@SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert")
public void shouldUseProvidedDeparsersWhenDeParsingUpsertWithExpressionList() throws JSQLParserException {
Upsert upsert = new Upsert();
Table table = new Table();
List<Column> duplicateUpdateColumns = new ArrayList<Column>();
List<Expression> duplicateUpdateExpressionList = new ArrayList<Expression>();
Column duplicateUpdateColumn1 = new Column();
Column duplicateUpdateColumn2 = new Column();
Expression duplicateUpdateExpression1 = mock(Expression.class);
Expression duplicateUpdateExpression2 = mock(Expression.class);
Select select = new Select();
List<WithItem> withItemsList = new ArrayList<WithItem>();
WithItem withItem1 = spy(new WithItem());
WithItem withItem2 = spy(new WithItem());
SelectBody withItem1SelectBody = mock(SelectBody.class);
SelectBody withItem2SelectBody = mock(SelectBody.class);
SelectBody selectBody = mock(SelectBody.class);
upsert.setSelect(select);
upsert.setTable(table);
upsert.setUseDuplicate(true);
upsert.setDuplicateUpdateColumns(duplicateUpdateColumns);
upsert.setDuplicateUpdateExpressionList(duplicateUpdateExpressionList);
duplicateUpdateColumns.add(duplicateUpdateColumn1);
duplicateUpdateColumns.add(duplicateUpdateColumn2);
duplicateUpdateExpressionList.add(duplicateUpdateExpression1);
duplicateUpdateExpressionList.add(duplicateUpdateExpression2);
upsert.setDuplicateUpdateExpressionList(duplicateUpdateExpressionList);
select.setWithItemsList(withItemsList);
select.setSelectBody(selectBody);
withItemsList.add(withItem1);
withItemsList.add(withItem2);
withItem1.setSelectBody(withItem1SelectBody);
withItem2.setSelectBody(withItem2SelectBody);
statementDeParser.visit(upsert);
then(withItem1).should().accept(selectDeParser);
then(withItem2).should().accept(selectDeParser);
then(selectBody).should().accept(selectDeParser);
then(duplicateUpdateExpression1).should().accept(expressionDeParser);
then(duplicateUpdateExpression1).should().accept(expressionDeParser);
}
use of net.sf.jsqlparser.expression.Expression in project JSqlParser by JSQLParser.
the class ExpressionDeParser method visit.
@Override
public void visit(CaseExpression caseExpression) {
buffer.append("CASE ");
Expression switchExp = caseExpression.getSwitchExpression();
if (switchExp != null) {
switchExp.accept(this);
buffer.append(" ");
}
for (Expression exp : caseExpression.getWhenClauses()) {
exp.accept(this);
}
Expression elseExp = caseExpression.getElseExpression();
if (elseExp != null) {
buffer.append("ELSE ");
elseExp.accept(this);
buffer.append(" ");
}
buffer.append("END");
}
use of net.sf.jsqlparser.expression.Expression in project JSqlParser by JSQLParser.
the class ExpressionDeParser method visit.
@Override
public void visit(RowConstructor rowConstructor) {
if (rowConstructor.getName() != null) {
buffer.append(rowConstructor.getName());
}
buffer.append("(");
boolean first = true;
for (Expression expr : rowConstructor.getExprList().getExpressions()) {
if (first) {
first = false;
} else {
buffer.append(", ");
}
expr.accept(this);
}
buffer.append(")");
}
Aggregations