DATAJDBC-262 - Update statements no longer set the id column.
This commit is contained in:
committed by
Greg Turnquist
parent
0816f4182e
commit
3d67ad08ed
@@ -284,8 +284,9 @@ class SqlGenerator {
|
||||
|
||||
String updateTemplate = "UPDATE %s SET %s WHERE %s = :%s";
|
||||
|
||||
String setClause = columnNames.stream()//
|
||||
.map(n -> String.format("%s = :%s", n, n))//
|
||||
String setClause = columnNames.stream() //
|
||||
.filter(s -> !s.equals(entity.getIdColumn())) //
|
||||
.map(n -> String.format("%s = :%s", n, n)) //
|
||||
.collect(Collectors.joining(", "));
|
||||
|
||||
return String.format(updateTemplate, entity.getTableName(), setClause, entity.getIdColumn(), entity.getIdColumn());
|
||||
|
||||
@@ -199,6 +199,17 @@ public class SqlGeneratorUnitTests {
|
||||
"FROM");
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-262
|
||||
public void update() {
|
||||
|
||||
assertThat(sqlGenerator.getUpdate()).containsSequence( //
|
||||
"UPDATE", //
|
||||
"dummy_entity", //
|
||||
"SET", //
|
||||
"WHERE", //
|
||||
"x_id = :x_id");
|
||||
}
|
||||
|
||||
private PersistentPropertyPath<RelationalPersistentProperty> getPath(String path, Class<?> base) {
|
||||
return PersistentPropertyPathTestUtils.getPath(context, path, base);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user