logo       

Re: Pointless update on a date field: msg#00084

Subject: Re: Pointless update on a date field
Matt S Trout wrote:
Result of 2 updates where only a non-date field should have been affected:

PRE: 1934-12-21
POST:1934-12-21

That one looks like it shouldn't have updated.
PRE: 1927-09-09
POST:1927-9-9

That one looks like what I was expecting.

You should just be dealing in DateTime objects and using the DBIC accessors;
the inflate/deflate will be transparent.

If you're using your own code to transform dates to/from mysql format you're
doing it wrong and any bugs are your problem.

Yes I know - my own code was just to get me going so I could retrieve stuff from the db when the user inputs dates in any EU format (I use Date::Calc::Decode_Date_EU to extract the year/month/day info). I knew I would have to revisit InflateColumn at some stage.

I have setup the table class as shown in DBIC::InflateColumn::DateTime, ie:
__PACKAGE__->add_columns( dob => { date_type=> 'date' } ),

but not:
__PACKAGE__->inflate_column( dob => {
  inflate => sub { ... },
  deflate => sub { ... }
} ) as described in DBIx::Class::InflateColumn.

There is obviously something amiss because if I omit my own date_to_mysql() method then system tries to retrieve dates in dd/mm/yyyy format.

> You can get the object DBIC
> does to do it via $storage->datetime_parser.

Not sure how to get from there to having DBIC transparently convert the users date input to mysql format so I can do things like:

my $rs = $c->model('Schema::Foo')->search( \%form_data );
$c->model('Schema::Foo')->find($id)->update( \%form_data );

without me having to do anything (manually) with the date fields in %form_data (apart from first validating they not invalid eg 31st February). Thanks for your help so far.
--
Richard Jones



<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