[Dbix-class] Inflated DateTime column not updated on $row->update({ ts_column => undef })

Lasse Makholm lasse at unity3d.com
Sat May 23 20:48:01 GMT 2015


On Sat, May 23, 2015 at 9:35 AM, Peter Rabbitson <rabbit+dbic at rabbit.us>
wrote:

> On 05/22/2015 09:57 PM, Lasse Makholm wrote:
>
>> It seems DBIx::Class::InflateColumn::DateTime does not update the
>> inflated column value on: $row->update({ ts_column => undef })
>>
>
> That is a bug, not sure how it went overlooked for so long :( It is
> present as far back as 0.08112 (2009), likely earlier.
>

Yeah, it seems remarkable that I'm the first to stumble across this. On the
other hand, I only found it because I was trying to get 100% condition
coverage on something and was updating a row through all permutations of a
couple of conditions.

I guess, generally, updating a timestamp column to null after it has had a
value, is just not a very common thing to do.


> Because of the nontrivial possibility of negative impact of changing
> something so fundamental, I have to think this through before going forward.
>

Yeah, I don't really see a pretty way around this without risking a lot of
random breakage.

In the meantime an easy workaround for you is to add the following to a
> base result class (this is a hack, a real fix will materialize later):
>
>   sub store_column {
>     delete $_[0]->{_inflated_column}{$_[1]};
>     shift->next::method(@_);
>   }
>
> Sorry for not being able to offer anything better at the moment :(


No worries. As far as workarounds/hacks go, this one is pretty decent. I've
seen and done a lot worse... :-)

Thanks for confirming this.

/L

>
>
> _______________________________________________
> 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/dbix-class@lists.scsys.co.uk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20150523/273e9bda/attachment.htm>


More information about the DBIx-Class mailing list