4

我有一个类需要 TEXT 最多约 300k 个字符,并且它存储在 PostgreSQL 数据库中。

Postgres 本身对兆字节 blob 没有问题,(最终我会将它们存储在 S3 中),但 Datamapper 对 TEXT 有“65k 个字符”的默认限制:

默认情况下,DataMapper 支持以下原始类型:

  • TrueClass,布尔值
  • 细绳
  • 文本(默认限制为 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?

或者是其他东西?

4

1 回答 1

3

好的,

原来 :length 确实有效。

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
于 2012-09-10T20:42:53.387 回答