[Dbix-class] how to search by date?
Jess Robinson
castaway at desert-island.me.uk
Wed Jan 16 20:52:00 GMT 2008
On Tue, 15 Jan 2008, Tobias Kremer wrote:
> Am 15.01.2008 um 00:13 schrieb Michael Higgins:
>> Shouldn't this datetime cast/conversion thing be automagical?
>>
>> eval { $rs = $schema->resultset('DB::DATA')->search(
>> {Name => {'like', $name_like},
>> "the date" => \"= cast ('01/4/2008' as datetime)"
>> })};
>>
>> I just can't figure out, I'm sure, where the syntax is documented for
>> searching by datetime-type of column data via DBIx::Class.
>
>
> Use DateTime and the following DBIC component for automatic
> inflating/deflating to/from your database:
>
> http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/InflateColumn/DateTime.pm
>
Nice try, but incorrect. InflateColumn does what it says on the tin (plus
deflating columns), and does not deflate random things passed as search
arguments. So you're barking up the wrong tree there.
There is as yet, no magic to do the conversion for you. But it's fairly
simple to call $schema->storage->datetime_parser and use that.
Jess
More information about the DBIx-Class
mailing list