Beispiel #1
0
 @Test
 public void testQuerySelectTrim() {
   // TODO fix use ltrim/rtrim for SQLServer
   Person person = randomPerson();
   person.setName("  Name  ");
   data.insert(person);
   Tuple result = data.select(Person.NAME.trim().as("name")).get().first();
   String name = result.get(0);
   assertEquals(name, "Name");
 }
Beispiel #2
0
 @Test
 public void testQueryCoalesce() {
   Person person = randomPerson();
   person.setName("Carol");
   person.setEmail(null);
   data.insert(person);
   person = randomPerson();
   person.setName("Bob");
   person.setEmail("*****@*****.**");
   person.setHomepage(null);
   data.insert(person);
   Result<Tuple> result = data.select(Coalesce.coalesce(Person.EMAIL, Person.NAME)).get();
   List<Tuple> list = result.toList();
   List<String> values = new ArrayList<>();
   for (Tuple tuple : list) {
     values.add(tuple.get(0).toString());
   }
   assertEquals(values.size(), 2);
   assertTrue(values.contains("Carol"));
   assertTrue(values.contains("*****@*****.**"));
 }