[Dbix-class] discard_changes upgrade.

Oleg Pronin syber.rus at gmail.com
Fri Apr 11 09:00:23 BST 2008


Yeah, that would be great! something like 'reload' or 'refresh'. Should we
post a patch for code and test, or somebody else will do this?

2008/4/10, Matt S Trout <dbix-class at trout.me.uk>:
>
> On Tue, Mar 25, 2008 at 11:54:24AM +0300, Oleg Pronin wrote:
>
> > Hello.
> >
> > I think 'discard_changes' should be upgraded because:
> > - it clears all the data in object. Suppose there was non-db data in the
> > object:
> >      __PACKAGE__->mk_accessors(....);
> >   'discard_changes' clears it all. I think this is not good.
>
>
> But it -is- how we've behaved for a while.
>
> How about adding a 'reload_columns' method that just reloads columns, and
> make discard_changes proxy to that?
>
>
> > - it does not accept $attrs. For example there is often a need to
> refresh
> > object from database with
> >   exclusive lock, like $row->discard_changes({lock_for =3D> 'update'});
> >
> > - I think it should fetch only data without a need of constructing a
> heavy
> > object. I.e.
> >
> >     my ($self, $attrs) =3D @_;
> >     return unless $self->in_storage;
> >
> >     my $rs =3D $self->result_source->resultset;
> >     $rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
> >
> >     my $hash_ref =3D $rs->find({
> >         map { $_ =3D> $self->get_column($_) } $self->primary_columns,
> >     }, $attrs);
> >
> >     $self->set_columns($hash_ref);
> >     delete $self->{_dirty_columns};
> >
> >
> > With best regards.
>
>
> > _______________________________________________
> > 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.rawmode.org
>
>
> --
>
>       Matt S Trout       Need help with your Catalyst or DBIx::Class
> project?
>    Technical Director
> http://www.shadowcat.co.uk/catalyst/
>   Shadowcat Systems Ltd.  Want a managed development or deployment
> platform?
> http://chainsawblues.vox.com/
> http://www.shadowcat.co.uk/servers/
>
> _______________________________________________
> 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.rawmode.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20080411/f7f=
e1f72/attachment-0001.htm


More information about the DBIx-Class mailing list