IN condition with select option returns a subset of rows

I've a "weird" issue with a select option and a query.

This is the use case.
I've three products:

  • Product A, category path Bag, category id 1, categories ids for filter 1, 2,3
  • Product B, category path Bag/Backpack, category id 2, categories ids for filter 2
  • Product C, category path Bag/Belt Bags, category id 3, categories ids for filter 3

I'm filtering the products through a select option.
What I need to do is that if you select Bag, the query returns also the products having a subcategory of Bag.
For this, I've added the "categories ids for filter" in order to have all the ids to be used in the query condition.

  WHEN {{select_Subcategory.selectedItems.length > 0 }} THEN p.category_id IN ( {{select_Subcategory.selectedItems.length > 0 ? select_Subcategory.value : 'NULL'}})
  WHEN {{select_Subcategory.selectedItems.length == 0 }} THEN TRUE

The generated query seems ok, so it prints all the IDS in the IN condition, but the it returns only the first product.
The same query executed with an sql client returns all the three products.

Is there anything that I'm missing?

I think that the issue is that select_Subcategory.value get value "1,2,3" and this lead to consider only 1.

It works with select_Subcategory.value['0'].split(",") but since it's a multiselect I can't use 0.

Edit: it seems working with JSON.parse("[" + select_Subcategory.value + "]")