PGError:错误:关系列不存在 [英] PGError: Error: column of relation does not exist

查看:152
本文介绍了PGError:错误:关系列不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将列"isGroup"的值更改为值"public".

I'm trying to change the value of a column "isGroup" to the value "public".

我创建了一个迁移:

Post.connection.execute("update Posts set isgroup='public'")

但是,出现以下错误:

PGError: ERROR:  column "isgroup" of relation "posts" does not exist

不幸的是,我在连接和执行迁移的同时运行了创建迁移的列.但是,"isGroup"列确实存在于Heroku上,因此很奇怪该列未显示为出现.

I had unfortunately ran the column creating migration at the same time as the connection.execute migration. However, the "isGroup" column does exist on Heroku, so it is weird that the column is not showing as appearing.

有什么建议吗?

推荐答案

如果您确定列isGroup存在,则应使用以下方式对其进行引用:

If you are sure that column isGroup exists, then you should quote it like:

UPDATE posts SET "isGroup" = 'public'

请注意,默认情况下,PostgreSQL会将所有未加引号的名称折叠成小写.

Note that PostgreSQL by default folds all unquoted named to lowercase.

为避免这种混淆和引用的必要性,您可能希望使用ALTER TABLE ... RENAME COLUMN ...isGroup重命名为isgroup.

To avoid this confusion and necessity to quote, you might want to rename isGroup to isgroup using ALTER TABLE ... RENAME COLUMN ....

这篇关于PGError:错误:关系列不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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