[Solved] Decimal with only one digit after comma

0 votes
asked May 29, 2013 in Solved by Alexander (250 points)
recategorized May 29, 2013 by ludek.vodicka

Hello.
Can somebody help me with the problem.
For now in ORM Designer I've type called - (Decimal) and after I transform this in database I got some kind of [ decimal(18,2) ].
My question is - How can I make [ decimal(18,1) ] with only one digit after comma.

ORM Framework - Doctrine1

2 Answers

0 votes
answered May 29, 2013 by Alexander (250 points)
 
Best answer

I found solution.

If you are using Doctrine1 in ORM Designer and what to change precision you should use "Scale" property and after generation you'll receive
- [ doctrine(int, scale) ]
in my situation if I set scale = 1 then I receive [ decimal(18,1) ]

commented May 29, 2013 by ludek.vodicka Skipper developer (140,450 points)

Perfect. I'm glad you found a solution!

I updated help-text for scale property in ORM Designer to reflect what it does.

commented May 29, 2013 by Alexander (250 points)

Thank you for your time :)

0 votes
answered May 29, 2013 by ludek.vodicka Skipper developer (140,450 points)

It's hard to help without knowledge which ORM framework you're using.

But the best practice is search in ORM documentation if your ORM framework support such feature (in some ORMs it's called "decimal" or "precision"). After you found such feature in ORM documentation, try to find same field property in ORM Property editor.

enter image description here

commented May 29, 2013 by Alexander (250 points)

I'm using - Doctrine1 ORM framework

But in properties I can't find property named - "Precision"
Maybe it's located some where else?

commented May 29, 2013 by ludek.vodicka Skipper developer (140,450 points)

As I wrote in my previous reply. You need to check in ORM documentation if ORM framework supports this feature. Screenshot I sent you was example of Doctrine2 properties.

After quick review of Doctrine1 ORM properties it seems that D1 doesn't support such feature.

commented May 29, 2013 by Alexander (250 points)

Hmm, it's not good. Because even if I use "MySQL Workbench" it's possible to add precision.

Ok. Thanks for answer!

commented May 29, 2013 by ludek.vodicka Skipper developer (140,450 points)

Sure, but MySql Workbench doesn't use ORM to define columns. MySql Workbench directly modifies database structure. On the other hand ORM Designer strictly uses only features offered by specific ORM.

So if ORM framework doesn't support it, it's not possible to configure it via ORM Designer ;-).

Great! You're right, scale seems to do the job.
I also checked Doctrine1 documentation to be sure and D1 really doesn't support decimal modifier: http://docs.doctrine-project.org/projects/doctrine1/en/latest/en/manual/defining-models.html

commented May 29, 2013 by Alexander (250 points)

Thank you solution was found for Doctrine1 in ORM Designer :)

...