Because the array is a text string and cid is an integer primary key. If I don't re-cast the cid then it doesn't work and I get a malformed array error.
Yes I figured as much - I think the String can be modified by using JSON.parse...(maybe) but check out this post as it seems similar in that the result the user was getting from AI was a string (which yours seems to be instead of an Array) - if you can get the Array properly formatted you won't have to change the cid integer to text
ScottR, you are indeed a 'steely-eyed missile man'.
For the sake of any other poor soul that finds this post I will endeavor to explain how I implemented your wisdom.
My use case involved creating an 'op' string in an onscreen table, with multiple row select enabled, that looked very much like an array (the values are the integer primary keys within a data table):
I needed to extract the records selected by the operator in the table using the 'IN' or '= ANY' sql functions. The two screenshots below should be self explanatory. Interestingly Retool warns that 'IN' may not work and recommends '= ANY' instead, and thus it proved to be...