handle precision and scale #14
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The SQL data type decimal takes 'precision' and 'scale' options. Currently the loopback code does not support these options. These few lines of code represent a naive implementation.
I'm not certain how to test this. I had thought to call MsSQL.prototype.propertySettingsSQL, but this function is private to the adapter and not exposed via any export. I think being able to unit test some of the SQL building functions would be advantageous, but clearly would require code restructure.
Also, I am using these options in context of the
decimaldata type, but I imagine there could be other data types that use them as well.Just out of curiosity, is the ability to supply SQL-specific options to the schema type supported? It seems to have been taken out of the documentation. It was present in 1.x, but is no longer present in 2.x. This is important functionality for certain applications - for instance the project I'm working on needs to handle money and accounting data. Having control over the precision/scale is very useful.