From: Jess Robinson Date: Sat, 25 Sep 2010 12:27:05 +0000 (+0100) Subject: Added ontes on where to override store_column (request from kd) X-Git-Tag: v0.08124~69 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ddabf34f6bef467bc213d2263f5ab2eb4d463b24;p=dbsrgits%2FDBIx-Class.git Added ontes on where to override store_column (request from kd) --- diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 3e3f5db..87ffd96 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -1877,7 +1877,7 @@ just looking for this. For example, say that you have three columns, C, C, and C. You would like to make changes to C and have C be automagically set to the value of C squared. -You can accomplish this by overriding C: +You can accomplish this by overriding C in your L: sub store_column { my ( $self, $name, $value ) = @_; @@ -1890,6 +1890,10 @@ You can accomplish this by overriding C: Note that the hard work is done by the call to C, which redispatches your call to store_column in the superclass(es). +Generally, if this is a calculation your database can easily do, try +and avoid storing the calculated value, it is safer to calculate when +needed, than rely on the data being in sync. + =head2 Automatically creating related objects You might have a class C which has many Cs. Further, you