Postgres:错误:类型字符变化的值太长(255)未指定字段 [英] Postgres: ERROR: value too long for type character varying(255) Does not specify the field

查看:2455
本文介绍了Postgres:错误:类型字符变化的值太长(255)未指定字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我偶尔会遇到此错误,显然我需要将类型从字符串更改为文本,但是日志未显示是哪一列是罪魁祸首。下面是来自resque的日志,它是最详细的错误输出,但是它是一个大表,并且sql输出会因错误而异,只是整个更新sql的一小部分。关于如何找出错误所指向的列的任何想法?

I am getting this error occasionally and obviously I need to change the type from string to text, but the logs do not show which column is the culprit. Below is log from resque which is the most detailed error output but it is a large table and the sql output changes from error to error and is just a small portion of the entire update sql. Any ideas on how to figure out which column the error is referring to?


PG :: StringDataRightTruncation:错误:对于类型字符,值太长Variant(255):UPDATE listings SET created_at = $ 1, date_posted = $ 2, google_map_link = $ 3, phone = $ 4, acency_id = $ 5, updated_at = $ 6 WHERE listings。 id = 392998

PG::StringDataRightTruncation: ERROR: value too long for type character varying(255) : UPDATE "listings" SET "created_at" = $1, "date_posted" = $2, "google_map_link" = $3, "phone" = $4, "acency_id" = $5, "updated_at" = $6 WHERE "listings"."id" = 392998

谢谢!

推荐答案

这是几年后的事了,在Python / Django中,但也许有人会发现它有用:

This is years later and in Python/Django, but perhaps someone will find this useful:

我几乎专门处理大量文本文件。我设置了一个字典来镜像数据库列,即:dict ['good_column']。
然后在我的try / except中,将其添加到logger.warning(您搞砸了一些东西:。format(dict ['good_column'])。这样,日志便会告诉我确切的位置寻找问题。我认为Ruby具有与此等效的构造。

I work almost exclusively with large numbers of text files. I set up a dict to mirror the database columns, ie: dict['good_column']. Then in my try/except, I added that to the end of my logger.warning("You screwed something up: ".format(dict['good_column']). That way, the log tells me exactly where to look for the problem. I assume Ruby has some equivalent constructs to do this with.

希望对某人有帮助。

这篇关于Postgres:错误:类型字符变化的值太长(255)未指定字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆