[Melbourne-pm] DBIx::Class inflate/deflate vs split/combined fields

Toby Corkindale toby.corkindale at strategicdata.com.au
Thu Nov 3 18:04:24 PDT 2011

On 04/11/11 11:47, Malcolm Herbert wrote:
> What's the recommended way to deal with cases where multiple fields
> in a database record need to be combined to produce a value? How does
> one then arrange to automatically split these back into their various
> components for insert/updates?
> I'm thinking here of cases where a database field has a string
> representing multiple values (I didn't write this schema) in a
> key=value;key=value format and other cases where I need to combine a
> date (without timezone) and a string containing the zone name into a
> DateTime object.
> Ideally I'd like to deal with that with the DBIx::Class inflate/deflate
> mechanism which should make things more portable ...
> In the case of the multi-value field I can create a class to represent
> this easily enough and write parse/dump routines as appropriate, but
> I'm stumped on how to work with the dates, split as they are over two
> database fields ...
> Has anyone had to tackle this before?

Inflation from the database is easy.
For deflation, you can override the actual field name methods, plus 
update() and create() methods, and handle the conversion there? It's a 
bit messy, but works.


More information about the Melbourne-pm mailing list