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

[prev] [thread] [next] [Date index for 2005/08/29]

From: George Hartzell
Subject: Re: [CDBI] Help tracking down a problem w/ has_a and unexpected deflating.
Date: 00:10 on 29 Aug 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.

_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

Re: [CDBI] Help tracking down a problem w/ has_a and unexpected deflating.
George Hartzell 00:10 on 29 Aug 2005

Generated at 14:27 on 07 Sep 2005 by mariachi v0.52