Postgres 13.12:错误:{错误:列 cnst.consrc 不存在

问题描述 投票:0回答:1

我正在使用 AWS RDS postgres 13.12 和 Node js typeorm 0.2.19。

error: { error: column cnst.consrc does not exist
query failed: SELECT "ns"."nspname" AS "table_schema", "t"."relname" AS "table_name", "cnst"."conname" AS "constraint_name", CASE "cnst"."contype" WHEN 'x' THEN pg_get_constraintdef("cnst"."oid", true) ELSE "cnst"."consrc" END AS "expression", CASE "cnst"."contype" WHEN 'p' THEN 'PRIMARY' WHEN 'u' THEN 'UNIQUE' WHEN 'c' THEN 'CHECK' WHEN 'x' THEN 'EXCLUDE' END AS "constraint_type", "a"."attname" AS "column_name" FROM "pg_constraint" "cnst" INNER JOIN "pg_class" "t" ON "t"."oid" = "cnst"."conrelid" INNER JOIN "pg_namespace" "ns" ON "ns"."oid" = "cnst"."connamespace" LEFT JOIN "pg_attribute" "a" ON "a"."attrelid" = "cnst"."conrelid" AND "a"."attnum" = ANY ("cnst"."conkey") WHERE "t"."relkind" = 'r' AND (("ns"."nspname" = 'dbname' AND "t"."relname" = 'users'))

我尝试将 typeorm 扩展升级到 0.2.45 和 0.3.6,因为最新版本抛出错误。 我尝试在本地系统中重新生成相同的错误,并且当我们在架构内没有任何表时发生这种情况,此时它会抛出错误。但在本地升级 TypeOrm 扩展版本时它解决了错误。但是当我在服务器上尝试相同的解决方案时,它会抛出不同的错误,例如

QueryFailedError: relation "dbname.datamod" does not exist
 
      at new QueryFailedError (src/error/QueryFailedError.ts:9:9)
      at Query.callback (src/driver/postgres/PostgresQueryRunner.ts:178:30)
      at Query.handleError (node_modules/pg/lib/query.js:146:19)
      at Connection.connectedErrorMessageHandler (node_modules/pg/lib/client.js:236:17)
      at Connection.emit (node:events:513:28)
      at Connection.emit (node:domain:489:12)
      at Socket.<anonymous> (node_modules/pg/lib/connection.js:121:12)
      at Socket.emit (node:events:513:28)
      at Socket.emit (node:domain:489:12)
      at addChunk (node:internal/streams/readable:315:12)
 

降级 Postgres 可能会解决此问题,但问题仅出现在开发服务器上,相同的配置适用于更高的环境。

node.js postgresql typeorm postgresql-13
1个回答
0
投票

Postgres 12 已从系统目录中删除了过时的列

pg_constraint.consrc

过时的参考

"cnst"."consrc"
必须替换为
pg_get_expr(cnst.conbin, cnst.conrelid)
。参见:

更新扩展消除错误是有意义的,因为期望当前版本包含该更新是合理的。 (新表达式也适用于较旧的 Postgres 版本。)

© www.soinside.com 2019 - 2024. All rights reserved.