[Dbix-class] Where to set database date format for InflateColumn::DateTime?

Adam Witney awitney at sgul.ac.uk
Thu Apr 17 12:37:07 GMT 2014


>> Great thanks,
>>
>>   on_connect_do => "SET datestyle = 'sql, mdy'",
>>
>> did the trick
> mea culpa! You should use on_connect_call => 'datetime_setup' which does
> the right thing for every supported RDBMS, so you can use your model
> e.g. for testing on sqlplus but deploy to postgres.

ok great thanks, changed it to

on_connect_call => [[ do_sql => "SET datestyle = 'sql, mdy'"]],

Also a related question, I just created a record in this table, the date 
on the machine was

$ date
Thu Apr 17 13:30:41 BST 2014

the date in the database was

# select now();
17/04/2014 13:30:41.213018 BST

but the timestamp field contained

17/04/2014 12:30:41

ie an hour behind. I assume this is because the database/OS are using 
BST, but the application isn't.

The Result class contains this

     'created_on' => {
         'data_type'     => 'timestamp',
         'set_on_create' => 1,
         'is_nullable'   => 0,
     },

I don't really understand what I need to set to make sure created 
records have the correct time, is this an on_connect_call job as well?

Thanks again for any help

Adam





More information about the DBIx-Class mailing list