-
Notifications
You must be signed in to change notification settings - Fork 212
Render in(emptyList) and notIn(emptyList) more reasonably #752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Rendering an empty list to What I would prefer is adding a configuration setting that would render empty lists as So your example above would render to this: update tableName set enabled = 0 where enabled = 1 and id in () What do you think? |
I think it is good. It is indeed a good thing that the library won't generate invalid SQL, but sometimes we have to make some compromises... |
Consider setting the default value of I believe that when encountering an empty list, Mybatis example also throws an exception. Throwing an exception allows us to find errors in the code before going live, rather than finding the bug after data has been wrongly modified or deleted. BTW, this issue caused us to accidentally delete thousands of records in the production environment (now fixed). It took us half a day to identify this problem, and it's really easy to overlook. |
I'm open to this idea, but it would probably break some existing code. I'd like to get some community feedback before proceeding. Please make a new issue with this request and let's see if there are any comments from other users. |
I have read through the previously published issues: #228 and #509, and I strongly agree with jesusslim's idea.
In my understanding, the configuration
nonRenderingWhereClauseAllowed
only takes effect when there are no where conditions at all. When I use logical deletion, there will definitely be a where condition present. However, using in(emptyList) will modify all data, which is a very dangerous operation.I'm thinking, if the condition is
isIn(emptyList)
, can it be render tofalse
? Similarly,isNotIn(emptyList)
can be render totrue
. This ensures both the syntax and semantics of SQL.The text was updated successfully, but these errors were encountered: