[Dbix-class] Currency Columns

Christopher H. Laco claco at chrislaco.com
Mon Nov 13 14:59:59 GMT 2006


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

-------------- 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/fb=
6d084d/signature.pgp


More information about the Dbix-class mailing list