-
Notifications
You must be signed in to change notification settings - Fork 212
Improve Kotlin Where Clause DSL #442
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A null initial criterion could happen in Kotlin if a user forgets to code the initial condition. We don't need to force that behavior as the renderer can handle removal of an "and" or "or" if there is no preceding criterion.
Adding group and not as options to a where clause made the previous pattern virtually unreadable. This new collector is far better for expressing the intent of a where clause at the expense of loss of backwards compatibility
Previously the reusable where support exposed the supporting Java class directly
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements a significant improvement in the where clause DSL for Kotlin. Where clauses look far more natural and are very close to native SQL. In the prior version it was not always clear where the parentheses would be rendered. When we added support for groups and not in the where clause, the Kotlin code became virtually unreadable. This PR resolves that issue.
The old DSL remains, but it is deprecated and will be removed in version 1.5.0. With this PR, group and not support is only implemented in the new DSL. There is a new documentation page that explains the new usage here: https://github.com/mybatis/mybatis-dynamic-sql/blob/master/src/site/markdown/docs/kotlinWhereClauses.md