[ https://issues.apache.org/jira/browse/COCOON-1740?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jörg Heinicke updated COCOON-1740: ---------------------------------- Status: Continued (was: On Hold) Missing test case isn't really a reason for on hold. > Modular DatabaseSelectAction incorrectly handles multiple rows > -------------------------------------------------------------- > > Key: COCOON-1740 > URL: https://issues.apache.org/jira/browse/COCOON-1740 > Project: Cocoon > Issue Type: Bug > Components: Blocks: Databases > Affects Versions: 2.1.8, 2.1.9, 2.2 > Reporter: Tuomo Lesonen > Priority: Minor > Attachments: 20060310-cocoon-databases, 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. - You can reply to this email to add a comment to the issue online.