#1016 ✓resolved
Martin Gamsjaeger (snusnu)

Integer FK properties with :key => true generate different type than serial PKs (at least on mysql)

Reported by Martin Gamsjaeger (snusnu) | August 23rd, 2009 @ 01:57 AM | in 0.10.0

Standalone script that reproduces the error can be found at http://pastie.org/592033

As a consequence of this bug, dm-constraints fails to auto_migrate! the FK constraints on mysql

Comments and changes to this ticket

  • Martin Gamsjaeger (snusnu)

    Martin Gamsjaeger (snusnu) August 23rd, 2009 @ 11:21 AM

    namelessjon pointed out that doing the following does the trick

    property :post_id, Integer, :key => true, :min => 0
    

    Now the question is, if that should be the default for Integer key properties.

  • Martin Gamsjaeger (snusnu)

    Martin Gamsjaeger (snusnu) August 23rd, 2009 @ 11:22 AM

    • State changed from “unconfirmed” to “confirmed”
  • Jonathan Stott (namelessjon)

    Jonathan Stott (namelessjon) August 23rd, 2009 @ 11:31 AM

    Just to further snusnu's comments, I'm not sure that making Serial keys unsigned by default is such a good idea, due to issues like this. Whilst it does allow for an extra 2 billion items in a table, that is not likely to be an issue for the vast bulk of DataMapper users. And for those that it is, an UNSIGNED or a BIGINT Serial column is easy enough to add.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) September 2nd, 2009 @ 11:53 AM

    • Assigned user set to “Dan Kubb (dkubb)”
    • State changed from “confirmed” to “resolved”

    This should be resolved in edge dm-core. The min/max options weren't being copied over properly for Integer properties.

    The primary motivation for this change wasn't necessarily the extra space for serial keys -- although that's a nice side effect -- it was the database constraint that prevents negative integers from being inserted. Even if the change resulted in just the constraint, and the limit stayed the same, I would've made the same change.

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 »

Pages