Skip to content
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

Prevent Non-Rendering Where Clauses by Default #515

Merged
merged 25 commits into from Aug 25, 2022

Conversation

jeffgbutler
Copy link
Member

Potentially Breaking Change

Most of the conditions in a where clause support optionality - meaning they may or may not render based on their values at runtime. If all conditions drop out of a where clause, then the entire where clause may be dropped from rendered SQL. This presents a danger in that a statement may inadvertently impact all rows in a table (for example, all rows could be deleted).

Out of an abundance of caution, this PR changes the default behavior pf the library. If a where clause is coded in a statement, but the where clause doesn't render, the library will now throw a NonRenderingWhereClauseException. This default behavior can be overridden globally, or on each individual statement.

If this new behavior is acceptable, then no code changes are required. If you would like to allow a statement to be rendered even if the where clause will be dropped, then you must either change the global configuration of the library, or change the configuration of the statement through the DSL. Configuration options are documented on the "Configuration of the Library" page.

This is related to #509

@coveralls
Copy link

coveralls commented Aug 25, 2022

Coverage Status

Coverage remained the same at 100.0% when pulling 21e45e7 on jeffgbutler:statement-configuration into 1a51903 on mybatis:master.

@jeffgbutler jeffgbutler merged commit c9e3801 into mybatis:master Aug 25, 2022
@jeffgbutler jeffgbutler deleted the statement-configuration branch August 25, 2022 15:42
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.

None yet

2 participants