|
22 | 22 | import java.util.stream.Collectors;
|
23 | 23 |
|
24 | 24 | import org.junit.Test;
|
| 25 | + |
25 | 26 | import org.springframework.data.r2dbc.convert.MappingR2dbcConverter;
|
26 | 27 | import org.springframework.data.r2dbc.convert.R2dbcConverter;
|
27 | 28 | import org.springframework.data.r2dbc.dialect.BindMarkersFactory;
|
28 | 29 | import org.springframework.data.r2dbc.dialect.BindTarget;
|
29 | 30 | import org.springframework.data.r2dbc.mapping.SettableValue;
|
30 |
| -import org.springframework.data.r2dbc.query.BoundAssignments; |
31 |
| -import org.springframework.data.r2dbc.query.Update; |
32 |
| -import org.springframework.data.r2dbc.query.UpdateMapper; |
33 | 31 | import org.springframework.data.relational.core.mapping.Column;
|
34 | 32 | import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
35 | 33 | import org.springframework.data.relational.core.sql.AssignValue;
|
@@ -91,6 +89,21 @@ public void shouldUpdateToNull() {
|
91 | 89 | verifyZeroInteractions(bindTarget);
|
92 | 90 | }
|
93 | 91 |
|
| 92 | + @Test // gh-195 |
| 93 | + public void shouldMapMultipleFields() { |
| 94 | + |
| 95 | + Update update = Update.update("c1", "a").set("c2", "b").set("c3", "c"); |
| 96 | + |
| 97 | + BoundAssignments mapped = map(update); |
| 98 | + |
| 99 | + Map<String, Expression> assignments = mapped.getAssignments().stream().map(it -> (AssignValue) it) |
| 100 | + .collect(Collectors.toMap(k -> k.getColumn().getName(), AssignValue::getValue)); |
| 101 | + |
| 102 | + assertThat(update.getAssignments()).hasSize(3); |
| 103 | + assertThat(assignments).hasSize(3).containsEntry("c1", SQL.bindMarker("$1")).containsEntry("c2", |
| 104 | + SQL.bindMarker("$2")); |
| 105 | + } |
| 106 | + |
94 | 107 | private BoundAssignments map(Update update) {
|
95 | 108 |
|
96 | 109 | BindMarkersFactory markers = BindMarkersFactory.indexed("$", 1);
|
|
0 commit comments