You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by "Jean-Baptiste Quenot (JIRA)" <ji...@apache.org> on 2006/07/19 23:37:15 UTC

[jira] Assigned: (COCOON-1740) Modular DatabaseSelectAction incorrectly handles multiple rows

     [ http://issues.apache.org/jira/browse/COCOON-1740?page=all ]

Jean-Baptiste Quenot reassigned COCOON-1740:
--------------------------------------------

    Assignee:     (was: Jean-Baptiste Quenot)

> Modular DatabaseSelectAction incorrectly handles multiple rows
> --------------------------------------------------------------
>
>                 Key: COCOON-1740
>                 URL: http://issues.apache.org/jira/browse/COCOON-1740
>             Project: Cocoon
>          Issue Type: Bug
>          Components: Blocks: Databases
>    Affects Versions: 2.1.8, 2.2-dev (Current SVN), 2.1.9
>            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.
-
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