Pavel A. Karoukin wrote:
> On Thu, Aug 26, 2010 at 3:33 AM, Peter Rabbitson <[email protected]
> <mailto:rabbit%[email protected]>> wrote:
> 
>     Pavel A. Karoukin wrote:
>     > Hello,
>     >
>     > I am trying to make something work nice, but it doesn't want to =)
>     > Probably, it's just by design, or I am missing something.
>     >
>     > Question: is it possible to make it work with $user->data->{test} = 1;
>     > notation? I.e. I do not want to create new methods in results
>     class, not
>     > want to extract hash from field first and then save it?
> 
>     Absolutely impossible, since the whole idea of InflateColumn is:
>     *) A plain scalar value supplied to new/update is assumed to be an
>     already-deflated value to be placed directly in the database
>     *) Any type of reference (blessed or not) is a candidate for deflation
>     and passed on to the deflator
> 
>     However you may find that FilterColumn does exactly what you want to
>     do.
> 
> 
> Peter,
> 
> Thank you for pointing to FilterColumn. I've tried it with almost same
> result tho.. Probably I am doing something wrong?
> 
> And now in my controller code trying this:
> 
>   $c->user->data->{test}; # return "yes" as stored in DB in JSON format
>   $c->user->data->{test} = "no"; # now this contain "no", but not stored
> in DB yet
>   $c->user->update(); # I thought it should pass $c->user->date to
> __data_to_storage(), but it never do this. Why?
> 

I misunderstood your initial question, sorry. For what you are doing both
IC and FC will work. However the data column stores a *reference* to a
hash. By doing hash->{key} = val you are not changing the reference, so
as far as DBIC is concerned the value of the column did not change.
What you need to do is manually invoke[1] or replace the entire hashref
with another hashref.

[1] 
http://search.cpan.org/~frew/DBIx-Class-0.08123/lib/DBIx/Class/Row.pm#make_column_dirty

Cheers

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to