[Templates] Single-object list being treated as hash bug/feature

Jess Robinson castaway@desert-island.me.uk
Wed, 30 May 2007 07:53:52 +0100 (BST)


Hi Andy,

I've mentioned and poked at this several times since around November, 
when TT 2.16 came out and produced this problem.

I'd like, if possible, an official response on whether this is a) a bug, 
and will be fixed (eventually), or b) a feature, in which case please tell 
me the workaround.

The short description is: If my TT code calls a method that should return 
a list of objects, and only gets one, it helpfully de-listifies. This is 
fine except when I wanted to loop around the result, which treats the 
single object as a hash and gives me the key/value pairs.

For a better description see: 
http://template-toolkit.org/pipermail/templates/2006-November/009115.html

For the patch with TEST I sent, see:
http://template-toolkit.org/pipermail/templates/2006-November/009115.html

This fixed it for the perl stash, someone else will need to poke the XS 
one..

Where it's turning up is in the SQL::Translator tests, which fail for all 
TT versions > 2.15.. I added a skip to ignore them if TT == 2.16, but that 
has now started failing since subsequent releases still have the 
bug/feature.

Thanks,
Jess