[Dbix-class] DateTime Inflations for Timestamps

Matt S Trout dbix-class at trout.me.uk
Thu Apr 30 22:48:43 GMT 2009


On Thu, Apr 30, 2009 at 03:53:52PM -0400, Ryan Cone wrote:
> Can anyone provide some insight into why timestamps are treated as  
> datetimes in DBIx::Class::InflateColumn::DateTime?
> 
> Line 63:    $type = 'datetime' if ($type =~ /^timestamp/);
> 
> 
> I am using DBIC with Oracle and I am trying to distinguish between  
> columns that are Date and Date Time accurate.  In the database and the  
> models, I am using Date and Timestamp to represent the two types.  But  
> a bit of unlucky coincidence prevents me from loading  
> InflateColumn::DateTime as a component...
> 
> 1.  InflateColumn makes the timestamp a datetime.
> 2.  DateTime::Format::Oracle makes the datetime a date (rightly so I  
> think since dates and datetimes are synonymous in Oracle).
> 
> For now, I am adding custom Inflates using DateTime::Format::Oracle's  
> parse_date and parse_timestamp and those work as expected.  But  
> eventually it would be nice to have something that can be loaded.

How about patching InflateColumn::DateTime so that if there -are-
parse_timestamp and format_timestamp methods it uses those, and then it
falls back to the _datetime methods if not?

Looks to me like we simply didn't realise that there were DateTime::Format::
modules that had separate timestamp support - in fact more accurately *I*
didn't realise that at the time.

Do the other Oracle users on here want to weigh in on this please?

-- 
        Matt S Trout         Catalyst and DBIx::Class consultancy with a clue
     Technical Director      and a commit bit: http://shadowcat.co.uk/catalyst/
 Shadowcat Systems Limited
  mst (@) shadowcat.co.uk        http://shadowcat.co.uk/blog/matt-s-trout/



More information about the DBIx-Class mailing list