use of net.sf.jsqlparser.statement.replace.Replace in project JSqlParser by JSQLParser.
the class ReplaceTest method testReplaceSyntax2.
@Test
public void testReplaceSyntax2() throws JSQLParserException {
String statement = "REPLACE mytable (col1, col2, col3) VALUES ('as', ?, 565)";
Replace replace = (Replace) PARSER_MANAGER.parse(new StringReader(statement));
assertEquals("mytable", replace.getTable().getName());
assertEquals(3, replace.getColumns().size());
assertEquals("col1", ((Column) replace.getColumns().get(0)).getColumnName());
assertEquals("col2", ((Column) replace.getColumns().get(1)).getColumnName());
assertEquals("col3", ((Column) replace.getColumns().get(2)).getColumnName());
assertEquals("as", ((StringValue) ((ExpressionList) replace.getItemsList()).getExpressions().get(0)).getValue());
assertTrue(((ExpressionList) replace.getItemsList()).getExpressions().get(1) instanceof JdbcParameter);
assertEquals(565, ((LongValue) ((ExpressionList) replace.getItemsList()).getExpressions().get(2)).getValue());
assertEquals(statement, "" + replace);
}
Aggregations