OPENJPA-2355: Allow more than two input argument to CONCAT()

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1459091 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Pinaki Poddar 2013-03-20 22:52:18 +00:00
parent 085ea3eb07
commit e966f0f51c
3 changed files with 17 additions and 4 deletions

View File

@ -1297,11 +1297,22 @@ public class JPQLExpressionBuilder
return factory.trim(val1, trimChar, trimWhere);
case JJTCONCAT:
val1 = getValue(left(node));
val2 = getValue(right(node));
if (node.children.length < 2)
throw parseException(EX_USER, "less-child-count",
new Object[]{ Integer.valueOf(2), node,
Arrays.asList(node.children) }, null);
val1 = getValue(firstChild(node));
val2 = getValue(secondChild(node));
setImplicitType(val1, TYPE_STRING);
setImplicitType(val2, TYPE_STRING);
return factory.concat(val1, val2);
Value concat = factory.concat(val1, val2);
for (int i = 2; i < node.children.length; i++) {
val2 = getValue(node.children[i]);
setImplicitType(val2, TYPE_STRING);
concat = factory.concat(concat, val2);
}
return concat;
case JJTSUBSTRING:
// Literals are forced to be Integers because PostgreSQL rejects Longs in SUBSTRING parameters.

View File

@ -1195,7 +1195,7 @@ void functions_returning_strings() : { }
void concat() #CONCAT : { }
{
<CONCAT> "(" string_expression() <COMMA> string_expression() ")"
<CONCAT> "(" string_expression() <COMMA> string_expression() [ <COMMA> string_expression() ] ")"
}

View File

@ -40,6 +40,8 @@ unknown-comp: Unknown comparison operator "{0}".
wrong-child-count: Wrong number of arguments to expression \
of type "{1}": should have been {0}, but the following arguments \
were specified: "{2}".
less-child-count: Insufficient number of argument to expression \
of type "{1}": should have been at least {0}, but were: "{2}"
not-schema-name: The name "{0}" is not a recognized entity or identifier. \
Known entity names: {1}
not-schema-name-hint: The name "{0}" is not a recognized entity or identifier. \