<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:courier, monaco, monospace, sans-serif;font-size:12pt"><DIV>Hello,</DIV>
<DIV>&nbsp;</DIV>
<DIV>I'm the person who started this thread on the Catalyst ML. </DIV>
<DIV>&nbsp;</DIV>
<DIV>The original problem is that trying to display the field of an object related by belongs_to, Template Toolkit would autovivify the object if it didn't already exist. So given a Transaction object r, just trying to display r.customer.b_company would do an sql insert and create a blank customer object, if the column r.customer was 0 (i.e. if there was no customer object).</DIV>
<DIV>&nbsp;</DIV>
<DIV>The docs did not explain that such side-effects were entailed by "doing the right thing". It seemed to be a bug to me but I understand now it is more just a problem with the docs. The might_have docs are also a bit lacking in fact one sentence stops midway through.</DIV>
<DIV>&nbsp;</DIV>
<DIV>It seems my options are to do one of the following.</DIV>
<DIV>1.&nbsp;Allow NULL for that column so belongs_to knows it is optional. </DIV>
<DIV>2.&nbsp;Use might_have instead of belongs_to, if there is no other difference in its operation.</DIV>
<DIV>3. Solve it all in the search call before going to the template. Maybe same autovivification will happen though.</DIV>
<DIV>4. Create a dummy customer of ID 0.</DIV>
<DIV>&nbsp;</DIV>
<DIV>My original reasoning for not allowing NULL is so that I wouldn't get a crash if trying to display/reference a null. Since it will be operated by someone not familiar with the concept of NULL it seemed a bit dangerous to use it. At any rate now I have a system in production and don't want to make big changes to it. probably #4 is simplest but also I would like to know if might_have can be used as a drop-in replacement for belongs_to that just won't do autovivification. Thanks for your help.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Sincerely,</DIV>
<DIV>&nbsp;</DIV>
<DIV>Matt Rosin</DIV></div><br>

<hr size=1><a href="http://us.rd.yahoo.com/evt=49938/*http://tools.search.yahoo.com/toolbar/features/mail/">Never miss an email again!<br>Yahoo! Toolbar</a> alerts you the instant new Mail arrives.<a href="
http://us.rd.yahoo.com/evt=49937/*http://tools.search.yahoo.com/toolbar/features/mail/"> Check it out.</a></body></html>