[ http://issues.apache.org/jira/browse/COCOON-1740?page=comments#action_12367225 ]
Jean-Baptiste Quenot commented on COCOON-1740: ---------------------------------------------- Can you please provide a *patch*, obtained using "svn diff" against a recent checkout of branch 2.1? That will help to fix this bug in a timely manner. Thanks in advance! > Modular DatabaseSelectAction incorrectly handles multiple rows > -------------------------------------------------------------- > > Key: COCOON-1740 > URL: http://issues.apache.org/jira/browse/COCOON-1740 > Project: Cocoon > Type: Bug > Components: Blocks: Databases > Versions: 2.1.8, 2.2-dev (Current SVN), 2.1.9-dev (current SVN) > Reporter: Tuomo Lesonen > Assignee: Jean-Baptiste Quenot > Priority: Minor > Attachments: DatabaseAction.java, DatabaseSelectAction.java > > When one needs to select multiple rows from a table, and the keys used to > identify the rows vary, for example when request-param inputmodule is used > with parameter-value of "id[*]", the outputted parameters are not unique. > For example, when there are 3 different variations of the keys, and every > variation returns a single row, the following is outputted: > ==> row #0 > o.a.c.components.modules.output.OutputModule:user.id[0] > o.a.c.components.modules.output.OutputModule:user.username[0] > o.a.c.components.modules.output.OutputModule:user.password[0] > ==> row #1 > o.a.c.components.modules.output.OutputModule:user.id[1] > o.a.c.components.modules.output.OutputModule:user.username[0] > o.a.c.components.modules.output.OutputModule:user.password[0] > ==> row #2 > o.a.c.components.modules.output.OutputModule:user.id[2] > o.a.c.components.modules.output.OutputModule:user.username[0] > o.a.c.components.modules.output.OutputModule:user.password[0] > What happens is that on every row the names of the previous output-parameters > from the value-fields (in descriptor) are overwritten with the new names, > since the index is always forced back to zero. > Because of this, the values from matching rows cannot be "forwarded" to other > actions for additional processing (ie. DatabaseDeleteAction). > The correct output should be: > ==> row #0 > o.a.c.components.modules.output.OutputModule:user.id[0] > o.a.c.components.modules.output.OutputModule:user.username[0] > o.a.c.components.modules.output.OutputModule:user.password[0] > ==> row #1 > o.a.c.components.modules.output.OutputModule:user.id[1] > o.a.c.components.modules.output.OutputModule:user.username[1] > o.a.c.components.modules.output.OutputModule:user.password[1] > ==> row #2 > o.a.c.components.modules.output.OutputModule:user.id[2] > o.a.c.components.modules.output.OutputModule:user.username[2] > o.a.c.components.modules.output.OutputModule:user.password[2] > The only way this output can be achieved is when the keys do not vary, and > multiple rows are returned. But this is not always the case, as the example > above demonstrates. > Here's the descriptor-snippet from the previous example: > <table name="user"> > <keys> > <key name="id" type="int" set="master"> > <mode name="request-param" parameter="id*" type="all"/> > </key> > </keys> > <values> > <value name="username" type="string"/> > <value name="password" type="string"/> > </values> > </table> > I have fixed this by adding a class variable "sumIndex" to > DatabaseAction.java, which is incremented in DatabaseSelectAction.java in > method "processRow". sumIndex is then used to produce unique names for the > output-parameters. Finally sumIndex contains the total rows selected. > Patched files (2) attached. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
