[#945] Calling UpdatableRecord.setValue() twice with the same argument causes the changed flag to be reset to false
[#948] Always set the changed flag to true in Record.setValue()
This commit is contained in:
parent
d5ba94ae38
commit
678ab08ef2
@ -4246,6 +4246,21 @@ public abstract class jOOQAbstractTest<
|
||||
.where(TAuthor_FIRST_NAME().equal("Arthur"))
|
||||
.and(TAuthor_LAST_NAME().equal("Cohen"))
|
||||
.fetchOne(0));
|
||||
|
||||
// [#945] Set the same value twice
|
||||
author = create().selectFrom(TAuthor())
|
||||
.where(TAuthor_FIRST_NAME().equal("Arthur"))
|
||||
.fetchOne();
|
||||
|
||||
author.setValue(TAuthor_FIRST_NAME(), "Leonard");
|
||||
author.setValue(TAuthor_FIRST_NAME(), "Leonard");
|
||||
assertEquals(1, author.store());
|
||||
assertEquals(1, create()
|
||||
.select(count())
|
||||
.from(TAuthor())
|
||||
.where(TAuthor_FIRST_NAME().equal("Leonard"))
|
||||
.and(TAuthor_LAST_NAME().equal("Cohen"))
|
||||
.fetchOne(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@ -50,31 +50,30 @@ class Value<T> implements Serializable {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public T getValue() {
|
||||
T getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public T getValue(T defaultValue) {
|
||||
T getValue(T defaultValue) {
|
||||
return value != null ? value : defaultValue;
|
||||
}
|
||||
|
||||
public void setValue(T value) {
|
||||
if (this.value == null) {
|
||||
setChanged(value != null);
|
||||
}
|
||||
void setValue(T value) {
|
||||
|
||||
else {
|
||||
setChanged(!this.value.equals(value));
|
||||
}
|
||||
// The flag is always set to true:
|
||||
// [#945] To avoid this bug
|
||||
// [#948] To allow for controlling the number of hard-parses
|
||||
// To allow for explicitly overriding default values
|
||||
|
||||
this.isChanged = true;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean isChanged() {
|
||||
boolean isChanged() {
|
||||
return isChanged;
|
||||
}
|
||||
|
||||
public void setChanged(boolean isChanged) {
|
||||
void setChanged(boolean isChanged) {
|
||||
this.isChanged = isChanged;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user