fix placeholder surround and add complex test
[scpubgit/Q-Branch.git] / t / 15placeholders.t
index bba9b66..4ee0db8 100644 (file)
@@ -12,7 +12,7 @@ my $placeholders = ['station', 'lolz'];
       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 @@ my $placeholders = ['station', 'lolz'];
       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;