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