[
https://issues.apache.org/jira/browse/OLINGO-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15894088#comment-15894088
]
Svante von Erichsen commented on OLINGO-1087:
---------------------------------------------
It seems that there is still some discrepancy between the specification and the
Olingo implementation, regarding the scale default of 0.
The specification seems to say that if you omit all facets for Edm.Decimal,
then scale is 0. The Olingo library (v2) does not do that, instead it skips
the validation of precision and scale if neither is given. It also doesn't
validate scale if it is not given.
Example: given metadata <Property Name="FOO" Type="Edm.Decimal"/>, the value
1.2 should not be valid.
Introducing this in the library might break a lot of code now, however. This
is especially hurtful, because often (as in our case) it is the server that
sends incorrect metadata, but the client that breaks. Disabling the validation
of facets might not be a good option for everyone, because that would also
disable the validation of other facets for other types.
One might interpret the notion of precision and scale being "optional" facets
in the sense that if _no_ facet is given, none should be validated. This would
break less (although in our HANA case we get metadata <Property Name="FOO"
Type="Edm.Decimal" Precision="34"/> for values like
0.08102359900000000170194880411145277, which is wrong anyway).
> Precision in EdmDecimal not calculated correctly
> ------------------------------------------------
>
> Key: OLINGO-1087
> URL: https://issues.apache.org/jira/browse/OLINGO-1087
> Project: Olingo
> Issue Type: Bug
> Components: odata2-core
> Affects Versions: V2 2.0.8
> Reporter: Svante von Erichsen
> Attachments: 0001-OLINGO-1087-Fix-calculation-of-precision.patch
>
>
> The "precision" found in a read number is currently at least the number of
> decimals (omitting trailing zeroes). That seems to be wrong, or at least not
> consistent with at least some server side view of the matter, for numbers
> smaller than 0.1 (the number shown has 35 decimals, but precision 34):
> org.apache.olingo.odata2.api.edm.EdmSimpleTypeException: The metadata
> constraints '[Precision=34]' do not match the literal
> '0.08102359900000000170194880411145277'.
> at
> org.apache.olingo.odata2.core.edm.EdmDecimal.internalValueOfString(EdmDecimal.java:107)
> at
> org.apache.olingo.odata2.core.edm.AbstractSimpleType.valueOfString(AbstractSimpleType.java:91)
> at
> org.apache.olingo.odata2.core.ep.consumer.JsonPropertyConsumer.readSimpleProperty(JsonPropertyConsumer.java:236)
> at
> org.apache.olingo.odata2.core.ep.consumer.JsonPropertyConsumer.readPropertyValue(JsonPropertyConsumer.java:169)
> ... 69 common frames omitted
> Wrapped by: org.apache.olingo.odata2.api.ep.EntityProviderException: An
> exception of type 'EdmSimpleTypeException' occurred.
> at
> org.apache.olingo.odata2.core.ep.consumer.JsonPropertyConsumer.readPropertyValue(JsonPropertyConsumer.java:171)
> at
> org.apache.olingo.odata2.core.ep.consumer.JsonEntryConsumer.handleName(JsonEntryConsumer.java:172)
> at
> org.apache.olingo.odata2.core.ep.consumer.JsonEntryConsumer.readEntryContent(JsonEntryConsumer.java:130)
> at
> org.apache.olingo.odata2.core.ep.consumer.JsonEntryConsumer.readFeedEntry(JsonEntryConsumer.java:117)
> at
> org.apache.olingo.odata2.core.ep.consumer.JsonFeedConsumer.readArrayContent(JsonFeedConsumer.java:153)
> at
> org.apache.olingo.odata2.core.ep.consumer.JsonFeedConsumer.handleName(JsonFeedConsumer.java:122)
> at
> org.apache.olingo.odata2.core.ep.consumer.JsonFeedConsumer.readFeedContent(JsonFeedConsumer.java:111)
> at
> org.apache.olingo.odata2.core.ep.consumer.JsonFeedConsumer.readFeed(JsonFeedConsumer.java:96)
> at
> org.apache.olingo.odata2.core.ep.consumer.JsonFeedConsumer.readFeedStandalone(JsonFeedConsumer.java:63)
> at
> org.apache.olingo.odata2.core.ep.consumer.JsonEntityConsumer.readDeltaFeed(JsonEntityConsumer.java:95)
> at
> org.apache.olingo.odata2.core.ep.consumer.JsonEntityConsumer.readFeed(JsonEntityConsumer.java:81)
> at
> org.apache.olingo.odata2.core.ep.JsonEntityProvider.readFeed(JsonEntityProvider.java:309)
> at
> org.apache.olingo.odata2.core.ep.ProviderFacadeImpl.readFeed(ProviderFacadeImpl.java:165)
> at
> org.apache.olingo.odata2.api.ep.EntityProvider.readFeed(EntityProvider.java:676)
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)