spotorm / spot2

Spot v2.x DataMapper built on top of Doctrine's Database Abstraction Layer
http://phpdatamapper.com
BSD 3-Clause "New" or "Revised" License
601 stars 101 forks source link

Problem when defining an entity with data of the decimal type #281

Closed dertin closed 5 years ago

dertin commented 5 years ago

Entity: 'FichaOrdenPrioridad' => ['type' => 'float', 'length' => [10, 9]]

MySQL: FichaOrdenPrioridad | double NULL

What I expected in MySQL: FichaOrdenPrioridad | decimal(10,9) unsigned NULL


MySQL version: 8.0.11 "vlucas/spot2": "dev-master"

FlipEverything commented 5 years ago

Hello!

To achieve what you expected use this:

'FichaOrdenPrioridad' => ['type' => 'decimal', 'precision' => 10, 'scale' => 9, 'unsigned' => true]

Result:

CREATE TABLE `x` (
  `FichaOrdenPrioridad` decimal(10,9) UNSIGNED DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

If you need further assistance feel free to reopen this issue. Have a nice day!