[Dbix-class] Currency Columns

Christopher H. Laco claco at chrislaco.com
Mon Nov 13 15:05:58 GMT 2006


Christopher H. Laco wrote:
> Over the last week on irc, someone asked the question about how to deal
> with currency columns and formatting in DBIC. I pointed them to
> Handel::Currency and Handel::Storage::DBIC from the upcoming 1.0.
> =

> In short, what Handel does is that it accepts a list of 'currency
> columns', and sets the inflate/deflate subs to use Handel::Currency.
> Handel::Currency is just a simple object that holds the real number
> value, and provides convert(), format() methods that use the various
> currency formatting/conversion bits from CPAN....but I digress.
> =

> The comment was made by me that those are such generic, but helpful
> things, that I'd like to split this out from Handel at some point;
> creating both a generic currency class that provides the format/convert
> API, and a DBIC class that provides the currency column inflate/deflate
> mappings...kind of like what DigestColumns does.
> =

> Now, my first question is, what are DBICs goals for the InflateColumn::
> namespace? Is it going to move to having different classes for different
> types in there? Or are pure component classes better, like DigestColumns?
> =

> If there was an InflateColumn::Currency, what would it do?
> =

> Some people want to use ints, some real numbers, some decimal, and some
> dbs use 'money' columns, etc. Rather than guessing from the data_type
> like InflateColumn::DateTime does, what about something more generic in
> there?
> =

> add_columns(
>   price =3D> {
>     data_type   =3D> 'decimal',
>     is_currency =3D> 1
>   }
> )
> =

> Then, when is_currency is set, InflateColumn::Currency sets the
> inflate/deflates appropriately.
> =

> Thoughts?
> -=3DChris

And to reply to my own question...since the concept of currency columns
is represented as real column types in a few database like datetime
columns are, [to me] it seems that they are more InflateColumn like,
than they are separate concepts, like DigestColumns...

-=3DChris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://jules.scsys.co.uk/pipermail/dbix-class/attachments/20061113/7c=
71b30a/signature.pgp


More information about the Dbix-class mailing list