我有一个类需要TEXT最多大约300k字符,并且它存储在PostgreSQL数据库中。
Postgres本身对于兆字节blob没有问题,(最终我会将它们存储在S3中),但Datamapper对于TEXT的默认限制为“65k个字符”:
默认情况下,DataMapper支持以下基本类型:
- TrueClass,Boolean
- 字符串
- 文字(默认限制为65k个字符)
我想做点什么
property :id, Serial
property :name, String, :index => true
property :posted, DateTime
property :info, DataMapper::Types::Text, :lazy => false
property :data, DataMapper::Types::Text, :limit => 500000 # needs to be big is :limit correct?5
我知道懒惰部分没问题,因为我是从http://datamapper.rubyforge.org/dm-core/DataMapper/Property.html得到的 - 但是用于覆盖TEXT字段限制的关键字是什么:
:length
?:maximum
?:limit
?还是其他什么?
答案 0 :(得分:3)
好的,
原来:长度确实有效。
class SomeClass
include DataMapper::Resource
property :id, Serial
property :name, String, :index => true # strings are actively loaded
property :posted, DateTime
property :info, Text, :lazy => false # This is short stuff a hundred or so bytes long that I want loaded
property :data, Text, :length => 500000 # Text is lazy loaded by default, but I also need to override the default length limit which is 65536 chars in DM