On Fri, Apr 20, 2018 at 9:22 AM, W. Trevor King <wking@tremily.us> wrote:
format(' WITH RECURSIVE _ancestors(id, ancestors) AS ( SELECT item.id AS id, ARRAY[item.ancestor_id] AS ancestors FROM items AS item %s
[...]
', condition);
SELECT * FROM ancestors('WHERE item.id = 62324721');
Just keep in mind that this opens up a huge SQL-injection hole in your database. Depending on how its called you might want to validation the input text for both whitelist and blacklist items before executing it.