How to set precision and scale for decimal data type
See original GitHub issueI’m submitting a…
- Bug report
- Feature request
- Question
Current behavior
I can’t add precision
and scale
options to decimal
data type. (it always use decimal(10,0)
)
Expected behavior
It should be able to specific precision
and scale
when i use below config:
price: { type: 'decimal', length: '16,4' },
db-migrate version: latest plugins with versions: latest db-migrate driver with versions: mysql latest
Additional information:
- Node version: v11
- Platform: Macos
Thank you very much for a nice job! 😄
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Precision, scale, and length (Transact-SQL) - Microsoft Learn
Precision is the number of digits in a number. Scale is the number of digits to the right of the decimal point in...
Read more >How do I interpret precision and scale of a number in a ...
Precision is the number of digits in a number. Scale is the number of digits to the right of the decimal point in...
Read more >An Essential Guide To SQL Server DECIMAL Data Type
To store numbers that have fixed precision and scale, you use the DECIMAL data type. The following shows the syntax of the DECIMAL...
Read more >DECIMAL(p,s) - 4Js
When using DECIMAL(p,s) with a precision and scale, you define a decimal for fixed point arithmetic, with p significant digits and s digits...
Read more >Understanding the SQL Decimal data type - SQLShack
p stands for Precision, the total number of digits in the value, i.e. on both sides of the decimal point · s stands...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you use this it works.
{ type: "decimal(10,2)" }
this has not been carried to every driver, but is certainly something that should.
https://github.com/db-migrate/mysql/blob/d2fdff16239c455a5ef02699a0cabf1cca5d4215/index.js#L78-L81
for MySQL you could use
{ type: 'decimal', precision: x, scale: x }
, that would need to be added to the base driver to work everywhere though.