#413 ✓resolved

can not assign precision, scale to a float

Reported by feydr | June 24th, 2008 @ 09:31 AM

I use a BigDecimal for a money related column as I am unable to use scale/precision with a float.


When I try to change the schema I get a message of 'For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 'small').'

When I change the schema from within irb I get the error:

>> h.valid?

  1. => true

ruby: main

>> h.small = 2

  1. => 2

ruby: main

>> h.valid?

/usr/lib/ruby/gems/1.8/gems/dm-validations-0.9.2/lib/dm-validations/numeric_validator.rb:36: warning: regexp has invalid interval

/usr/lib/ruby/gems/1.8/gems/dm-validations-0.9.2/lib/dm-validations/numeric_validator.rb:36: warning: regexp has `}' without escape

/usr/lib/ruby/gems/1.8/gems/dm-validations-0.9.2/lib/dm-validations/numeric_validator.rb:36: warning: regexp has invalid interval

/usr/lib/ruby/gems/1.8/gems/dm-validations-0.9.2/lib/dm-validations/numeric_validator.rb:36: warning: regexp has `}' without escape

  1. => false

My db is mysql and I use memcache 1.2.1. I have the following gems

ian@hypatia:~/bluffware/merb-backend$ gem list | grep dm

dm-aggregates (0.9.2)

dm-ar-finders (0.9.2)

dm-cli (0.9.2)

dm-core (0.9.2, 0.9.1)

dm-couchdb-adapter (0.9.2)

dm-is-nested_set (0.9.2)

dm-is-tree (0.9.2)

dm-migrations (0.9.2)

dm-more (0.9.2)

dm-observer (0.9.2)

dm-rest-adapter (0.9.2)

dm-serializer (0.9.2)

dm-shorthand (0.9.2)

dm-timestamps (0.9.2)

dm-types (0.9.2)

dm-validations (0.9.2)

I am using Merb

ian@hypatia:~/bluffware/merb-backend$ gem list | grep merb

merb (0.9.4, 0.9.3)

merb-action-args (0.9.4, 0.9.3)

merb-assets (0.9.4, 0.9.3)

merb-auth (0.1.0)

merb-builder (0.9.4, 0.9.3)

merb-cache (0.9.4, 0.9.3)

merb-core (0.9.4, 0.9.3)

merb-freezer (0.9.4, 0.9.3)

merb-gen (0.9.4, 0.9.3)

merb-haml (0.9.4, 0.9.3)

merb-mailer (0.9.4, 0.9.3)

merb-more (0.9.4, 0.9.3)

merb-parts (0.9.4, 0.9.3)

merb-slices (0.9.4)

merb_activerecord (0.9.4)

merb_datamapper (0.9.3)

merb_helpers (0.9.4)

merb_param_protection (0.9.4)

merb_sequel (0.9.4)

merb_stories (0.9.4)

merb_test_unit (0.9.4)

Comments and changes to this ticket

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) June 24th, 2008 @ 11:05 AM

    • State changed from “new” to “open”

    feydr, I'm not sure why you're getting that warning. Which backend are you using?

    Also I added some debug code to dm-validates so if the precision/scale are set incorrectly it'll raise a warning:


    I also rearranged the code so it was a bit more clear what the different conditions were for. I will probably add some sort of checking in the property declaration too.

    Can you sync up dm-core and dm-more and pastie the errors (if any) that you get?

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) June 24th, 2008 @ 11:56 AM

    feydr, I also added some checks into the property declarations so if the precision/float are wrong it should blow up as expected:


  • feydr

    feydr June 24th, 2008 @ 01:38 PM

    Dan: I upgraded to latest git repo and everything seems to work now.

    Guess I should have tried that first.


  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) June 24th, 2008 @ 01:48 PM

    • Milestone cleared.
    • Assigned user changed from “Sam Smoot” to “Dan Kubb (dkubb)”
    • State changed from “open” to “resolved”

    feydr, yeah there was a bug where I accidentally flipped around precision and scale, so Float and BigDecimal columns were being created with the wrong values. I fixed it about a week ago, but I think with the addition of these extra checks in dm-core and dm-validates anyone relying on the old buggy behavior will update their software.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket