make _table use expand/render code
[scpubgit/Q-Branch.git] / t / 15placeholders.t
CommitLineData
9d11f0d4 1use strict;
2use warnings;
3
4use Test::More;
5use SQL::Abstract::Tree;
6
9d11f0d4 7{
8 my $sqlat = SQL::Abstract::Tree->new({
9 fill_in_placeholders => 1,
10 placeholder_surround => [qw(; -)],
11 });
12
e4570c8e 13 is($sqlat->fill_in_placeholder(['lolz']), q(;lolz-),
9d11f0d4 14 'placeholders are populated correctly'
15 );
16}
17
18{
19 my $sqlat = SQL::Abstract::Tree->new({
20 fill_in_placeholders => 1,
21 placeholder_surround => [qw(< >)],
22 });
23
e4570c8e 24 is($sqlat->fill_in_placeholder(['station']), q(<station>),
9d11f0d4 25 'placeholders are populated correctly and in order'
26 );
27}
28
ad46269d 29
30{
31 my $sqlat = SQL::Abstract::Tree->new({
32 fill_in_placeholders => 1,
33 placeholder_surround => [qw(' ')],
34 });
35
6c4d8eb8 36 is $sqlat->format('SELECT ? AS x, ? AS y FROM Foo WHERE t > ? and z IN (?, ?, ?) ', [qw/frew ribasushi 2008-12-12 1 2 3/]),
37 q[SELECT 'frew' AS x, 'ribasushi' AS y FROM Foo WHERE t > '2008-12-12' AND z IN ( '1', '2', '3' )], 'Complex placeholders work';
ad46269d 38}
39
9d11f0d4 40done_testing;