Skip to content

Conversation

rdowne
Copy link
Contributor

@rdowne rdowne commented Aug 29, 2017

Given that jsonschema has both "numeric" and "integer" types, I think that numeric types with no fixed point specifications should be floating point types in the database.

Happy to flesh this out to mysql as well; did postgres here because that's the db I know and the one I work with.

if (property.decimals && property.decimals > 0) {
column = 'NUMERIC(' + property.maxLength + ',' + property.decimals + ')';
} else {
column = integerType;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For compatibility a else if is required here:

      if (property.decimals && property.decimals > 0) {
        column = 'NUMERIC(' + property.maxLength + ',' + property.decimals + ')';
      } else if (property.maxLength > 0) {
        column = integerType;
      } else {
        column = floatType;
      }

src/index.js Outdated
break;
case 'real':
case 'double precision':
property.type = 'numeric';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

property.type should contain a valid json schema type then this line better be property.type = 'number'

@rdowne
Copy link
Contributor Author

rdowne commented Aug 30, 2017 via email

@andrglo andrglo merged commit 4cf0124 into andrglo:master Aug 31, 2017
@andrglo
Copy link
Owner

andrglo commented Aug 31, 2017

Yes, only for compatibility with existing code

@rdowne rdowne deleted the numeric-to-float branch August 31, 2017 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants