The following query runs fine from directly within psql:
psql
SELECT i.* AS id, array_agg(c.category) AS categories FROM inventory i LEFT OUTER JOIN invento