#1383 ✓resolved
smu43

dm-rails freezes when creating an invalid record

Reported by smu43 | August 9th, 2010 @ 10:37 PM | in 1.1

I am using rails 3.0.0.rc with the edge dm-rails.

Considering this class:

class User
  include DataMapper::Resource
  has n, :user_files
  property :id, Serial
  property :name, String, :required => true, :length => (1..n)
end

This line freezes in rails console:

irb(main):001:0> User.create :name => ''

Comments and changes to this ticket

  • Martin Gamsjaeger (snusnu)

    Martin Gamsjaeger (snusnu) August 10th, 2010 @ 05:47 PM

    • State changed from “new” to “unconfirmed”
    • Assigned user set to “Martin Gamsjaeger (snusnu)”
  • Martin Gamsjaeger (snusnu)

    Martin Gamsjaeger (snusnu) October 24th, 2010 @ 07:52 AM

    • State changed from “unconfirmed” to “confirmed”

    The problem here is not specific to dm-rails. It happens in raw irb as well, and is caused by the fact that the code is trying to automigrate an infinitely large upper bound for a String column (which cannot work). I agree that just hanging is probably not the most friendly way of reporting the problem back to the user, but there's really not much DM could do anyway (apart from informing the user that the desired operation doesn't make sense, which we should probably do at some point).

    A better way to specify the above would be to make a column of type Text and give that a large upper bound. In reality, it's not possible to have a totally unconstrained length on any kind of column anyway (at the very least, at some point you will hit the limits of physical memory available).

    Marking this confirmed for now, maybe we should discuss some more exactly what we wanna do about this. An error message, explaining to users that what they're doing doesn't make sense, might be best?

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) October 24th, 2010 @ 07:52 PM

    • State changed from “confirmed” to “resolved”

    (from [69b4b9a2237b6a73c708d6fb460caabb0cb8ba01]) Don't hang when a length range's maximum is Infinity

    Raise with a meaningful error message instead. It's
    not feasible to allow infinitely large persisted
    data structures since there's always some form of
    constraint in reality, depending on the datastore
    or even the physical amount of memory available.

    [#1383 state:resolved] http://github.com/datamapper/dm-validations/commit/69b4b9a2237b6a73...

  • Martin Gamsjaeger (snusnu)

    Martin Gamsjaeger (snusnu) October 24th, 2010 @ 07:53 PM

    • Milestone set to 1.1
    • Tag changed from rails3 dm-rails, create, validations to dm-validations
    • Milestone order changed from “196255” to “0”

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 »

Referenced by

Pages