Postgres CTE : type character varying(255)[] in non-recursive term but type character varying[] overall

杀马特。学长 韩版系。学妹 提交于 2019-12-04 03:08:34

Try casting the SELECT lists in the recursive and non-recursive terms to varchar.

WITH RECURSIVE search_graph(path, last_profile1, last_profile2) AS (
    SELECT ARRAY[id]::varchar[], id::varchar, id::varchar
    FROM node WHERE id = '408d6b12-d03e-42c2-a2a7-066b3c060a0b'
  UNION ALL
    SELECT (sg.path || m.toid || m.fromid)::varchar[], m.fromid::varchar, m.toid::varchar
    FROM search_graph sg
    JOIN rel m
    ON (m.fromid = sg.last_profile2 AND NOT sg.path @> ARRAY[m.toid]) 
       OR (m.toid = sg.last_profile1 AND NOT sg.path @> ARRAY[m.fromid])
)
SELECT DISTINCT unnest(path) FROM search_graph;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!