logo       

Re: Detecting changes after ->update(\%) ?: msg#00072

Subject: Re: Detecting changes after ->update(\%) ?
On 8/12/07, Matt S Trout <dbix-class@xxxxxxxxxxx> wrote:
> On Sat, Aug 11, 2007 at 08:48:13PM +0100, Paul Makepeace wrote:
> > On 8/8/07, Matt S Trout <dbix-class@xxxxxxxxxxx> wrote:
> > > On Tue, Aug 07, 2007 at 11:30:06PM +0100, Paul Makepeace wrote:
> > > > I had a look in various places (cookbook, faq, ::resultset) and
> > > > couldn't find whether there's a way to see if any SQL would be
> > > > generated due to a call to update().
> > >
> > > Call get_dirty_columns and see if it returns anything.
> >
> > Perhaps I'm being slow here, can you give some example code please?
>
> you asked "to see if any SQL would be generated", not "to see if any SQL
> -was- generated".
>
> my $will_change = $obj->get_dirty_columns;
>
> $obj->update;

The format of my question (see subject) contains an argument to
update(), so this answer unfortunately doesn't fit my question,
afaics. Another way of putting this is, picking nits in my language
aside, can you see what I'm trying to achieve? I would like to find
out whether a call to update(\%) resulted in a change so I can report
this back to the user.

At the risk of tiring anyone else who can see what I'm talking about
I'll copy/paste what I originally wrote,

 my $rv = $obj->update(\%stuff);
 $messages->($rv->XXX ? "updated" : "unchanged");

What goes in XXX or some other change to make this work?

</verbose>,

P

>
> > I have tried it as,
> >
> >   my $changes = $user_obj->update($u);
> >   $messages->("$uname ", $user_obj->get_dirty_columns ? "UPDATED" :
> > "unchanged");
> >
> > ($changes->get_dirty_columns as well just to be sure..)
> >
> > and it always shows "unchanged". Which sort of makes sense if the
> > ->update performs the actual update you wouldn't expect any dirtiness.
>
> --
>       Matt S Trout       Need help with your Catalyst or DBIx::Class project?
>    Technical Director    Want a managed development or deployment platform?
>  Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
> http://chainsawblues.vox.com/                    http://www.shadowcat.co.uk/
>
> _______________________________________________
> List: http://lists.rawmode.org/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@xxxxxxxxxxxxxxxxx
>



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe