in reply to Dbic and inflating Oracle DATE columns - solved
ilmari on IRC pointed me towards DBIx::Class::Storage::DBI::Oracle::Generic and the connect_call_datetime_setup method. While I can't say for certain that the on_connect_call option goes and finds the correct formatter, the docs say that it Does the Right Thing, i.e. it sets the necessary values and environment variables for DBIx::Class::InflateColumn::DateTime and DateTime::Format::Oracle. It just works.
There is a no-op sub in the base class DBIx::Class::Storage::DBI so that your code is portable across databases. The documentation on on_connect_call explains that on_connect_call => 'datetime_setup' calls DBIx::Class::Storage::DBI::Oracle::Generic->connect_call_datetime_setup() on Oracle databases which makes your InflateColumn call work.
some example code
works withmy $schema = Timetable::Schema->connect("dbi:Oracle:$schema_name", $db_username, $db_password, {on_connect_call => 'datetime_setup'} ); my $resultset = $schema->resultset('Ical') ->search($id); print "Start time is ", $resultset->start_time; # Start time is 2018-04-30T16:00:00
use utf8; package Timetable::Schema::Result::Ical; use base 'DBIx::Class::Core'; __PACKAGE__->load_components("InflateColumn::DateTime"); __PACKAGE__->table_class("DBIx::Class::ResultSource::View"); __PACKAGE__->table("ICAL"); __PACKAGE__->add_columns( "id", { data_type => "varchar2", is_nullable => 0, size => 255 }, "start_time", { data_type => "datetime", is_nullable => 1, original => { data_type => "date" }, }, }; 1;
Mojoconf was great!
|
---|