Closed spring-projects-issues closed 12 years ago
Dave Syer commented
Spring Integration also would like to see this change: named parameter support is used in the JDBC adapters, and it is combined with SpEL so that the parameter name can be an expression. Unfortunately a large class of SpEL expressions are not parsed correctly as parameter names by NamedParameterUtils and ':{...}' would actually work perfectly.
Daniel Boulerice opened SPR-7476 and commented
There seems to be a problem with the JDBC parameter replacement. The existing mechanism searches for names in a prototype string, find pemeter placeholders, and attempts to fill them. The problem is that it does not allow to generate any sort of string. In particular, colons pose problems.
I want to insert legitimate colons in an SQL without incurring name replacement.
For example (MySQL): WHERE m.name REGEXP '[0-9][:alnum:]*' (asks me for parameter 'alnum') For example (MySQL): WHERE x.created_on BETWEEN Date(:p1) AND DATE(:p2 23:59:59) (asks me for parameter '59')
In the prototype string, I want to escape colons using a backslash. The former strategy of letting two colons go through is insufficient (issue #9289). I want to write " WHERE m.name REGEXP '[0-9][\:alnum\:]*'" and not be asked for 'alnum'.
In addition, the current process does not delimit parameter names. Suppose I have a field names like 'Line0Top', 'Line1Top', 'Line2Top' and I want to select them syntetically. I would use a prototype SQL like "SELECT Line:NumTop" expecting to be asked for parameter 'Num' and having to replace it by 0 1 or 2. But the current stategy will ask me for parameter 'NumTop'.
So can we also have a delimited escape sequence using ':{' and '}' like in the Bourne shell, TK scripts, JSLT etc. E.g. "SELECT Line:{Num}Top".
That would really be nice!
Affects: 3.0.2
Reference URL: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/jdbc.html#jdbc-NamedParameterJdbcTemplate
1 votes, 2 watchers