I think the problem is with parameter binding. I had a similar problem when trying to register a function for DATE_ADD with SQL Server. Here is my method:
registerFunction("addminutes", new TestSqlFunctionTemplate(TimeMillisType.INSTANCE, "DATEADD(MINUTE, ?2, ?1)"));
After going through the source code for TemplateRenderer, I found that the problem is how the SQL string is rendered. The rendering function is passed a list of arguments to send, but since the parameters are bound, a list of "?" Strings indicating the associated parameter. The output for the render function when using a query with related parameters in my example:
DATEADD(MINUTE, ?, ?)
This does not indicate order. I am looking for an alternative solution, but at the moment I have not seen anything yet.
source share