[Dbix-class] search() and deflating columns

Chisel Wright chisel at herlpacker.co.uk
Tue Jun 27 22:50:22 CEST 2006


It's taken me a while to nail this one down to a point where I know
roughly where the problem lies, and to produce a test-case to
demonstrate it.

For reasons known only to me, I've been doing DBIC lookups with quite
precise times (fractions of seconds).

However, it appears that and inflated (timestamp) column doesn't get
deflated for searches.

In my code I'm inflating timestamps to a DateTime object (using
DateTime::Format::Pg->parse_datetime), and deflating with
DT:F:P->format_datetime).

DateTime objects parse and store nanoseconds (perfect), unfortunately it
looks like search() uses the default stringification of the object,
i.e.:

  # perl -MDateTime -le '$dt = DateTime->now(); print "$dt";'
  2006-06-27T20:41:58

which throws away the fractional part of the timestamp.

What I believe would be more useful, would be to deflate inflated
objects in search()es and the like [otherwise, why bother with a deflate
action?]

In my code I've worked around this by changing from:

  $thingy_list = $schema->resultset('Thingy')->search(
    {
       created => { '=', $new_thingy->created() },
    }
  );

to:

  $thingy_list = $schema->resultset('Thingy')->search(
    {
      created => {
        '=',
        DateTime::Format::Pg->format_datetime($new_thingy->created())
      },
    }
  );


Rather than attach files or pad out the email with their contents, I've
uploaded a test-case to Berlios, everything's in the README:

  http://svn.berlios.de/wsvn/parley/trunk/issues/search_deflate/?rev=169&sc=0
or
  svn co -r 169 \
   http://svn.berlios.de/svnroot/repos/parley/trunk/issues/search_deflate/

I've tested with DBIC versions 0.06003 and 0.06999_03, with results for
the latter here:

  http://svn.berlios.de/wsvn/parley/trunk/issues/search_deflate/RESULTS-0.06999_03?op=file&rev=169&sc=0


It would be great to know if this behaviour can be changed, or reason
why it can't be done.


Cheers,

Chisel
-- 
Chisel Wright
e: chisel at herlpacker.co.uk
w: http://www.herlpacker.co.uk/

This is not an automated signature. I type this in to the bottom of every
message. 



More information about the Dbix-class mailing list