Skip to content

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 15 commits into from
Feb 1, 2022

Conversation

jeffgbutler
Copy link
Member

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

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
@jeffgbutler jeffgbutler added this to the 1.4.0 milestone Feb 1, 2022
@coveralls
Copy link

coveralls commented Feb 1, 2022

Coverage Status

Coverage remained the same at 100.0% when pulling 96a1b72 on jeffgbutler:update-kotlin-dsl into cf62191 on mybatis:master.

@jeffgbutler jeffgbutler merged commit a67f75a into mybatis:master Feb 1, 2022
@jeffgbutler jeffgbutler deleted the update-kotlin-dsl branch February 1, 2022 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants