加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby – 数量超出了ActiveRecord :: Type :: Integer,限制为4

发布时间:2020-12-16 21:54:32 所属栏目:百科 来源:网络整理
导读:我在我的 Ruby应用程序中使用SQLite ActiveRecord,并且在尝试将一个大数字写入整数字段时,我遇到错误: 1428584647765 is out of range for ActiveRecord::Type::Integer with limit 4 但是根据SQLite文档: The value is a signed integer,stored in 1,2,3,
我在我的 Ruby应用程序中使用SQLite ActiveRecord,并且在尝试将一个大数字写入整数字段时,我遇到错误:

1428584647765 is out of range for ActiveRecord::Type::Integer with
limit 4

但是根据SQLite文档:

The value is a signed integer,stored in 1,2,3,4,6,or 8 bytes depending on the magnitude of the value.

8字节是大量的空间存储1428584647765号码,那为什么ActiveRecord给我一个错误?为什么它认为这是一个4字节的字段?

解决方法

美好的一天.
默认情况下,使用len = 32字节创建columnt

为了改变这个,你可以创建迁移,例如:

t.integer :some_field,:limit => 8

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读