Field object = fieldByName("ANY");
// Check if a correct type was coerced correctly
// ---------------------------------------------
{
Condition int_int = integer.eq(1);
assertEquals("`TABLE1`.`ID1` = 1", r_refI().render(int_int));
context.checking(new Expectations() {{
oneOf(statement).setInt(1, 1);
}});
assertEquals(2, b_ref().visit(int_int).peekIndex());
context.assertIsSatisfied();
}
{
Condition string_string = string.eq("1");
assertEquals("`TABLE1`.`NAME1` = '1'", r_refI().render(string_string));
context.checking(new Expectations() {{
oneOf(statement).setString(1, "1");
}});
assertEquals(2, b_ref().visit(string_string).peekIndex());
context.assertIsSatisfied();
}
// Check if a convertible type was coerced correctly
// -------------------------------------------------
{
Condition int_string = integer.eq("1");
assertEquals("`TABLE1`.`ID1` = 1", r_refI().render(int_string));
context.checking(new Expectations() {{
oneOf(statement).setInt(1, 1);
}});
assertEquals(2, b_ref().visit(int_string).peekIndex());
context.assertIsSatisfied();
Condition string_int = string.eq(1);
assertEquals("`TABLE1`.`NAME1` = '1'", r_refI().render(string_int));
context.checking(new Expectations() {{
oneOf(statement).setString(1, "1");
}});
assertEquals(2, b_ref().visit(string_int).peekIndex());
context.assertIsSatisfied();
}
// Check if ...
// ------------
{
Condition object_int = object.eq(1);
assertEquals("`ANY` = 1", r_refI().render(object_int));
context.checking(new Expectations() {{
oneOf(statement).setInt(1, 1);
}});
assertEquals(2, b_ref().visit(object_int).peekIndex());
context.assertIsSatisfied();
}
{
Condition object_string = object.eq("1");
assertEquals("`ANY` = '1'", r_refI().render(object_string));
context.checking(new Expectations() {{
oneOf(statement).setString(1, "1");
}});
assertEquals(2, b_ref().visit(object_string).peekIndex());
context.assertIsSatisfied();
}
{
Condition object_date = object.eq(Timestamp.valueOf("2012-12-21 15:30:00.0"));
assertEquals("`ANY` = {ts '2012-12-21 15:30:00.0'}", r_refI().render(object_date));
context.checking(new Expectations() {{
oneOf(statement).setTimestamp(1, Timestamp.valueOf("2012-12-21 15:30:00.0"));
}});