json field

48 views
Skip to first unread message

Jos Elkink

unread,
Sep 20, 2009, 3:37:49 AM9/20/09
to datam...@googlegroups.com
Hi all,

I just upgraded to 0.10 and one feature suddenly doesn't work anymore. I have a field of type Json (from dm-types) and when I use the migrate command, it tries to create a varchar(65535) field, while the maximum is apparently 21845 ... Did anyone else experience this? What is the easiest solution?

Jos

Jordan Ritter

unread,
Sep 20, 2009, 5:25:04 AM9/20/09
to datam...@googlegroups.com
Assuming you're using MySQL, this is probably because you're in UTF-8
mode and MySQL uses 3 bytes for each UTF8 character.

DM 0.10 defaults to the TEXT SQL type (65k/3 = ~21k) for the Text
primitive (Json/Yaml/etc are built on it), but can auto-size any Text-
based field when a maximum length is specified. Try passing the
option :length => 2**24-1 (MEDIUMTEXT) or :length => 2**32-1
(LONGTEXT) to your Json property, and call ::DataMapper.auto_migrate!
again.

cheers,
--jordan
Reply all
Reply to author
Forward
0 new messages