I had actually already tackled this in 6.0. What I have there so far is:
public enum QueryLiteralRendering {
/**
* Always render as a SQL literal, never a parameter
*/
AS_LITERAL( "literal" ),
/**
* Always as a parameter, never as a literal
*/
AS_PARAM( "param" ),
/**
* As a parameter when the literal occurs outside the SELECT clause,
* otherwise render as a SQL literal.
*/
AS_PARAM_OUTSIDE_SELECT( "param-outside-select" );
...
}
We can add your AUTO here I guess, although I am not sure of the usefulness of it. The special AS_PARAM_OUTSIDE_SELECT is to account for databases (DB2 for sure) that do not like parameters in the SELECT clause. In such cases we have 2 options:
- render the literal directly.
- render as a param, but wrap in a cast
We could also offer that as a distinction: AS_PARAM_OUTSIDE_SELECT + AS_PARAM_WRAPPED_IN_SELECT. Or alternatively we could simply interpret AS_PARAM + Dialect#requiresCastingOfParametersInSelectClause == true as "AS_PARAM_WRAPPED_IN_SELECT". I think the second option is the best option. |