Use SqlIdentifier.getReference() when calling Row.get(…).
We now use the referencename instead of toString() when obtaining values from Row. Closes #530.
This commit is contained in:
@@ -164,7 +164,7 @@ public class MappingR2dbcConverter extends BasicRelationalConverter implements R
|
||||
return readEntityFrom(row, metadata, property);
|
||||
}
|
||||
|
||||
String identifier = prefix + property.getColumnName();
|
||||
String identifier = prefix + property.getColumnName().getReference();
|
||||
if (metadata != null && !metadata.getColumnNames().contains(identifier)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,9 @@ import io.r2dbc.spi.test.MockColumnMetadata;
|
||||
import io.r2dbc.spi.test.MockRow;
|
||||
import io.r2dbc.spi.test.MockRowMetadata;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -182,9 +184,24 @@ public class MappingR2dbcConverterUnitTests {
|
||||
.containsEntry(SqlIdentifier.unquoted("entity"), Parameter.from("nested_entity"));
|
||||
}
|
||||
|
||||
@Test // gh-59
|
||||
@Test // gh-530
|
||||
public void shouldReadTopLevelEntity() {
|
||||
|
||||
mappingContext.setForceQuote(true);
|
||||
|
||||
Row rowMock = mock(Row.class);
|
||||
when(rowMock.get("firstname")).thenReturn("Walter");
|
||||
when(rowMock.get("lastname")).thenReturn("White");
|
||||
|
||||
ConstructorAndPropertyPopulation result = converter.read(ConstructorAndPropertyPopulation.class, rowMock);
|
||||
|
||||
assertThat(result.firstname).isEqualTo("Walter");
|
||||
assertThat(result.lastname).isEqualTo("White");
|
||||
}
|
||||
|
||||
@Test // gh-59
|
||||
public void shouldReadTopLevelEntityWithConverter() {
|
||||
|
||||
Row rowMock = mock(Row.class);
|
||||
when(rowMock.get("foo_column", String.class)).thenReturn("bar");
|
||||
when(rowMock.get("nested_entity")).thenReturn("map");
|
||||
@@ -236,6 +253,14 @@ public class MappingR2dbcConverterUnitTests {
|
||||
LocalDateTime localDateTime;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@RequiredArgsConstructor
|
||||
static class ConstructorAndPropertyPopulation {
|
||||
final String firstname;
|
||||
String lastname;
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
static class WithEnum {
|
||||
@Id String id;
|
||||
|
||||
Reference in New Issue
Block a user