Hi, I’m writing an DB application in Crystal and got stuck at providing an array as parameter to a query:
db.query "SELECT ... FROM ... WHERE x IN (?)", my_array
It seems that it is not supported. As an alternative, does Crystal DB API expose functionality for escaping parameters so that I can prepare the query manually?
I’m not sure if the base drivers support such a features (Bind an array to a parameter in prepared statement).
I found a workaround, though. I dynamically generate the query with the number of ‘?’ equal to the number of arguments in the array. Not very beautiful but works.
I as said, I’m dynamically generating the query to contain as many comma-joined '?'s in the “IN” part as the needed.
On the other hand a routine for DB-escaping a string would be quite useful in the more general context.