Hi gugod

I believe you've actually discovered a bug in dm-core.  It's not
intended that options set in the way you did propagate down into
subclasses which have previously set their own value.

Regards
Jon

On 10 October 2010 17:26, gugod <[email protected]> wrote:
> Hi all,
>
> Recently I changed the default string length from 50 to 255 with this:
>
>    DataMapper::Property::String.length(255)
>
> However, that also effected Text properties and those properties
> becomes a `tinytext` table fields. After reading property.rb a bit, I
> realized that this seems to be coded on purpose -- all sub-classes of
> DataMapper::Property::String has `length` option as a class method,
> and changing the value of length on String will end up being
> propagated to all is subclasses.
>
> And then the work-around is to add another lines to reset default Text
> length like this:
>
>    DataMapper::Property::String.length(255)
>    DataMapper::Property::Text.length(65535)
>
> While this usage is not documented as the way to alter default length,
> it seems to becomes a small problem that people might bump into from
> time to time. Mainly because String has a very insufficient default
> length of 50. A commonly used `email` or `title` field (of any sort of
> model) can easily overflow that limit. People using ActiveRecord::Base
> before will feel highly uncomfortable with that short length and
> they'll want to change the default to be 255 if they figured out how.
>
> It feels like the current coded behavior can benefit dm internally so
> maybe they should not be changed. Because of that, I wonder if this
> should be at least documented somewhere for reference. Or
> alternatively, DataMapper should provide some sort of official
> configure API (maybe like Rspec.configure) such that options in each
> property classes can be individually tweaked.

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to