Skip to content

Commit e8876ad

Browse files
committed
Update docs
1 parent 5a68a75 commit e8876ad

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

CHANGELOG.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ but fails to render because all the optional conditionals drop out of the where
1313
throw a `NonRenderingWhereClauseException`. We have made this change out of an abundance of caution. The prior
1414
behavior would allow generation of statements that inadvertently affected all rows in a table.
1515

16-
Because of this change, we have also deprecated the "empty callback" functions in the "in" conditions.
16+
We have also deprecated the "empty callback" functions in the "in" conditions in favor of this new configuration
17+
strategy. The "empty callback" methods were effective for "in" conditions that failed to render, but they offered
18+
no help for other conditions that failed to render, or if all conditions fail to render - which is arguably a more
19+
dangerous outcome. If you were using any of these methods, you should remove the calls to those methods and catch the
20+
new `NonRenderingWhereClauseException`.
1721

1822
If you desire the prior behavior where non rendering where clauses are allowed, you can change the global configuration
1923
of the library or - even better - change the configuration of individual statements where this behavior should be allowed.
@@ -32,8 +36,8 @@ For examples of global and statement configuration, see the "Configuration of th
3236
accurately represent the nullable/non-nullable expectations for API method calls.
3337
([#496](https://github.com/mybatis/mybatis-dynamic-sql/pull/496))
3438
4. Added the ability to configure the library and change some default behaviors. Currently, this is limited to changing
35-
the behavior of the library in regard to where clauses that will not render. See the new configuration page for
36-
details.
39+
the behavior of the library in regard to where clauses that will not render. See the "Configuration of the Library"
40+
page for details.
3741

3842
## Release 1.4.0 - March 3, 2022
3943

src/site/markdown/docs/configuration.md

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Configuration of the Library
22

3-
Most behaviors of MyBatis Dynamic SQL are not configurable - the library does what it does.
4-
This page will detail the behaviors that can be modified. Configuration is available with version 1.4.1 and later
5-
of the library.
3+
This page will detail the behaviors of MyBatis Dynamic SQL that can be modified.
4+
Configuration is available with version 1.4.1 and later of the library.
65

76
The library can be configured globally - which will change the behavior for all statements - or each individual statement
87
can be configured. There are sensible defaults for all configuration values, so configuration is not strictly necessary.
@@ -12,12 +11,11 @@ Prior to version 1.4.1 of the library, there was no configurable behavior in the
1211
the default behavior of the library to throw an exception if a where clause fails to render. We did this out of an
1312
abundance of caution because the optional conditions in a where clause could lead to a statement that affected all
1413
rows in a table (for example, a delete statement could inadvertently delete all rows in a table). If you want the library
15-
to function as it did before version 1.4.1 where it was acceptable to have a where clause that didn't render, then you
16-
can change the global configuration as shown below.
14+
to function as it did before version 1.4.1 , then you can change the global configuration as shown below.
1715

1816
## Global Configuration
1917

20-
On first use the library will initialize the global configuration. The global configuration can be changed via a property
18+
On first use the library will initialize the global configuration. The global configuration can be specified via a property
2119
file named `mybatis-dynamic-sql.properties` in the root of the classpath. If you wish to use a different file name,
2220
you can specify the file name as a JVM property named `mybatis-dynamic-sql.configurationFile`. Note that the global
2321
configuration is created one time and shared for every statement in the same JVM.
@@ -26,9 +24,9 @@ The configuration file is a standard Java properties file. The possible values a
2624

2725
## Global Configuration Properties
2826

29-
| Property | Default | Meaning |
30-
|--------------------------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
31-
| nonRenderingWhereClauseAllowed | false | If a where clause is specified, but fails to render, then the library will throw a `NonRenderingWhereClauseException` by default. If you set this value to true, then no exception will be thrown. This could cause statements to be rendered without where clauses that affect all rows in a table. |
27+
| Property | Default | Meaning |
28+
|--------------------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
29+
| nonRenderingWhereClauseAllowed | false | If a where clause is specified, but fails to render, then the library will throw a `NonRenderingWhereClauseException` by default. If you set this value to true, then no exception will be thrown. This could enable statements to be rendered without where clauses that affect all rows in a table. |
3230

3331
## Statement Configuration
3432

@@ -37,13 +35,13 @@ DSL. Consider the following statement:
3735

3836
```java
3937
DeleteStatementProvider deleteStatement = deleteFrom(animalData)
40-
.where(id, isNotIn(null, 22, null).filter(Objects::nonNull).filter(i -> i != 22))
38+
.where(id, isIn(null, 22, null).filter(Objects::nonNull).filter(i -> i != 22))
4139
.configureStatement(c -> c.setNonRenderingWhereClauseAllowed(true))
4240
.build()
4341
.render(RenderingStrategies.MYBATIS3);
4442
```
4543

46-
In this case, the `isNotIn` condition has filters that will remove all values from the condition. In that case, the
44+
In this case, the `isIn` condition has filters that will remove all values from the condition. In that case, the
4745
condition will not render and, subsequently, the where clause will not render. This means that the generated delete
4846
statement would delete all rows in the table. By default, the global configuration will block this statement from
4947
rendering and throw a `NonRenderingWhereClauseException`. If for some reason you would like to allow a statement
@@ -53,7 +51,7 @@ The Kotlin DSL contains the same function:
5351

5452
```kotlin
5553
val deleteStatement = deleteFrom(person) {
56-
where { id isNotEqualToWhenPresent null }
54+
where { id isEqualToWhenPresent null }
5755
configureStatement { isNonRenderingWhereClauseAllowed = true }
5856
}
5957
```

0 commit comments

Comments
 (0)