[#1995] Record.original() values aren't updated after a Record.store()
operation
This commit is contained in:
parent
7a05f5711c
commit
e4ed930fd7
@ -39,6 +39,7 @@ import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
import static org.jooq.impl.Factory.count;
|
||||
@ -375,9 +376,18 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T725,
|
||||
assertEquals(0, book1.store());
|
||||
|
||||
// Modify and store the original record
|
||||
// [#1995] Check for correct changed() and original() values, too
|
||||
Integer id = book1.getValue(TBook_ID());
|
||||
book1.setValue(TBook_TITLE(), "1985");
|
||||
assertEquals("1984", book1.original().getValue(TBook_TITLE()));
|
||||
assertEquals("1984", book1.original(TBook_TITLE()));
|
||||
assertTrue(book1.changed());
|
||||
assertTrue(book1.changed(TBook_TITLE()));
|
||||
assertEquals(1, book1.store());
|
||||
assertEquals("1985", book1.original().getValue(TBook_TITLE()));
|
||||
assertEquals("1985", book1.original(TBook_TITLE()));
|
||||
assertFalse(book1.changed());
|
||||
assertFalse(book1.changed(TBook_TITLE()));
|
||||
|
||||
// Fetch the modified record
|
||||
book1 = create().fetchOne(TBook(), TBook_ID().equal(id));
|
||||
|
||||
@ -46,7 +46,7 @@ class Value<T> implements Serializable {
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -9065797545428164533L;
|
||||
private final T original;
|
||||
private T original;
|
||||
private T value;
|
||||
private boolean isChanged;
|
||||
|
||||
@ -106,6 +106,12 @@ class Value<T> implements Serializable {
|
||||
|
||||
final void setChanged(boolean isChanged) {
|
||||
this.isChanged = isChanged;
|
||||
|
||||
// [#1995] If a value is meant to be "unchanged", the "original" should
|
||||
// match the supposedly "unchanged" value.
|
||||
if (!isChanged) {
|
||||
original = value;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user