[#4161] { INSERT | UPDATE | MERGE } .. SET [ Record ] doesn't take changed flags into account

This commit is contained in:
Lukas Eder 2015-04-01 15:08:50 +02:00
parent ae9233c758
commit 4c5fe868a2
8 changed files with 18 additions and 12 deletions

View File

@ -285,7 +285,9 @@ public interface InsertSetStep<R extends Record> {
* Set values in the <code>INSERT</code> statement.
* <p>
* This is the same as calling {@link #set(Map)} with the argument record
* treated as a <code>Map&lt;Field&lt;?>, Object></code>.
* treated as a <code>Map&lt;Field&lt;?>, Object></code>, except that the
* {@link Record#changed()} flags are taken into consideration in order to
* update only changed values.
*
* @see #set(Map)
*/

View File

@ -107,7 +107,9 @@ public interface MergeMatchedSetStep<R extends Record> {
* statement's <code>WHEN MATCHED</code> clause.
* <p>
* This is the same as calling {@link #set(Map)} with the argument record
* treated as a <code>Map&lt;Field&lt;?>, Object></code>.
* treated as a <code>Map&lt;Field&lt;?>, Object></code>, except that the
* {@link Record#changed()} flags are taken into consideration in order to
* update only changed values.
*
* @see #set(Map)
*/

View File

@ -91,7 +91,9 @@ public interface UpdateSetStep<R extends Record> {
* Set a value for a field in the <code>UPDATE</code> statement.
* <p>
* This is the same as calling {@link #set(Map)} with the argument record
* treated as a <code>Map&lt;Field&lt;?>, Object></code>.
* treated as a <code>Map&lt;Field&lt;?>, Object></code>, except that the
* {@link Record#changed()} flags are taken into consideration in order to
* update only changed values.
*
* @see #set(Map)
*/

View File

@ -483,8 +483,8 @@ abstract class AbstractQuery extends AbstractQueryPart implements Query, Attacha
x
x
xx xxxxxxxxxxxxxxxxxxxxxx x xxxxxxxxx x
xxxxx xxx xxxxxxxxxxxxxxxxxxxxx xxxx xxxxxxxx x xxxxxx xxxxxxx xxxx xxx xxxx xxxxx xxxxxxxx xxxxxx xxxxxxxx xxxxxxxxx xx x xxxxxxxxxx xxxxxxx xx xxxxxxx xxxxxxxxxxxxxxxxxxxxxx xx xxx xxxx xx xxx xxxx xxxxxxx xxxx xxxx xxxx xxxxxxxxx
xx xxxxxxxxxxxxxxxxxxxxxx x xxxxxxxx x
xxxxx xxx xxxxxxxxxxxxxxxxxxxxx xxxx xxxxxxxx x xxxxxxx xxxxxxx xxxx xxx xxxx xxxxx xxxxxxxx xxxxxx xxxxxxxx xxxxxxxxx xx x xxxxxxxxxx xxxxxxx xx xxxxxxx xxxxxxxxxxxxxxxxxxxxxx xx xxx xxxx xx xxx xxxx xxxxxxx xxxx xxxx xxxx xxxxxxxxx
x
xx xxxx x xxxxxxxxxxxxxxxxxxxxxxxxxxx x

View File

@ -630,7 +630,7 @@ class InsertImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
@Override
public final InsertImpl set(Record record) {
return set(Utils.map(record));
return set(Utils.mapOfChangedValues(record));
}
@Override

View File

@ -743,7 +743,7 @@ implements
@Override
public final MergeImpl set(Record record) {
return set(Utils.map(record));
return set(Utils.mapOfChangedValues(record));
}
@Override

View File

@ -161,7 +161,7 @@ final class UpdateImpl<R extends Record>
@Override
public final UpdateImpl<R> set(Record record) {
return set(Utils.map(record));
return set(Utils.mapOfChangedValues(record));
}
// [jooq-tools] START [set]

View File

@ -1103,13 +1103,13 @@ final class Utils {
/**
* Turn a {@link Record} into a {@link Map}
*/
static final Map<Field<?>, Object> map(Record record) {
static final Map<Field<?>, Object> mapOfChangedValues(Record record) {
Map<Field<?>, Object> result = new LinkedHashMap<Field<?>, Object>();
int size = record.size();
for (int i = 0; i < size; i++) {
result.put(record.field(i), record.getValue(i));
}
for (int i = 0; i < size; i++)
if (record.changed(i))
result.put(record.field(i), record.getValue(i));
return result;
}