X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FInflateColumn.pm;h=ee3081c4100db85b4c68662100aca46fba82dda8;hb=79a77af646d55bab4840d883527d4f73c9426427;hp=721894f4260a1ba4a554265bd3f6677dccfc12cc;hpb=664a70fad7d9aaf7d38579cdafe934663ee4a9c3;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/InflateColumn.pm b/lib/DBIx/Class/InflateColumn.pm index 721894f..ee3081c 100644 --- a/lib/DBIx/Class/InflateColumn.pm +++ b/lib/DBIx/Class/InflateColumn.pm @@ -25,12 +25,19 @@ the column data. It also "deflates" references into an appropriate format for the database. It can be used, for example, to automatically convert to and from -L objects for your date and time fields. +L objects for your date and time fields. There's a +conveniece component to actually do that though, try +L. -It will accept arrayrefs, hashrefs and blessed references (objects), -but not scalarrefs. Scalar references are passed through to the -database to deal with, to allow such settings as C< \'year + 1'> and -C< \'DEFAULT' > to work. +It will handle all types of references except scalar references. It +will not handle scalar values, these are ignored and thus passed +through to L. This is to allow setting raw values to +"just work". Scalar references are passed through to the database to +deal with, to allow such settings as C< \'year + 1'> and C< \'DEFAULT' > +to work. + +If you want to filter plain scalar values and replace them with +something else, contribute a filtering component. =head1 METHODS @@ -57,8 +64,7 @@ database, or consider L.) The coderefs you set for inflate and deflate are called with two parameters, the first is the value of the column to be inflated/deflated, the second is the -row object itself. Thus you can call C<< ->result_source->schema->storage->dbh >> on -it, to feed to L. +row object itself. Thus you can call C<< ->result_source->schema->storage->dbh >> in your inflate/defalte subs, to feed to L. In this example, calls to an event's C accessor return a L object. This L object is later "deflated" when @@ -73,7 +79,7 @@ sub inflate_column { $self->throw_exception("inflate_column needs attr hashref") unless ref $attrs eq 'HASH'; $self->column_info($col)->{_inflate_info} = $attrs; - $self->mk_group_accessors('inflated_column' => $col); + $self->mk_group_accessors('inflated_column' => [$self->column_info($col)->{accessor} || $col, $col]); return 1; }