[Dbix-class] Detecting changes after ->update(\%) ?
Matt S Trout
dbix-class at trout.me.uk
Sun Aug 12 18:03:22 GMT 2007
On Sun, Aug 12, 2007 at 04:21:06PM +0100, Paul Makepeace wrote:
> On 8/12/07, Matt S Trout <dbix-class at trout.me.uk> wrote:
> > On Sat, Aug 11, 2007 at 08:48:13PM +0100, Paul Makepeace wrote:
> > > On 8/8/07, Matt S Trout <dbix-class at trout.me.uk> 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.
Don't call update(\%), use the setters and then call ->get_dirty_columns
then ->update().
Convenience shortcut methods don't always expose as much information as doing
it yourself :)
--
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/
More information about the DBIx-Class
mailing list