-
Notifications
You must be signed in to change notification settings - Fork 3
Numeric to float #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
if (property.decimals && property.decimals > 0) { | ||
column = 'NUMERIC(' + property.maxLength + ',' + property.decimals + ')'; | ||
} else { | ||
column = integerType; |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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'
This does have the effect of eviscerating the maxLength property. Would it
be better to make it a varchar in this case? In jsonschema numbers can
have min and max values but length is somewhat meaningless? Or, if this is
for compatibility with existing code, I'm comfortable with just mapping to
an integer type as you suggested.
…On Tue, Aug 29, 2017 at 6:44 PM, Andre Gloria ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/index.js
<#4 (comment)>
:
> @@ -535,7 +537,7 @@ function propertyToPostgres(property, name, schema, isAlter) {
if (property.decimals && property.decimals > 0) {
column = 'NUMERIC(' + property.maxLength + ',' + property.decimals + ')';
} else {
- column = integerType;
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;
}
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFmhfwIrWmGerK-kH8YwgO_8jQPcochvks5sdJQygaJpZM4PFS7X>
.
--
RICHARD DOWNE
Figure 1 Director of Data
WEBSITE <https://figure1.com> | TWITTER <http://twitter.com/figure1> |
FACEBOOK <https://www.facebook.com/figure1>
|
Yes, only for compatibility with existing code |
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.