【问题标题】:Postgresql column exists, but getting column of relation does not existPostgresql 列存在,但获取关系列不存在
【发布时间】:2021-07-29 18:07:46
【问题描述】:
 query =
      'insert into ' +
      table +
      "( replyDate) values('" +
      event.state.session.lastMessages
        .map(function(elem) {
          return elem.replyDate
        })
        .join(',') +
      "')"

我有一个名为 messages 的表,其中有一个名为 replyDate 的列。 event.state.session.lastMessages 包含一个 javascript 对象列表,如下所示: [ { eventId: '14337275205243615', incomingPreview: 'bonjour', replyConfidence: 1, replySource: 'dialogManager', replyDate: '2021-05-04T16:40:07.242Z', replyPreview: '#!builtin_single-choice-mrFFU_' } ]

我想将值replyDate 保存在我的数据库中,但出现错误:

Executing: insert into messages( replyDate) values('2021-05-07T11:33:36.721Z,2021-05-07T11:33:39.704Z,2021-05-07T11:33:42.414Z,2021-05-07T11:33:42.422Z,2021-05-07T11:33:49.454Z')
 error: la colonne « replydate » de la relation « messages » n'existe pas

【问题讨论】:

  • 很可能该列是用大写字符定义的(错误),您现在需要双引号。
  • 离题:您使用什么 javascript 库与您的数据库交互?您可以从准备好的陈述中受益匪浅。
  • @LaurenzAlbe 你是对的,谢谢。
  • @Adam 我正在使用框架 Botpress
  • 您能分享一下表架构吗?错误消息la colonne « replydate » de la relation 表明还提交了replydate 列而不是replyDate。即使您提供了一个示例对象,仍然看起来像是拼写错误。

标签: javascript postgresql botpress


【解决方案1】:

如果你的表名是大写的,你必须用双引号把表括起来

insert into messages( "replyDate") values('2021-05-07T11:33:36.721Z'),('2021-05-07T11:33:39.704Z'),('2021-05-07T11:33:42.414Z'),('2021-05-07T11:33:42.422Z'),('2021-05-07T11:33:49.454Z')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-11-18
    • 2017-05-26
    • 2020-05-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多