-
Notifications
You must be signed in to change notification settings - Fork 212
when i use isIn(emptyList) where condition, it would not render to sql #228
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
I don't agree this is a bug - I think it is actually a good thing that the library won't generate invalid SQL. I think it would be best to check to see if the list is empty before trying to execute the statement. If it is a possibility in your app that the list could be empty, then do you really want to rely on causing a database exception as a kind of validation? Honestly it wouldn't be too hard to provide an option to render these conditions even when they are empty. But I'm not convinced that is a good idea. Thoughts??? |
if i want ignore invalid condition, i will use |
there is two method do same thing with diff name, may be there should has one method named |
|
with 1.3.7 generator, i use Example, when i use |
there is a problem, when i build sql with not valid param, it where change more data than what i want it modify, |
I get it. I really do think you should be validating, but I understand it could be a change to how you're working now and not doing it would cause undesirable side effects. I've been experimenting a bit. I can enable you to write a condition that will force the exception with a very simple code change. I'll push something to address this shortly. |
This will enable the list conditions to render invalid SQL, so it should be used with caution. But it will make transition from some legacy code bases easier. Resolves mybatis#228
Thanks for understanding |
Here is 4:00am, I will try it when I waked up. |
Add Ability to Write "in" Conditions that will render even when the list of value is empty
See documentation here: https://github.com/mybatis/mybatis-dynamic-sql/blob/master/src/site/markdown/docs/conditions.md#optionality-with-the-in-conditions I will release the new version in the next few days. |
i code like this
to fix my codes now. ur idea is so good, I don't try to expland where codition before, |
@clcy1243 I like your solution a lot! This is much better than forcing the library to generate invalid SQL. I'm going to remove the change I made and use your example in the docs. |
I would like to view this as a bug. |
@zhenchuan9r If you have found a bug, please open a new issue. It is ineffective to comment on an issue that has been closed for three years. |
I encountered the same problem as this issue. |
code example
will render like this
it should be like
and mysql where throw exception when execute this sql, it's what my want,
so i think there is a bug,
i found this code at
org.mybatis.dynamic.sql.where.render.WhereConditionVisitor<T>
if list value condition accept an empty list, fc.isEmpty() will be true, this condition where be deleted
could anyone fix this?
The text was updated successfully, but these errors were encountered: