[CDBI] Help tracking down a problem w/ has_a and unexpected deflating.

George Hartzell hartzell at kestrel.alerce.com
Mon Aug 29 01:10:18 BST 2005


George Hartzell writes:
 > George Hartzell writes:
 >  > 
 >  > I'm building a Mason based web app on FreeBSD 6-ish using perl 5.8.6
 >  > and a whole passel of cpan-standard stuff (details if they're
 >  > interesting).  I'm using SQLite to store my data and Class::DBI to
 >  > manipulate it.  I'm using Class::DBI version 0.96 built via FreeBSD's
 >  > ports system but see similar results with a copy of 0.999.
 >  > [...]
 > 
 > I hate to reply to my own message, but I've just had an Ah-ha moment
 > that might be helpful.
 > [...]

Ok, I figured it out.

When I create the objects, the things that I'm passing in are simple
scalars, so the code in _deflated_column doesn't monkey with them and
they're written to the database as is (as simple integers in this
case).

Once I have a real object in hand and I *change* the value, Class::DBI
inflates the column for me so that it's value is a reference to an
object.  When *that* gets passed down into _deflated_columns it sees
it as an object and tries to deflate it.  Since I didn't include a
deflate sub {}, I've been ending up with the default stringification.

Adding a deflate sub that's just sub {$_[0]->epoch} makes everything
work.

Phew.

g.




More information about the ClassDBI mailing list