Subject: | update_or_create CURRENT_DATE() problem |
Date: | Sun, 15 Nov 2009 16:00:41 -0600 |
To: | bug-DBIx-Class [...] rt.cpan.org |
From: | Dave Wolfe <Dave [...] WolfeWorks.net> |
Ubuntu 9.10 generic with latest updates
Perl 1.10.0
Catalyst 5.80002
DBIx::Class 0.08112
Updating a possibly non-existant table entry using the MySQL
CURRENT_DATE() function fails in DateTime/Format/MySQL.pm.
When I attempt to use the following request:
c->model('DB::Hitcount')->update_or_create(
{ hitdate => {'=' => \'CURRENT_DATE()'},
contentid => $id,
hitcount => \'hitcount + 1' });
it throws the error:
[debug] Hit count transaction failed for content 51: DBIx::Class::Schema::txn_do(): Can't call method "ymd" on unblessed reference at .../DateTime/Format/MySQL.pm line 84.
Because 'hitdate' is a "DATE" data_type, it expects the ref to
'CURRENT_DATE()' to be a DateTime object and doesn't accept a DB
function in create/update although it does for search/find.
-------------------- Begin Hitcount.pm --------------------
package STM::Schema::Result::Hitcount;
use strict;
use warnings;
use base 'DBIx::Class';
__PACKAGE__->load_components("InflateColumn::DateTime", "Core");
__PACKAGE__->table("HitCount");
__PACKAGE__->add_columns(
"hitdate",
{ data_type => "DATE", default_value => undef, is_nullable => 0, size => 10 },
"contentid",
{ data_type => "INT", default_value => undef, is_nullable => 0, size => 10 },
"hitcount",
{ data_type => "INT", default_value => undef, is_nullable => 0, size => 10 },
);
__PACKAGE__->set_primary_key("hitdate", "contentid");
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-06-22 15:50:14
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:BN+t/vl86e7atzM1AqFa7g
__PACKAGE__->belongs_to(hitpage => 'STM::Schema::Result::Content', 'contentid');
1;
-------------------- End Contactmap.pm --------------------
--
Dave Wolfe