datamapper / dm-types

DataMapper plugin providing extra data types
http://datamapper.org/
MIT License
55 stars 80 forks source link

Can't make String properties with arbitrary length #29

Closed solnic closed 13 years ago

solnic commented 13 years ago

Setting a property with type String forces a limit on the length. It defaults to 50, and there is no way to un-set it.

property :name, String, :length => nil
# +options[:length]+ should be Range or Integer, but was NilClass (ArgumentError)

property :name, String, :length => n
# options[:length]+ should be Range or Integer, but was Float (ArgumentError)

Yes, I could used Text, :lazy => false, but thats convoluted. Postgres has no limit on the length of VARCHAR columns, and MySQL has a 64K limit, but requires that a limit be specified. SQLite3 has no limit, even if one is specified. Several other adapters have no limit on a string-ish attribute.

My suggestion would be to remove the default 50-char limit from String properties, and have no default limit. The MySQL adapter can then pick a special default, since it is the only one that needs it.


Created by Paul Sadauskas (Rando) - 2009-05-14 21:51:04 UTC

Original Lighthouse ticket: http://datamapper.lighthouseapp.com/projects/20609/tickets/850

dkubb commented 13 years ago

This change will not be made. A length is needed in most cases, and IMHO it is bad practice to say a string is "infinite" in length regardless of the storage engine.

If you really need this it's probably possible to set using DataMapper::Property::String.length(nil) but if it doesn't work there won't be any direct support to add it.