#591 ✓resolved
felix (xilef)

Length of dm-type in migrations

Reported by felix (xilef) | October 14th, 2008 @ 11:27 PM | in 0.10.2

Using Slug which is set to length 65535, when rake db:migrate is run it tries to create a VARCHAR(65535) which is too long on MySQL. When db:automigrate is run it creates it correctly, honouring the size set in the model (for me 255).

This is using edge Merb so I am not sure what Rakefile funniness is underfoot.

If I remove the length of the type in its definition in dm-types it then tries to create a VARCHAR with no length, still ignoring my length set in the model.

Comments and changes to this ticket

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) December 5th, 2008 @ 04:48 AM

    • Assigned user cleared.
    • Tag set to dm-more, dm-types, migrations
    • State changed from “new” to “hold”

    Felix, what version of MySQL are you running? MySQL prior to 5.03 was limited to VARCHAR(255).

    It would actually be nice if our migration system would take into account the MySQL version and use VARCHAR when possible, because it's able to be indexed, and the allowed length can be specified more precisely. However in earlier versions of MySQL we might want to just use TEXT automatically when the length exceeds 255 characters.

    It's also questionable why a Slug type would need 65535 characters. I'm pretty certain no usable Slug would ever be that large, and I wouldn't be surprised if a URL that long would be not be valid according to the RFCs. I think 255 would be a reasonable maximum length. Perhaps we should discuss with the original Slug author to be sure.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) January 8th, 2009 @ 02:49 PM

    • Assigned user set to “Michael Klishin (antares)”
  • Michael Klishin (antares)

    Michael Klishin (antares) March 25th, 2009 @ 03:26 PM

    • Milestone set to 0.10.0
    • Tag changed from dm-more, dm-types, migrations to dm-migrations, dm-more, migrations
    • State changed from “hold” to “unconfirmed”

    It is likely to be dm-migrations problem, moving for 0.10.

  • Anthony Williams

    Anthony Williams June 24th, 2009 @ 08:28 AM

    Hi,

    I recently experienced a similar issue to this after trying out 0.10 RC1 on Postgres. The custom types in dm-types which use a String primitive all set the column length to 50 (which I believe is the default for string columns), rather than whatever is set in the type. I found that replacing size nnn with length nnn solved the problem.

    However, I'm not sure that's a perfect fix: the dm-types specs all pass when using SQlite, but many fail when using Postgres, implying that the cause might be elsewhere (adapters or auto-migrator, perhaps?) I'm happy to look into this further, but I'm not sure where to start; I couldn't see any obvious difference between the SQlite and Postgres adapters which might be causing this.

    Unfortunately, I'm not sure what the situation is on MySQL as I don't have an installed copy handy at the moment.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) August 14th, 2009 @ 03:16 AM

    • Assigned user changed from “Michael Klishin (antares)” to “Dan Kubb (dkubb)”
    • State changed from “unconfirmed” to “accepted”

    I made some fixes to dm-migrations and custom types for another ticket. Would you mind trying this again and see if the problem is resolved with edge dm-core (the next branch)

  • Glen Mailer

    Glen Mailer October 1st, 2009 @ 11:30 AM

    I've experienced a similar problem with the Text type, as far as I can tell, the dm-migrations code identifies String as the primitive of Type, and then looks up the String type in the type map, leaving it with VARCHAR and 50.

    After merging in the options from the type_class.options hash, this leaves 65535 and VARCHAR, which fails.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) October 4th, 2009 @ 09:33 PM

    • Milestone changed from 0.10.0 to 0.10.2

    [project:id#20609 not-tagged:"0.10.0" milestone:id#51895 bulk edit command]

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) October 6th, 2009 @ 12:04 PM

    (from [6a63b2ba78c6432020cb395c708cf4205c34cc44]) Updated Text type to be a primitive

    • Allows Csv, Json and Yaml types in dm-types to use the Text column underneath.

    [#591] http://github.com/datamapper/dm-core/commit/6a63b2ba78c6432020cb395...

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) October 6th, 2009 @ 12:06 PM

    • State changed from “accepted” to “resolved”

    (from [3177dad62d5c6a2a0696982a674dbcadaf7abb7e]) [dm-types] Make sure Csv, Json and Yaml types are based on the Text type

    [#591 state:resolved] http://github.com/datamapper/dm-more/commit/3177dad62d5c6a2a0696982...

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