Skip to content

Commit

Permalink
Merge 7d4414c into 07041c5
Browse files Browse the repository at this point in the history
  • Loading branch information
jonesaaronj committed Apr 28, 2021
2 parents 07041c5 + 7d4414c commit 5eb03d0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/main/java/io/frictionlessdata/tableschema/field/Field.java
Expand Up @@ -147,7 +147,17 @@ public abstract class Field<T> {

Map<String, Object> constraints = null;

Map<String, Object> options = null;
Map<String, Object> options = new HashMap<>();

@JsonAnyGetter
public Map<String, Object> otherFields() {
return options;
}

@JsonAnySetter
public void setOtherField(String key, Object value) {
options.put(key, value);
}

/**
* Constructor for our reflection-based instantiation only
Expand Down
Expand Up @@ -103,6 +103,14 @@ public void testReadSchemaFieldNames() throws Exception {
Assert.assertArrayEquals(testArr, namesArr);
}

@Test
public void testCreateSchemaWithNumberOptions() throws Exception {
File source = getResourceFile("/fixtures/schema/number_types_schema.json");
Schema schema = Schema.fromJson(source, true);

assertEquals( ",", schema.getField("numberWithComma").getOptions().get("groupChar"));
assertEquals( ".", schema.getField("numberWithComma").getOptions().get("decimalChar"));
}

@Test
public void testCreateFromListOfFields() throws Exception {
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/fixtures/data/number_types.csv
@@ -1,2 +1,2 @@
id, byteVal, shortVal, intVal, longClassVal, longVal, floatVal, doubleVal,floatClassVal,doubleClassVal, bigIntVal, bigDecimalVal, atomicIntegerVal, atomicLongVal, atomicDoubleVal
23143245,126,234,234534,908347392304952,893479850249,3245.1234,345234552345.2345,2.34566246E9,3.4567347437347346E+23,23459734123456676123981234,3542352304245234542345345423453.02345234,2345123,234597341234502345,3453254.34
id, byteVal, shortVal, intVal, longClassVal, longVal, floatVal, doubleVal,floatClassVal,doubleClassVal, bigIntVal, bigDecimalVal, atomicIntegerVal, atomicLongVal, atomicDoubleVal, numberWithComma
23143245,126,234,234534,908347392304952,893479850249,3245.1234,345234552345.2345,2.34566246E9,3.4567347437347346E+23,23459734123456676123981234,3542352304245234542345345423453.02345234,2345123,234597341234502345,3453254.34,"1,000.00"
7 changes: 7 additions & 0 deletions src/test/resources/fixtures/schema/number_types_schema.json
Expand Up @@ -73,5 +73,12 @@
"name": "atomicDoubleVal",
"format": "default",
"type": "number"
},
{
"name": "numberWithComma",
"format": "default",
"type": "number",
"decimalChar": ".",
"groupChar": ","
}
]}

0 comments on commit 5eb03d0

Please sign in to comment.