首页 > 解决方案 > aws rds postgres9.6:在数据库恢复地理位置列后返回字符串而不是对象

问题描述

我有一个自动恢复脚本,它已经运行了大约 1 年,但在上个月,有些东西发生了变化,导致地理请求以字符串而不是对象的形式返回。同一集群中较旧的数据库以完全相同的值正确返回,因此在完成还原后我正在努力找出列/数据的问题?

我有一个测试 nodejs 脚本,它使用 sequelize 作为 ORM 来单独测试 dbs。我最初认为这是 ORM 的问题,但考虑到它适用于一个数据库而不是另一个数据库,具有完全相同的数据,这让我认为恢复的数据库有问题。作为字符串而不是对象返回的代码块是:

geoPointLocation: {
    type: Sequelize.GEOMETRY('POINT'),
    defaultValue: DEFAULT_GEOPOINT,
},
...
const geoPointLocation = this.getDataValue('geoPointLocation');
...

从数据库中“看起来”它们完全一样,但显然我错过了什么?

框架执行的查询:

SELECT "name", "address", "geoPointLocation" FROM "Locations" AS "Locations" WHERE "Locations"."name" = 'this-issue-sucks';

工作数据库 <<

postgres@working_db=> select ST_IsValid("geoPointLocation") from "Locations" where name = 'this-issue-sucks';
-[ RECORD 1 ]-
st_isvalid | t

postgres@working_db=> select st_asText("geoPointLocation") from "Locations" where name = 'this-issue-sucks';
-[ RECORD 1 ]----------------------------
st_astext | POINT(-77.0365739 38.8976633)

postgres@working_db=> select "geoPointLocation" from "Locations" where name = 'this-issue-sucks';
-[ RECORD 1 ]----+-------------------------------------------
geoPointLocation | 0101000000C7180E3A574253C0E3288AA1E6724340

失败的数据库<<

postgres@temp_geo=> select ST_IsValid("geoPointLocation") from "Locations" where name = 'this-issue-sucks';
-[ RECORD 1 ]-
st_isvalid | t

postgres@temp_geo=> select st_asText("geoPointLocation") from "Locations" where name = 'this-issue-sucks';
-[ RECORD 1 ]----------------------------
st_astext | POINT(-77.0365739 38.8976633)

postgres@temp_geo=> select "geoPointLocation" from "Locations" where name = 'this-issue-sucks';
-[ RECORD 1 ]----+---------------------------------------------------
geoPointLocation | 0101000020E6100000C7180E3A574253C0E3288AA1E6724340

标签: postgresqlsequelize.jsamazon-rdspostgis

解决方案


推荐阅读