question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to set precision and scale for decimal data type

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
patebrycommented, Feb 24, 2022

If you use this it works. { type: "decimal(10,2)" }

0reactions
wzrdtalescommented, May 2, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found