[Bast-commits] r9764 - in SQL-Abstract/1.x/trunk: lib/SQL/Abstract t
frew at dev.catalyst.perl.org
frew at dev.catalyst.perl.org
Fri Oct 15 00:31:47 GMT 2010
Author: frew
Date: 2010-10-15 00:31:47 +0000 (Fri, 15 Oct 2010)
New Revision: 9764
Modified:
SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm
SQL-Abstract/1.x/trunk/t/15placeholders.t
Log:
fix placeholder surround and add complex test
Modified: SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm
===================================================================
--- SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm 2010-10-12 00:30:50 UTC (rev 9763)
+++ SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm 2010-10-15 00:31:47 UTC (rev 9764)
@@ -367,11 +367,11 @@
my ($self, $bindargs) = @_;
if ($self->fill_in_placeholders) {
- my $val = pop @{$bindargs} || '';
+ my $val = shift @{$bindargs} || '';
my ($left, $right) = @{$self->placeholder_surround};
$val =~ s/\\/\\\\/g;
$val =~ s/'/\\'/g;
- return qq('$left$val$right')
+ return qq($left$val$right)
}
return '?'
}
Modified: SQL-Abstract/1.x/trunk/t/15placeholders.t
===================================================================
--- SQL-Abstract/1.x/trunk/t/15placeholders.t 2010-10-12 00:30:50 UTC (rev 9763)
+++ SQL-Abstract/1.x/trunk/t/15placeholders.t 2010-10-15 00:31:47 UTC (rev 9764)
@@ -12,7 +12,7 @@
placeholder_surround => [qw(; -)],
});
- is($sqlat->fill_in_placeholder($placeholders), q(';lolz-'),
+ is($sqlat->fill_in_placeholder($placeholders), q(;lolz-),
'placeholders are populated correctly'
);
}
@@ -23,9 +23,20 @@
placeholder_surround => [qw(< >)],
});
- is($sqlat->fill_in_placeholder($placeholders), q('<station>'),
+ is($sqlat->fill_in_placeholder($placeholders), q(<station>),
'placeholders are populated correctly and in order'
);
}
+
+{
+ my $sqlat = SQL::Abstract::Tree->new({
+ fill_in_placeholders => 1,
+ placeholder_surround => [qw(' ')],
+ });
+
+ is $sqlat->format('SELECT ? as x, ? as y FROM Foo WHERE t > ? and z IN (?, ?, ?) ', ['frew', 'ribasushi', '2008-12-12', 1, 2, 3]),
+ q[SELECT 'frew' as x, 'ribasushi' as y FROM Foo WHERE t > '2008-12-12' AND z IN ('1', '2', '3')], 'Complex placeholders work';
+}
+
done_testing;
More information about the Bast-commits
mailing list