[Dbix-class] changing view definition

Dave Howorth dhoworth at mrc-lmb.cam.ac.uk
Fri May 18 10:26:03 GMT 2012


Is it possible to change the definition of a
DBIx::Class::ResultSource::View based on the particular database to
which a connection is made?

I have a result class that is a union of several tables. Unfortunately,
I now have another database to which I must connect that has an
additional table needing to be included in the union. Is it possible to
do this by connecting to the database and then changing the result class
somehow to use the expanded union?

My class initializes with:

__PACKAGE__->result_source_instance->is_virtual(1);
__PACKAGE__->result_source_instance->view_definition($my_select_union_sql);

I've tried adding a call later, once I know which database is in use:

__PACKAGE__->result_source_instance->view_definition($my_new_select_union_sql);

but DBIC still uses the original select SQL when querying the database.

Is there some other way of changing the definition of the view?

Thanks, Dave



More information about the DBIx-Class mailing list