[Dbix-class] Get generated SQL

Mark Lawrence nomad at null.net
Wed Mar 12 15:15:49 GMT 2008


On Wed Mar 12, 2008 at 12:30:14PM +0000, Matt Lawrence wrote:
> Mark Lawrence wrote:
> >
> >You don't deal with binary (non-printable) data. Assuming this is method
> >is for debugging purposes its usefulness is limited to pure text and
> >won't work for mixed text/binary queries.
> >  
> 
> Specifying the data type for the bind columns should allow the driver to 
> properly escape binary data where appropriate, albeit non-automatically.

Yes, the escaping would make the data safe/suitable for the database,
but that won't change the effects that binary data has on terminals.

> Are there any circumstances where unprintable values would be wanted anyway?

Not that I can think of. I find the main issue is that binary data
basically screws the debugging process when you try and print it.

> I guess I could add a failsafe to trap unprintable values still present 
> after quote() and replace them with dummy values as in your previous 
> example.
> 
>    # Store quoted versions of the values
>    my @bind_vals = map {
>        $_ = $storage->dbh->quote($_->[1], shift @$datatypes);
>        $_ = $storage->dbh->quote('*BINARY DATA*') if /[^[:print:]\n\t]/;
>        $_;
>    } @$bind;
> 

You don't need to care about newlines or tabs (in fact if you
specifically search for that you might not find what you are looking
for), you just want to know if it contains non-printable data:

   $_ = $storage->dbh->quote('*BINARY DATA*') if /[^[:print:]]/;

Mark.
-- 
Mark Lawrence



More information about the DBIx-Class mailing list