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;
}