You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Mark B (JIRA)" <ji...@apache.org> on 2009/09/02 13:58:33 UTC

[jira] Updated: (DERBY-3676) Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far

     [ https://issues.apache.org/jira/browse/DERBY-3676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark B updated DERBY-3676:
--------------------------

    Attachment: humanstringprepared.txt

Hi I noticed the request is marked as suitable for a newbie so I've made a preliminary patch;

I'd make these comments
1 I tend to feel that the idea of making the toString() method return the sql, then documenting a change so that a new method, let's say idString() returned the original toString() id, is more appropriate
2 as currently written, there is no checking for thread-safety
3 a quoted '?' in the PreparedStatement would be replaced, so the replacement routine should be improved
4 I should add client-side / api functionality, as well as Embedded

currently it works as suggested in a cast to ((EmbedPreparedStatement) ps).toHumanString()

I'm just posting the patch for comments / to avoid duplication of work so people notice I'm working at it

> Make the toString() method of Derby PreparedStatements print out SQL text with ? parameters replaced by the values that have been set so far
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3676
>                 URL: https://issues.apache.org/jira/browse/DERBY-3676
>             Project: Derby
>          Issue Type: Improvement
>          Components: JDBC
>            Reporter: Rick Hillegas
>         Attachments: humanstringprepared.txt, ick.txt, ick.txt
>
>
> This topic came up in the following email thread on the user list: http://www.nabble.com/PreparedStatement.toString%28%29---nice-formatting-td17250811.html#a17250811 Here's what the thread requests: 
> "In mysql, a toString() on a PreparedStatement will do this, eg "select x
> from foo where x.a = ?" will become "select x from foo where x.a = 1" with
> the appropriate setValue() call."
> At first blush, this seems like it might be a simple project for a newcomer.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.