[Dbix-class] Where to set database date format for InflateColumn::DateTime?
Adam Witney
awitney at sgul.ac.uk
Thu Apr 17 14:10:32 GMT 2014
On 17. 4. 2014 14:34, Hartmaier Alexander wrote:
> On 2014-04-17 15:29, Adam Witney wrote:
>>
>>
>> On 17. 4. 2014 14:20, Hartmaier Alexander wrote:
>>> On 2014-04-17 14:37, Adam Witney wrote:
>>>>
>>>>>> 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'"]],
>>> It should be on_connect_call => 'datatime_setup', literally!
>>
>> But this gives the same error as without the on_connect_call.
> Show us your complete code and look at which sql queries are executed
> after connecting using DBIC_TRACE.
It is just running this SQL query
SELECT me.id, me.description, me.created_on, me.user_id FROM
audit_log_changeset me WHERE ( me.id = ? ): '1'
My model is
package My::Model::DB;
use strict;
use base 'Catalyst::Model::DBIC::Schema';
__PACKAGE__->config(
schema_class => 'My::Schema',
connect_info => {
dsn => 'dbi:Pg:dbname=db1',
user => 'test',
options => { AutoCommit => 0 },
on_connect_call => 'datetime_setup',
}
);
And the timestamp field, "created_on", is within
DBIx::Class::AuditLog::Changeset
http://search.cpan.org/~ioncache/DBIx-Class-AuditLog-0.6.0/lib/DBIx/Class/Schema/AuditLog/Structure/Changeset.pm
And i just have
[% auditlog.Changeset.created_on %]
in my template
Thanks again
More information about the DBIx-Class
mailing list