Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.

Commit fc6f246

Browse files
committed
Add bit more support to hopefully/eventually solve issue #15
1 parent 1fb4e27 commit fc6f246

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

src/main/java/com/fasterxml/jackson/dataformat/csv/CsvFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public String getFormatName() {
100100
@Override
101101
public MatchStrength hasFormat(InputAccessor acc) throws IOException
102102
{
103-
// !!! TBI -- but how?
103+
// !!! TBI [Issue#2] -- but how?
104104
return MatchStrength.INCONCLUSIVE;
105105
}
106106

src/main/java/com/fasterxml/jackson/dataformat/csv/CsvMapper.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,15 @@ protected CsvSchema _schemaFor(JavaType pojoType, LRUMap<JavaType,CsvSchema> sch
202202
CsvSchema.Builder builder = CsvSchema.builder();
203203
for (BeanPropertyDefinition prop : beanDesc.findProperties()) {
204204
// ignore setter-only properties:
205-
if (prop.couldSerialize()) {
206-
if (typed) {
207-
builder.addColumn(prop.getName(), _determineType(prop.getAccessor().getRawType()));
208-
} else {
209-
builder.addColumn(prop.getName());
210-
}
205+
if (!prop.couldSerialize()) {
206+
continue;
207+
}
208+
// TODO: [Issue#15]: need to handle unwrapped props?
209+
210+
if (typed) {
211+
builder.addColumn(prop.getName(), _determineType(prop.getAccessor().getRawType()));
212+
} else {
213+
builder.addColumn(prop.getName());
211214
}
212215
}
213216
CsvSchema result = builder.build();

src/test/java/com/fasterxml/jackson/dataformat/csv/TestUnwrappingWithCSV.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public void testSimpleUnwrappingRoundtrip() throws Exception
5151
.addColumn("x")
5252
.addColumn("y")
5353
.build();
54-
Unwrapping wrapper = mapper.reader(schema).withType(Unwrapping.class).readValue(
55-
CSV);
54+
Unwrapping wrapper = mapper.reader(schema).withType(Unwrapping.class).readValue(CSV);
5655
assertNotNull(wrapper);
5756
assertNotNull(wrapper.location);
5857
assertEquals(15, wrapper.location.x);
@@ -67,12 +66,19 @@ public void testSimpleUnwrappingRoundtrip() throws Exception
6766
* Another simple test, but this time auto-generating Schema from
6867
* POJO.
6968
*/
69+
/* NOTE: the problem here is that Unwrapped properties should be further
70+
* detected to find sub-properties -- but that information is not yet
71+
* available via BeanProperty/POJOPropertyBuilder. But it needs to be
72+
* made; and when this occurs, we can handle this case reasonably well.
73+
*/
7074
/*
7175
public void testSimpleWithAutoSchema() throws Exception
7276
{
7377
final String CSV = "Henry,1,2\n";
7478
CsvMapper mapper = mapperForCsv();
7579
CsvSchema schema = mapper.schemaFor(Unwrapping.class);
80+
System.err.println("SChema/auto -> "+schema);
81+
7682
Unwrapping wrapper = mapper.reader(schema).withType(Unwrapping.class).readValue(CSV);
7783
assertNotNull(wrapper);
7884
assertNotNull(wrapper.location);

0 commit comments

Comments
 (0)