Skip to content

Commit 6202ac8

Browse files
committed
Change default value of precision if non is provided in metadata
According to ODATA V4 specification when precision is not provided it defaults to infinity. ODATA V2 specification does not provide any information regarding the default value and ODATA V3 specification is unclear. Thus, following the ODATA V4 specification for all versions seams as the best idea. https://www.odata.org/documentation/odata-version-3-0/common-schema-definition-language-csdl/#csdl5.3.4 https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/csprd06/odata-csdl-xml-v4.01-csprd06.html#sec_Precision https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/csprd06/odata-csdl-xml-v4.01-csprd06.html#sec_Scale
1 parent 7e1fde8 commit 6202ac8

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2020

2121
### Changed
2222
- Implementation and naming schema of `from_etree` - Martin Miksik
23-
- Build functions of struct types now handle invalid metadata independently. - Martin Miksik
23+
- Build functions of struct types now handle invalid metadata independently. - Martin Miksik
24+
- Default value of precision if non is provided in metadata - Martin Miksik
2425

2526
### Fixed
2627
- make sure configured error policies are applied for Annotations referencing

pyodata/model/elements.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def __init__(self, name, type_info, nullable, max_length, precision, scale):
293293
self._max_length = int(max_length)
294294

295295
if not precision:
296-
self._precision = 0
296+
self._precision = None
297297
else:
298298
self._precision = int(precision)
299299
if not scale:
@@ -337,7 +337,7 @@ def scale(self):
337337
return self._scale
338338

339339
def _check_scale_value(self):
340-
if self._scale > self._precision:
340+
if self._precision and self._scale > self._precision:
341341
raise PyODataModelError('Scale value ({}) must be less than or equal to precision value ({})'
342342
.format(self._scale, self._precision))
343343

0 commit comments

Comments
 (0)