<br><div class="gmail_quote">On Thu, Aug 26, 2010 at 9:11 AM, Peter Rabbitson <span dir="ltr"><<a href="mailto:rabbit%2Bdbic@rabbit.us">rabbit+dbic@rabbit.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">Pavel A. Karoukin wrote:<br>
> On Thu, Aug 26, 2010 at 3:33 AM, Peter Rabbitson <<a href="mailto:rabbit%2Bdbic@rabbit.us">rabbit+dbic@rabbit.us</a><br>
</div><div class="im">> <mailto:<a href="mailto:rabbit%252Bdbic@rabbit.us">rabbit%2Bdbic@rabbit.us</a>>> wrote:<br>
><br>
> Pavel A. Karoukin wrote:<br>
> > Hello,<br>
> ><br>
> > I am trying to make something work nice, but it doesn't want to =)<br>
> > Probably, it's just by design, or I am missing something.<br>
> ><br>
> > Question: is it possible to make it work with $user->data->{test} = 1;<br>
> > notation? I.e. I do not want to create new methods in results<br>
> class, not<br>
> > want to extract hash from field first and then save it?<br>
><br>
> Absolutely impossible, since the whole idea of InflateColumn is:<br>
> *) A plain scalar value supplied to new/update is assumed to be an<br>
> already-deflated value to be placed directly in the database<br>
> *) Any type of reference (blessed or not) is a candidate for deflation<br>
> and passed on to the deflator<br>
><br>
> However you may find that FilterColumn does exactly what you want to<br>
> do.<br>
><br>
><br>
> Peter,<br>
><br>
> Thank you for pointing to FilterColumn. I've tried it with almost same<br>
> result tho.. Probably I am doing something wrong?<br>
><br>
</div><div class="im">> And now in my controller code trying this:<br>
><br>
> $c->user->data->{test}; # return "yes" as stored in DB in JSON format<br>
> $c->user->data->{test} = "no"; # now this contain "no", but not stored<br>
> in DB yet<br>
> $c->user->update(); # I thought it should pass $c->user->date to<br>
> __data_to_storage(), but it never do this. Why?<br>
><br>
<br>
</div>I misunderstood your initial question, sorry. For what you are doing both<br>
IC and FC will work. However the data column stores a *reference* to a<br>
hash. By doing hash->{key} = val you are not changing the reference, so<br>
as far as DBIC is concerned the value of the column did not change.<br>
What you need to do is manually invoke[1] or replace the entire hashref<br>
with another hashref.<br>
<br>
[1] <a href="http://search.cpan.org/~frew/DBIx-Class-0.08123/lib/DBIx/Class/Row.pm#make_column_dirty" target="_blank">http://search.cpan.org/~frew/DBIx-Class-0.08123/lib/DBIx/Class/Row.pm#make_column_dirty</a><br>
<div><div></div><div class="h5"><br></div></div></blockquote><div><br></div><div>Thank you Peter! That's something I had in mind but I didn't know about possibility column being dirty! I will try to rework it somehow to make call to make_column_dirty() automatically inside of "something" =)</div>
<div><br></div><div>Regards,</div><div>Pavel</div></div>