Open sbscan opened 1 year ago
That's the expected behavior : array permits sending multiple values. Example :
await conn.query('CREATE TABLE namedPlaceholders1(t varchar(128))');
await conn.query("INSERT INTO `namedPlaceholders1` value ('a'), ('b'), ('c')");
const res = await conn.query('select * from `namedPlaceholders1` where t IN (:possible)', { possible: ['a', 'c'] });`
// res = [{ t: 'a' }, { t: 'c' }]
if your behavior is explicitly to have a string list, then, yes toString is the way to go.
When using namedPlaceholders if we use array parameters it sterilize array without quotes. My parameter is an array like role => ["Admin","Accounting"] When I use it as a namedPlaceholder in an insert statement the resulting SQL is: 'role': Admin,Teklif Which should be: 'role': 'Admin,Teklif' So ends with an SQL error. Quick fix is using toString and convert array to string.