Skip Menu |

This queue is for tickets about the Data-Phrasebook CPAN distribution.

Report information
The Basics
Id: 25089
Status: resolved
Priority: 0/
Queue: Data-Phrasebook

People
Owner: Nobody in particular
Requestors: JGONZALEZ [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.26
Fixed in: (no value)



Subject: Cannot change the default delimiter (Generic.pm)
Data:Phrasebook::Generic-0.26 I will attach the patch at a later date as I don't currently have it in front of me; however, the bug exists in Generic.pm. I found it version 0.26 recently while trying to set a date format using the TO_CHAR(<date>, <format>) function. SQL: select TO_CHAR(sysdate, 'yyyy-mm-dd hh:mi:ss') Description: The above SQL will cause Phrasebook to think that mi and ss are parameters that need to be passed in. I then tried to change the default delimiter to something less useful in SQL. I set the delimiter by doing $self->delimiter(regexp). This did not work because the default delimiter is then being overwritten with the value from Generic.pm Fix: The default delimiter is being set after the foreach loop. This resets the delimiter to a : instead of the chosen delimiter. The fix is simply to put this statement before the loop begins to iterate. This will cause the default to be used when no other delimiter is selected. sub new { my $class = shift; my %hash = @_; $hash{loader} ||= 'Text'; if($class->debug) { $class->store(3,"$class->new IN"); $class->store(4,"$class->new args=[".$class->dumper(\%hash)."]"); } my $self = bless {}, $class; $self->{delimiters} = qr{ :(\w+) }x; foreach (keys %hash) { $self->$_($hash{$_}); } # $self->{delimiters} = qr{ \[% \s* (\w+) \s* %\] }x; # $self->{delimiters} = qr{ :(\w+) }x; moved this single line above to # set the default delimiter before any custom delimiter requests. return $self; }
From: jgonz0010 [...] gmail.com
On Fri Feb 23 01:08:14 2007, jgonzalez wrote: Show quoted text
> Data:Phrasebook::Generic-0.26 > I will attach the patch at a later date as I don't currently have it in > front of me; however, the bug exists in Generic.pm. I found it version > 0.26 recently while trying to set a date format using the > TO_CHAR(<date>, <format>) function. > > SQL: > select TO_CHAR(sysdate, 'yyyy-mm-dd hh:mi:ss') > > Description: > The above SQL will cause Phrasebook to think that mi and ss are > parameters that need to be passed in. I then tried to change the default > delimiter to something less useful in SQL. I set the delimiter by doing > $self->delimiter(regexp). This did not work because the default > delimiter is then being overwritten with the value from Generic.pm > > Fix: > The default delimiter is being set after the foreach loop. This resets > the delimiter to a : instead of the chosen delimiter. The fix is simply > to put this statement before the loop begins to iterate. This will cause > the default to be used when no other delimiter is selected. > > sub new { > my $class = shift; > my %hash = @_; > $hash{loader} ||= 'Text'; > > if($class->debug) { > $class->store(3,"$class->new IN"); > $class->store(4,"$class->new > args=[".$class->dumper(\%hash)."]"); > } > > my $self = bless {}, $class; > $self->{delimiters} = qr{ :(\w+) }x; > foreach (keys %hash) { > $self->$_($hash{$_}); > } > # $self->{delimiters} = qr{ \[% \s* (\w+) \s* %\] }x; > # $self->{delimiters} = qr{ :(\w+) }x; moved this single line above to > # set the default delimiter before any custom delimiter requests. > > return $self; > }
Sorry for the delay, here is the diff as promissed.
Index: lib/Data/Phrasebook/Generic.pm =================================================================== --- lib/Data/Phrasebook/Generic.pm (revision 175740) +++ lib/Data/Phrasebook/Generic.pm (working copy) @@ -52,11 +52,14 @@ $class->store(4,"$class->new args=[".$class->dumper(\%hash)."]"); my $self = bless {}, $class; + $self->{delimiters} = qr{ :(\w+) }x; moved above the loop in foreach (keys %hash) { $self->$_($hash{$_}); } # $self->{delimiters} = qr{ \[% \s* (\w+) \s* %\] }x; - $self->{delimiters} = qr{ :(\w+) }x; +# $self->{delimiters} = qr{ :(\w+) }x; moved above the loop in +# order to be able to set a delimiter when desired. This was +# overwriting any delimieters with the default. return $self; }
Thanks for spotting my faux pas :) Fixed in 0.29