This is kind-of a known limitation of DBAL types, sorry.

See https://github.com/doctrine/dbal/issues/2411, for example. Also has
been reported over multiple years, but it would need some architectural
changes in DBAL that we didn't plan yet.

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On 7 July 2016 at 22:32, Kevin Young <[email protected]> wrote:

> I am new to doctrine and I have a task to change a couple of custom types
> precision and scale.
>
> I was hoping that altering them in the Custom type's class would cause
> doctrine to give an alter column output but it does not.
>
> Doctrine does not seem to notice the change. There are a good number of
> fields and multiple custom types I have to change so I'm hoping there is an
> easy way to get doctrine to recognize the change.
>
> I have boiled the problem down to this
>
> setup:
>
> class TestType extends Type
> {
>     const TEST = 'test';
>
>     public function getSQLDeclaration(array $fieldDeclaration, 
> AbstractPlatform $platform)
>     {
>         return 'NUMERIC(' . 5 . ', ' . 2 . ')';
>     }
>
>
>     public function getName()
>     {
>         return self::TEST;
>     }
>
>     /**
>      * @inheritdoc
>      */
>     public function requiresSQLCommentHint(AbstractPlatform $platform)
>     {
>         return true;
>     }
> }
>
>
> /**
>  * @ORM\Entity
>  */
>
> class TestDigest
> {
> /**
> * @ORM\Id
> * @ORM\GeneratedValue(strategy="AUTO")
> * @ORM\Column(type="integer")
> */
> protected $id;
>
>
> /**
> * @ORM\Column(type="test")
> */
> protected $testType;
> } The command "doctrine orm:schema-tool:update --dump-sql" gives me
>
> CREATE TABLE TestDigest (id INT IDENTITY NOT NULL, testType NUMERIC(5, 2) NOT 
> NULL, PRIMARY KEY (id));
> EXEC sp_addextendedproperty N'MS_Description', N'(DC2Type:test)', N'SCHEMA', 
> dbo, N'TABLE', TestDigest, N'COLUMN', testType;
>
>
> What I need to do:
>
> Change TestType to NUMERIC(7, 4)
> so
>
>
> class TestType extends Type
> {
>     const TEST = 'test';
>
>     public function getSQLDeclaration(array $fieldDeclaration, 
> AbstractPlatform $platform)
>     {
>         return 'NUMERIC(' . 7 . ', ' . 4 . ')';
>     }
>
>
>     public function getName()
>     {
>         return self::TEST;
>     }
>
>     /**
>      * @inheritdoc
>      */
>     public function requiresSQLCommentHint(AbstractPlatform $platform)
>     {
>         return true;
>     }
> }
>
> *The command "doctrine orm:schema-tool:update --dump-sql" give me nothing.
>
> I am using doctrine 2.5.4.*
>
> *I do
> *
>
> Type::addType('test', 'Saw\Digest\Types\TestType');
> and
>
> $entityManager = $serviceManager->get('doctrine.entitymanager.orm_default');
>
> $connection->getDatabasePlatform()->registerDoctrineTypeMapping('db_test', 
> 'test');
>
>
> *I don't see a way to do it with extending type and DecimalType and there are 
> a few issues with that. *
>
> *You either need to have the values to 10,0 or set the Precision and scale in 
> the annotations.
> We want to try and avoid the need to have to set the precision every time we 
> use our custom fields.*
>
> *
> If anyone know a good solution to this problem please let me know.*
>
>
> *I don't know what other info you need but feel free to ask for it*
>
> --
> You received this message because you are subscribed to the Google Groups
> "doctrine-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/doctrine-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to