Precision and Scale bug mysql
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 4.5k
- Forks
- 884
- PR merge metrics
- No merged PRs in 30d
Description
When I create table with column decimal, for example:
->addColumn(
'id_usuario_inclusao',
'decimal', [
'default' => null,
'null' => false,
'precision' => 30,
'scale' => 0
])
the method protected function getColumnSqlDefinition() in Phinx\Db\Adapter\MysqlAdapter, no set precision and scale because the verification if ($column->getPrecision() && $column->getScale()) { not works.
If I set scale how true, 1 and more it works, for example:
->addColumn(
'id_usuario_inclusao',
'decimal', [
'default' => null,
'null' => false,
'precision' => 30,
'scale' => true
])
My suggest is change the verification if to:
if ($column->getPrecision() && $column->getScale()) {
$def .= '(' . $column->getPrecision() . ',' . $column->getScale() . ')';
} elseif ($column->getScale()) {
$def .= '(' . 10 . ',' . $column->getScale() . ')';
} elseif ($column->getPrecision()) {
$def .= '(' . $column->getPrecision() . ',' . 0 . ')';
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Phinx\Db\Adapter\MysqlAdapter, in protected getColumnSqlDefinition(), and reproduce the decimal-column case with precision 30 and scale 0. Check the generated MySQL column definition for zero-valued scale or precision, then verify that the resulting SQL preserves the requested decimal precision and scale.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, php
- Domain
- database
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100