Program: 150507
Project: 150507
Buggy source:
@SuppressWarnings("String_Node_Str") @Test public void testInsertReturning() throws Exception {
  if (TTriggers() == null) {
    log.info("String_Node_Str","String_Node_Str");
    return;
  }
  jOOQAbstractTest.reset=false;
  InsertQuery<T> query;
  int ID=0;
  query=create().insertQuery(TTriggers());
  query.addValue(TTriggers_ID(),null);
  query.addValue(TTriggers_COUNTER(),0);
  assertEquals(1,query.execute());
  assertNull(query.getReturnedRecord());
  assertEquals(1,create().selectFrom(TTriggers()).fetch().size());
  assertEquals(++ID,(int)create().selectFrom(TTriggers()).fetchOne(TTriggers_ID_GENERATED()));
  assertEquals(ID,(int)create().selectFrom(TTriggers()).fetchOne(TTriggers_ID()));
  assertEquals(2 * ID,(int)create().selectFrom(TTriggers()).fetchOne(TTriggers_COUNTER()));
  query=create().insertQuery(TTriggers());
  query.addValue(TTriggers_COUNTER(),null);
  query.addValue(TTriggers_COUNTER(),0);
  query.setReturning();
  assertEquals(1,query.execute());
  assertNotNull(query.getReturnedRecord());
  assertEquals(++ID,(int)query.getReturnedRecord().getValue(TTriggers_ID_GENERATED()));
  assertEquals(ID,(int)query.getReturnedRecord().getValue(TTriggers_ID()));
  assertEquals(2 * ID,(int)query.getReturnedRecord().getValue(TTriggers_COUNTER()));
  query=create().insertQuery(TTriggers());
  query.addValue(TTriggers_COUNTER(),0);
  query.setReturning(TTriggers_ID_GENERATED());
  assertEquals(1,query.execute());
  assertNotNull(query.getReturnedRecord());
  assertEquals(++ID,(int)query.getReturnedRecord().getValue(TTriggers_ID_GENERATED()));
  assertNull(query.getReturnedRecord().getValue(TTriggers_ID()));
  assertNull(query.getReturnedRecord().getValue(TTriggers_COUNTER()));
  query.getReturnedRecord().refresh();
  assertEquals(ID,(int)query.getReturnedRecord().getValue(TTriggers_ID_GENERATED()));
  assertEquals(ID,(int)query.getReturnedRecord().getValue(TTriggers_ID()));
  assertEquals(2 * ID,(int)query.getReturnedRecord().getValue(TTriggers_COUNTER()));
  TableRecord<T> returned=create().insertInto(TTriggers(),TTriggers_COUNTER()).values(0).returning().fetchOne();
  assertNotNull(returned);
  assertEquals(++ID,(int)returned.getValue(TTriggers_ID_GENERATED()));
  assertEquals(ID,(int)returned.getValue(TTriggers_ID()));
  assertEquals(2 * ID,(int)returned.getValue(TTriggers_COUNTER()));
  returned=create().insertInto(TTriggers()).set(TTriggers_COUNTER(),0).returning(TTriggers_ID_GENERATED()).fetchOne();
  assertNotNull(returned);
  assertEquals(++ID,(int)returned.getValue(TTriggers_ID_GENERATED()));
  assertNull(returned.getValue(TTriggers_ID()));
  assertNull(returned.getValue(TTriggers_COUNTER()));
switch (getDialect()) {
case ASE:
case DERBY:
case H2:
case INGRES:
case ORACLE:
case SQLITE:
case SQLSERVER:
case SYBASE:
    log.info("String_Node_Str","String_Node_Str");
  break;
default :
Result<?> many=create().insertInto(TTriggers(),TTriggers_COUNTER()).values(-1).values(-2).values(-3).returning().fetch();
assertNotNull(many);
assertEquals(3,many.size());
assertEquals(++ID,(int)many.getValue(0,TTriggers_ID_GENERATED()));
assertEquals(ID,(int)many.getValue(0,TTriggers_ID()));
assertEquals(2 * ID,(int)many.getValue(0,TTriggers_COUNTER()));
assertEquals(++ID,(int)many.getValue(1,TTriggers_ID_GENERATED()));
assertEquals(ID,(int)many.getValue(1,TTriggers_ID()));
assertEquals(2 * ID,(int)many.getValue(1,TTriggers_COUNTER()));
assertEquals(++ID,(int)many.getValue(2,TTriggers_ID_GENERATED()));
assertEquals(ID,(int)many.getValue(2,TTriggers_ID()));
assertEquals(2 * ID,(int)many.getValue(2,TTriggers_COUNTER()));
break;
}
returned=create().insertInto(TTriggers(),TTriggers_COUNTER()).values(0).returning(TTriggers_ID()).fetchOne();
assertNotNull(returned);
assertEquals(++ID,(int)returned.getValue(TTriggers_ID()));
assertNull(returned.getValue(TTriggers_ID_GENERATED()));
assertNull(returned.getValue(TTriggers_COUNTER()));
returned.refreshUsing(TTriggers_ID());
assertEquals(ID,(int)returned.getValue(TTriggers_ID_GENERATED()));
assertEquals(2 * ID,(int)returned.getValue(TTriggers_COUNTER()));
T triggered=create().newRecord(TTriggers());
triggered.setValue(TTriggers_COUNTER(),0);
assertEquals(1,triggered.store());
assertEquals(++ID,(int)triggered.getValue(TTriggers_ID_GENERATED()));
assertEquals(null,triggered.getValue(TTriggers_ID()));
assertEquals(0,(int)triggered.getValue(TTriggers_COUNTER()));
triggered.refresh();
assertEquals(ID,(int)triggered.getValue(TTriggers_ID()));
assertEquals(2 * ID,(int)triggered.getValue(TTriggers_COUNTER()));
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Test public void testInsertReturning() throws Exception {
  if (TTriggers() == null) {
    log.info("String_Node_Str","String_Node_Str");
    return;
  }
  jOOQAbstractTest.reset=false;
  InsertQuery<T> query;
  int ID=0;
  query=create().insertQuery(TTriggers());
  query.addValue(TTriggers_ID(),null);
  query.addValue(TTriggers_COUNTER(),0);
  assertEquals(1,query.execute());
  assertNull(query.getReturnedRecord());
  assertEquals(1,create().selectFrom(TTriggers()).fetch().size());
  assertEquals(++ID,(int)create().selectFrom(TTriggers()).fetchOne(TTriggers_ID_GENERATED()));
  assertEquals(ID,(int)create().selectFrom(TTriggers()).fetchOne(TTriggers_ID()));
  assertEquals(2 * ID,(int)create().selectFrom(TTriggers()).fetchOne(TTriggers_COUNTER()));
  query=create().insertQuery(TTriggers());
  query.addValue(TTriggers_COUNTER(),null);
  query.addValue(TTriggers_COUNTER(),0);
  query.setReturning();
  assertEquals(1,query.execute());
  assertNotNull(query.getReturnedRecord());
  assertEquals(++ID,(int)query.getReturnedRecord().getValue(TTriggers_ID_GENERATED()));
  assertEquals(ID,(int)query.getReturnedRecord().getValue(TTriggers_ID()));
  assertEquals(2 * ID,(int)query.getReturnedRecord().getValue(TTriggers_COUNTER()));
  query=create().insertQuery(TTriggers());
  query.addValue(TTriggers_COUNTER(),0);
  query.setReturning(TTriggers_ID_GENERATED());
  assertEquals(1,query.execute());
  assertNotNull(query.getReturnedRecord());
  assertEquals(++ID,(int)query.getReturnedRecord().getValue(TTriggers_ID_GENERATED()));
  assertNull(query.getReturnedRecord().getValue(TTriggers_ID()));
  assertNull(query.getReturnedRecord().getValue(TTriggers_COUNTER()));
  query.getReturnedRecord().refresh();
  assertEquals(ID,(int)query.getReturnedRecord().getValue(TTriggers_ID_GENERATED()));
  assertEquals(ID,(int)query.getReturnedRecord().getValue(TTriggers_ID()));
  assertEquals(2 * ID,(int)query.getReturnedRecord().getValue(TTriggers_COUNTER()));
  TableRecord<T> returned=create().insertInto(TTriggers(),TTriggers_COUNTER()).values(0).returning().fetchOne();
  assertNotNull(returned);
  assertEquals(++ID,(int)returned.getValue(TTriggers_ID_GENERATED()));
  assertEquals(ID,(int)returned.getValue(TTriggers_ID()));
  assertEquals(2 * ID,(int)returned.getValue(TTriggers_COUNTER()));
  returned=create().insertInto(TTriggers()).set(TTriggers_COUNTER(),0).returning(TTriggers_ID_GENERATED()).fetchOne();
  assertNotNull(returned);
  assertEquals(++ID,(int)returned.getValue(TTriggers_ID_GENERATED()));
  assertNull(returned.getValue(TTriggers_ID()));
  assertNull(returned.getValue(TTriggers_COUNTER()));
switch (getDialect()) {
case ASE:
case CUBRID:
case DERBY:
case H2:
case INGRES:
case ORACLE:
case SQLITE:
case SQLSERVER:
case SYBASE:
    log.info("String_Node_Str","String_Node_Str");
  break;
default :
Result<?> many=create().insertInto(TTriggers(),TTriggers_COUNTER()).values(-1).values(-2).values(-3).returning().fetch();
assertNotNull(many);
assertEquals(3,many.size());
assertEquals(++ID,(int)many.getValue(0,TTriggers_ID_GENERATED()));
assertEquals(ID,(int)many.getValue(0,TTriggers_ID()));
assertEquals(2 * ID,(int)many.getValue(0,TTriggers_COUNTER()));
assertEquals(++ID,(int)many.getValue(1,TTriggers_ID_GENERATED()));
assertEquals(ID,(int)many.getValue(1,TTriggers_ID()));
assertEquals(2 * ID,(int)many.getValue(1,TTriggers_COUNTER()));
assertEquals(++ID,(int)many.getValue(2,TTriggers_ID_GENERATED()));
assertEquals(ID,(int)many.getValue(2,TTriggers_ID()));
assertEquals(2 * ID,(int)many.getValue(2,TTriggers_COUNTER()));
break;
}
returned=create().insertInto(TTriggers(),TTriggers_COUNTER()).values(0).returning(TTriggers_ID()).fetchOne();
assertNotNull(returned);
assertEquals(++ID,(int)returned.getValue(TTriggers_ID()));
assertNull(returned.getValue(TTriggers_ID_GENERATED()));
assertNull(returned.getValue(TTriggers_COUNTER()));
returned.refreshUsing(TTriggers_ID());
assertEquals(ID,(int)returned.getValue(TTriggers_ID_GENERATED()));
assertEquals(2 * ID,(int)returned.getValue(TTriggers_COUNTER()));
T triggered=create().newRecord(TTriggers());
triggered.setValue(TTriggers_COUNTER(),0);
assertEquals(1,triggered.store());
assertEquals(++ID,(int)triggered.getValue(TTriggers_ID_GENERATED()));
assertEquals(null,triggered.getValue(TTriggers_ID()));
assertEquals(0,(int)triggered.getValue(TTriggers_COUNTER()));
triggered.refresh();
assertEquals(ID,(int)triggered.getValue(TTriggers_ID()));
assertEquals(2 * ID,(int)triggered.getValue(TTriggers_COUNTER()));
}