use of org.teiid.translator.google.visitor.SpreadsheetUpdateVisitor in project teiid by teiid.
the class TestSQLtoSpreadsheetQuery method testUpdateConversion.
private void testUpdateConversion(String sql, String expectedCriteria) throws Exception {
Update update = (Update) getCommand(sql);
SpreadsheetUpdateVisitor spreadsheetVisitor = new SpreadsheetUpdateVisitor(people);
spreadsheetVisitor.visit(update);
assertEquals(expectedCriteria, spreadsheetVisitor.getCriteriaQuery());
}
use of org.teiid.translator.google.visitor.SpreadsheetUpdateVisitor in project teiid by teiid.
the class SpreadsheetUpdateExecution method executeUpdate.
private UpdateResult executeUpdate() throws TranslatorException {
SpreadsheetInfo info = connection.getSpreadsheetInfo();
SpreadsheetUpdateVisitor updateVisitor = new SpreadsheetUpdateVisitor(info);
updateVisitor.visit((Update) command);
checkHeaders(updateVisitor.getWorksheetTitle());
result = connection.updateRows(updateVisitor.getWorksheetTitle(), updateVisitor.getCriteriaQuery(), updateVisitor.getChanges());
return result;
}
use of org.teiid.translator.google.visitor.SpreadsheetUpdateVisitor in project teiid by teiid.
the class TestSQLtoSpreadsheetQuery method testUpdateVisitorNull.
@Test
public void testUpdateVisitorNull() throws Exception {
String sql = "UPDATE PeopleList set A = 'String,String', C = null where A='Str,Str'";
SpreadsheetUpdateVisitor visitor = new SpreadsheetUpdateVisitor(people);
visitor.visit((Update) getCommand(sql));
assertEquals(2, visitor.getChanges().size());
assertEquals("A", visitor.getChanges().get(0).getColumnID());
assertEquals("'String,String", visitor.getChanges().get(0).getValue());
assertEquals("C", visitor.getChanges().get(1).getColumnID());
assertEquals("", visitor.getChanges().get(1).getValue());
assertEquals("a = \"Str,Str\"", visitor.getCriteriaQuery());
}
use of org.teiid.translator.google.visitor.SpreadsheetUpdateVisitor in project teiid by teiid.
the class TestSQLtoSpreadsheetQuery method testUpdateVisitorNullString.
// should fail as the null string would be treated as empty
@Test(expected = SpreadsheetOperationException.class)
public void testUpdateVisitorNullString() throws Exception {
String sql = "UPDATE PeopleList set A = null where A='Str,Str'";
SpreadsheetUpdateVisitor visitor = new SpreadsheetUpdateVisitor(people);
visitor.visit((Update) getCommand(sql));
}
use of org.teiid.translator.google.visitor.SpreadsheetUpdateVisitor in project teiid by teiid.
the class TestSQLtoSpreadsheetQuery method testUpdateVisitor.
@Test
public void testUpdateVisitor() throws Exception {
String sql = "UPDATE PeopleList set A = 'String,String', C = 1.5";
SpreadsheetUpdateVisitor visitor = new SpreadsheetUpdateVisitor(people);
visitor.visit((Update) getCommand(sql));
assertEquals(2, visitor.getChanges().size());
assertEquals("A", visitor.getChanges().get(0).getColumnID());
assertEquals("'String,String", visitor.getChanges().get(0).getValue());
assertEquals("C", visitor.getChanges().get(1).getColumnID());
assertEquals("1.5", visitor.getChanges().get(1).getValue());
assertNull(visitor.getCriteriaQuery());
}
Aggregations