Description
It's been posted here two years ago. But I don't think isInRequired
or withListEmptyCallback
is a good solution.Because if we can remember to use isInRequired
,of course we can also remember to check empty list before isIn
.
I can understand that you never want to build invalid sql, but in my opinion, once we use isIn
, whatever param we pass, you should never change our sql, we don't want fixing, if you think our sql is invalid just throw exception, not change it to another wrong sql.
If we pass empty list, the sql should be in ()
,you can't change it to query full table, because it will be a disaster in production if we have a table with big data, there will be lots of slow queries. And if we use it in delete
, it will delete all rows, it's a real disaster because you changed our sql wrong for "valid sql".
And for most programmers, they don't know this issue, so every time in code review, we have to take time to check if they have checked empty list or not before isIn
.And it's like a time bomb if someone forget to check empty list before use isIn.
I think it will be a good solution if there is a config setting to decision throw exception or query full table when isIn empty list.