From: <sha...@us...> - 2011-11-16 13:10:20
|
Revision: 15545 http://exist.svn.sourceforge.net/exist/?rev=15545&view=rev Author: shabanovd Date: 2011-11-16 13:10:14 +0000 (Wed, 16 Nov 2011) Log Message: ----------- [bugfix] For each pre-grouping tuple, the grouping keys are created by atomizing the values of the grouping variables. If the resulting value for any grouping variable consists of more than one item, a dynamic error is raised [err:XPTY0004]. Note: The atomized grouping key will always be either an empty sequence or a single atomic value. Modified Paths: -------------- trunk/eXist/src/org/exist/xquery/value/GroupedValueSequenceTable.java Modified: trunk/eXist/src/org/exist/xquery/value/GroupedValueSequenceTable.java =================================================================== --- trunk/eXist/src/org/exist/xquery/value/GroupedValueSequenceTable.java 2011-11-16 13:07:07 UTC (rev 15544) +++ trunk/eXist/src/org/exist/xquery/value/GroupedValueSequenceTable.java 2011-11-16 13:10:14 UTC (rev 15545) @@ -25,6 +25,7 @@ import java.util.Hashtable; import java.util.Iterator; +import org.exist.xquery.ErrorCodes; import org.exist.xquery.GroupSpec; import org.exist.xquery.XPathException; import org.exist.xquery.XQueryContext; @@ -82,9 +83,14 @@ for (int i = 0; i < groupSpecs.length; i++) { // evaluates the values of the grouping keys - specEvaluation[i] = groupSpecs[i].getGroupExpression().eval( - item.toSequence()); // TODO : too early evaluation ! - keySequence.add(specEvaluation[i].itemAt(0)); + specEvaluation[i] = groupSpecs[i].getGroupExpression().eval(item.toSequence()); // TODO : too early evaluation ! + + if (specEvaluation[i].isEmpty()) + keySequence.add(AtomicValue.EMPTY_VALUE); + else if (specEvaluation[i].hasOne()) + keySequence.add(specEvaluation[i].itemAt(0)); + else + throw new XPathException(groupSpecs[i].getGroupExpression(), ErrorCodes.XPTY0004, "More that one key values", specEvaluation[i]); } String hashKey = keySequence.getHashKey(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |