I am changing a db function and I need to add a query for items matching their category id with any items from an array i give.
Example input:
let categories = ['10272111', '165796011', '3760911', '9223372036854776000','3760901','7141123011']
Part of db function:
(case when brand is null then '' else 'AND ra.brand ILIKE ''%%'||brand||'%%''' end),
(case when category is null then '' else 'AND ra.root_category IN ('||category||')' end),
(case when asin is null then '' else 'AND ra.asin ILIKE ''%%'||asin||'%%''' end),
But I keep getting malformed array literal: "AND ra.root_category IN (" error and I can't find any resource for the right syntax.
Edit:
This is the definition at the top of the function:
category text[] DEFAULT NULL::text[],