@@ -56,3 +56,32 @@ val deleteStatement = deleteFrom(person) {
5656}
5757```
5858
59+ ## Configuration Scope with Select Statements
60+
61+ Select statements can stand alone, or they can be embedded within other statements. For example, the library supports
62+ writing insert statements with an embedded select, or select statements that contain other select statements for sub
63+ queries. The select DSLs (both Java and Kotlin) appear to allow you to specify statement configuration on embedded
64+ select statements, but this is not supported in point of fact. Statement configuration must ALWAYS be specified on the
65+ outermost statement. Any configuration specified on embedded select statements will be ignored. We realize this could be
66+ confusing! But we've made this decision hoping to minimize code duplication and maximize consistency.
67+
68+ So the best practice is to ALWAYS specify the statement configuration as the LAST call to the DSL before calling
69+ ` build ` , or before ending a Kotlin lambda.
70+
71+ The following Kotlin code snippet shows this in action...
72+
73+ ``` kotlin
74+ val insertStatement = insertSelect {
75+ into(person)
76+ select(id, firstName, lastName, birthDate, employed, occupation, addressId) {
77+ from(person)
78+ where { id isGreaterThanOrEqualToWhenPresent null }
79+ // the following will be ignored in favor of the enclosing statement configuration...
80+ configureStatement { isNonRenderingWhereClauseAllowed = false }
81+ }
82+ configureStatement { isNonRenderingWhereClauseAllowed = true }
83+ }
84+ ```
85+
86+ The inner ` configureStatement ` call will be ignored in this case, only the ` configureStatement ` call scoped to the
87+ insert statement itself will be in effect.
0 commit comments