RE: Class::DBI::FromCGI and is_changed
[prev]
[thread]
[next]
[Date index for 2004/10/26]
Charles Bailey writes:
> --On Tuesday, October 26, 2004 7:56 PM +0100 Simon Wilcox <essuu@xxxxxxxx.xxx> wrote:
> > On Tue, 26 Oct 2004, Zhuang Li wrote:
> > > Assuming $cd->year is already '2002' and then $cd->year('2002') is
> > > called. is_changed() will think $cd->year has been changed although with
> > > the same value.
> >
> > Which is arguably wrong as I now need to pre-process all the args and
> > compare them against the original values to see if they've really changed
> > or not.
>
> While I see the intuitive value of your argument, I'm not sure it's a good
> idea to ask is_changed() to account for 'equivalent' values, both because
> equivalence may be difficult to define in some cases, and because the
> necessary comparisons may (in tricky cases) slow down a basic operation.
This issue is essentially equivalent to the following thread.
http://groups.kasei.com/mail/arc/cdbi-talk/2004-10/msg00055.html
Perhaps is_changed() should be renamed to
set_accessors_have_been_used_since_last_update()
because that's currently the true semantics (see the code).
The wording "is_changed" is misleading, or at the very least ambiguous.
Regardless, I agree with Charles's response. If you need to see
whether an object's values differ from the database, roll your own
comparison code. By the way, is there a module that attempts such, in
a generic manner?
Kings