use of io.shardingjdbc.core.parsing.parser.expression.SQLTextExpression in project sharding-jdbc by shardingjdbc.
the class InsertSetClauseParser method parse.
/**
* Parse insert set.
*
* @param insertStatement insert statement
*/
public void parse(final InsertStatement insertStatement) {
if (!lexerEngine.skipIfEqual(getCustomizedInsertKeywords())) {
return;
}
do {
Column column = new Column(SQLUtil.getExactlyValue(lexerEngine.getCurrentToken().getLiterals()), insertStatement.getTables().getSingleTableName());
lexerEngine.nextToken();
lexerEngine.accept(Symbol.EQ);
SQLExpression sqlExpression;
if (lexerEngine.equalAny(Literals.INT)) {
sqlExpression = new SQLNumberExpression(Integer.parseInt(lexerEngine.getCurrentToken().getLiterals()));
} else if (lexerEngine.equalAny(Literals.FLOAT)) {
sqlExpression = new SQLNumberExpression(Double.parseDouble(lexerEngine.getCurrentToken().getLiterals()));
} else if (lexerEngine.equalAny(Literals.CHARS)) {
sqlExpression = new SQLTextExpression(lexerEngine.getCurrentToken().getLiterals());
} else if (lexerEngine.equalAny(DefaultKeyword.NULL)) {
sqlExpression = new SQLIgnoreExpression(DefaultKeyword.NULL.name());
} else if (lexerEngine.equalAny(Symbol.QUESTION)) {
sqlExpression = new SQLPlaceholderExpression(insertStatement.getParametersIndex());
insertStatement.increaseParametersIndex();
} else {
throw new UnsupportedOperationException("");
}
lexerEngine.nextToken();
if (lexerEngine.equalAny(Symbol.COMMA, DefaultKeyword.ON, Assist.END)) {
insertStatement.getConditions().add(new Condition(column, sqlExpression), shardingRule);
} else {
lexerEngine.skipUntil(Symbol.COMMA, DefaultKeyword.ON);
}
} while (lexerEngine.skipIfEqual(Symbol.COMMA));
}
Aggregations