Add new tests for unused numeric macros and the rownum macro in t/Macro/SQL.t

Document how unused numeric macros are handled in the SQL macro and that rownum
starts counting at 1.
Quote entries in the related section to make detecting spaces in names easier.
This commit is contained in:
Colin Kuskie 2006-07-04 04:14:20 +00:00
parent 122b59019c
commit 553f1e0c4a
3 changed files with 16 additions and 3 deletions

View file

@ -15,13 +15,16 @@ our $I18N = {
'sql body' => {
message => q|
<p><b>&#94;SQL();</b><br />
A one line SQL report. Sometimes you just need to pull something back from the database quickly. This macro is also useful in extending the SQL Report wobject. It uses the numeric macros (&#94;0; &#94;1; &#94;2; etc) to position data and can also use the &#94;&#94;rownum; macro just like the SQL Report wobject. Examples:</p>
A one line SQL report. Sometimes you just need to pull something back from the database quickly. This macro is also useful in extending the SQL Report wobject. It uses the numeric macros (&#94;0; &#94;1; &#94;2; etc) to position data and can also use the &#94;&#94;rownum; macro just like the SQL Report wobject.</p>
<p>Examples:</p>
<p>&#94;SQL("select count(*) from users","There are &#94;0; users on this system.");
</p>
<p>&#94;SQL("select userId,username from users order by username","&lt;a href='&#94;/;?op=viewProfile&amp;uid=&#94;0;'&gt;&#94;1;&lt;/a&gt;&lt;br /&gt;");
</p>
<p>If there are more numeric macros than selected columns in the SQL report the extra macros will be discarded.</p>
<p>The rownum macro, &#94;rownum;, begins counting at 1.</p>
|,
lastUpdated => 1146805799,
lastUpdated => 1151986323,
},
'illegal query' => {

View file

@ -66,7 +66,7 @@ plan tests => scalar @relatedHelp + scalar @isaHelp;
foreach my $related (@relatedHelp) {
my ($topic, $entry, $parentTopic, $parentEntry) = @{ $related }{'namespace', 'tag', 'parentTopic', 'parentEntry'};
ok( exists $helpTable{$topic}{$entry}, "Help entry: $topic -> $entry from $parentTopic -> $parentEntry");
ok( exists $helpTable{$topic}{$entry}, "Help entry: $topic -> '$entry' from $parentTopic -> $parentEntry");
}
foreach my $isa (@isaHelp) {

View file

@ -73,6 +73,16 @@ my @testSets = (
template => '^0;',
output => 'Cannot execute this type of query.',
},
{ ##Test unused macro variables
sql => q!select zero,one,two,three from testTable order by one!,
template => join(':', map { "^$_;" } 0..4).'-',
output => '0:1:2:3:-100:101:102:103:-',
},
{ ##rownum test
sql => q!select zero,one,two,three from testTable order by one!,
template => join(':', map { "^$_;" } 'rownum', 0..3).',',
output => '1:0:1:2:3,2:100:101:102:103,',
},
);
my $numTests = scalar @testSets;