[Bast-commits] r6523 - in DBIx-Class/0.08/branches/dts-in-search:
lib/DBIx/Class/Storage t
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Fri Jun 5 19:03:14 GMT 2009
Author: caelum
Date: 2009-06-05 19:03:14 +0000 (Fri, 05 Jun 2009)
New Revision: 6523
Modified:
DBIx-Class/0.08/branches/dts-in-search/lib/DBIx/Class/Storage/DBI.pm
DBIx-Class/0.08/branches/dts-in-search/t/89inflate_datetime.t
Log:
DTs now work in search
Modified: DBIx-Class/0.08/branches/dts-in-search/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/dts-in-search/lib/DBIx/Class/Storage/DBI.pm 2009-06-05 18:48:27 UTC (rev 6522)
+++ DBIx-Class/0.08/branches/dts-in-search/lib/DBIx/Class/Storage/DBI.pm 2009-06-05 19:03:14 UTC (rev 6523)
@@ -907,6 +907,15 @@
unshift(@bind,
map { ref $_ eq 'ARRAY' ? $_ : [ '!!dummy', $_ ] } @$extra_bind)
if $extra_bind;
+
+ for my $bind (@bind) {
+ my $val = $bind->[1];
+
+ if (Scalar::Util::blessed($val) && $val->isa('DateTime')) {
+ $bind->[1] = $self->datetime_parser->format_datetime($val);
+ }
+ }
+
return ($sql, \@bind);
}
Modified: DBIx-Class/0.08/branches/dts-in-search/t/89inflate_datetime.t
===================================================================
--- DBIx-Class/0.08/branches/dts-in-search/t/89inflate_datetime.t 2009-06-05 18:48:27 UTC (rev 6522)
+++ DBIx-Class/0.08/branches/dts-in-search/t/89inflate_datetime.t 2009-06-05 19:03:14 UTC (rev 6523)
@@ -13,7 +13,7 @@
my $schema = DBICTest->init_schema();
-plan tests => 53;
+plan tests => 57;
SKIP: {
eval { require DateTime::Format::MySQL };
@@ -29,6 +29,14 @@
my $starts = $event->starts_at;
is("$starts", '2006-04-25T22:24:33', 'Correct date/time');
+ok(my $row =
+ $schema->resultset('Event')->search({ starts_at => $starts })->single);
+is(eval { $row->id }, 1, 'DT in search');
+
+ok($row =
+ $schema->resultset('Event')->search({ starts_at => { '>=' => $starts } })->single);
+is(eval { $row->id }, 1, 'DT in search with condition');
+
# create using DateTime
my $created = $schema->resultset('Event')->create({
starts_at => DateTime->new(year=>2006, month=>6, day=>18),
More information about the Bast-commits
mailing list