String sql0 = "SELECT x.id FROM Person x"
+ " WHERE x.category IN (?, ?)";
CommandBuilder cb = new CommandBuilder(sess, sql0, args("A", "B"));
RootPanel.get().add(cb);
Select s = cb.getSelect();
cb.fireDirty();
{
Comparison comp = (Comparison) s.getCondition();
Parameter right = (Parameter) comp.getRight();
Element selectElmt = right.getElement();
String html = "<select class='gwt-ListBox' multiple='multiple' size='2'>"
+ "<option value='A'>A</option>"
+ "<option value='B'>B</option>"
+ "<option value='C'>C</option>" + "</select>";
assertEquals(html, selectElmt);
assertEquals("SELECT X.ID\nFROM PERSON X\nWHERE (X.CATEGORY IN (?, ?))", s.getSQL(args()));
// change to sex
ExpressionColumn left2 = (ExpressionColumn) comp.getLeft();
left2.updateColumn("X", sess.getDatabase().getMainSchema()
.findTableOrView("PERSON").getColumn("category2"));
cb.fireDirty();
}
{
Comparison comp = (Comparison) s.getCondition();
Parameter right = (Parameter) comp.getRight();
Element selectElmt = right.getElement();
String html = "<select class='gwt-ListBox' multiple='multiple' size='2'>"
+ "<option value='X'>X</option>"
+ "<option value='Y'>Y</option>"
+ "<option value='Z'>Z</option>" + "</select>";
assertEquals(html, selectElmt);
assertEquals("SELECT X.ID\nFROM PERSON X\nWHERE (X.category2 IN ?)", s.getSQL(args()));
// change to sex
ExpressionColumn left2 = (ExpressionColumn) comp.getLeft();
left2.updateColumn("X", sess.getDatabase().getMainSchema()
.findTableOrView("PERSON").getColumn("sex"));
cb.fireDirty();
}
{
Comparison comp = (Comparison) s.getCondition();
Parameter right = (Parameter) comp.getRight();
Element selectElmt = right.getElement();
String html = "<select class='gwt-ListBox'>"
+ "<option value='Please select...'>Please select...</option>"
+ "<option value='M'>M</option>"
+ "<option value='F'>F</option>"
+ "</select>";
assertEquals(html, selectElmt);
assertEquals("SELECT X.ID\nFROM PERSON X\nWHERE (X.sex = ?)", s.getSQL(args()));
}
// check options in ListBox please, male, female
}