[#1989] Add Record.changed(Field<?>), changed(int), changed(String) to
check whether a single field's value has changed
This commit is contained in:
parent
66e4716794
commit
c6e3b61aca
@ -106,7 +106,11 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T725,
|
||||
B book = create().selectFrom(TBook()).where(TBook_ID().eq(1)).fetchOne();
|
||||
|
||||
assertFalse(book.changed());
|
||||
assertFalse(book.changed(TBook_TITLE()));
|
||||
assertFalse(book.changed(TBook_TITLE().getName()));
|
||||
book.setValue(TBook_TITLE(), "abc");
|
||||
assertTrue(book.changed());
|
||||
assertTrue(book.changed(TBook_TITLE()));
|
||||
assertTrue(book.changed(TBook_TITLE().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -379,6 +379,24 @@ public interface Record extends FieldProvider, Attachable {
|
||||
*/
|
||||
boolean changed();
|
||||
|
||||
/**
|
||||
* Check if a field's value has been changed from its original as fetched
|
||||
* from the database.
|
||||
*/
|
||||
boolean changed(Field<?> field);
|
||||
|
||||
/**
|
||||
* Check if a field's value has been changed from its original as fetched
|
||||
* from the database.
|
||||
*/
|
||||
boolean changed(int fieldIndex);
|
||||
|
||||
/**
|
||||
* Check if a field's value has been changed from its original as fetched
|
||||
* from the database.
|
||||
*/
|
||||
boolean changed(String fieldName);
|
||||
|
||||
/**
|
||||
* Convert this record into an array.
|
||||
* <p>
|
||||
|
||||
@ -369,6 +369,21 @@ abstract class AbstractRecord extends AbstractStore implements Record {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean changed(Field<?> field) {
|
||||
return changed(getIndex(field));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean changed(int fieldIndex) {
|
||||
return getValue0(fieldIndex).isChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean changed(String fieldName) {
|
||||
return changed(getIndex(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Object[] intoArray() {
|
||||
return into(Object[].class);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user