这让我发疯了。以下查询在本地完全正常,但是当我在travis-ci上测试并抛出错误时失败:
java.lang.RuntimeException: org.postgresql.util.PSQLException: ERROR: syntax error at or near "select"
Position: 39
希望有人可以看到我无法看到的东西。
以下是我的表格:
+----------+---------------+
| ways |
+----------+---------------+
| way_id | bigint |
| node_ids | bigint array |
| rep_lat | float(9) |
| rep_lon | float(9) |
+----------+---------------+
+---------+-----------+
| nodes |
+---------+-----------+
| node_id | bigint |
| lat | float(9) |
| lon | float(9) |
+---------+-----------+
这是我的问题:
update ways
set (rep_lat, rep_lon) =
(
select lat, lon
from nodes
where nodes.node_id = ways.node_ids[array_length(ways.node_ids, 1)/2]
)
答案 0 :(得分:0)
奇怪,无论出于何种原因,这种格式是可以接受的:
UPDATE ways
SET rep_lat=subq.lat, rep_lon=subq.lon
FROM (SELECT lat, lon, node_id FROM nodes) as subq
WHERE subq.node_id = ways.node_ids[array_length(ways.node_ids, 1)/2]