Mike Bennett
Mike Bennett

Reputation: 386

Catalyst FormFu DBIC error - using dot notation in a resultset

I've inherited a Perl Catalyst application that I'm trying to port to a new server. The application uses FormFu with the HTML::FormFu::Model::DBIC module used to load data from a result set.

I have a DBIx table, say MyTable, with an auto-generated Result implementation and a custom ResultSet implementation. In the custom ResultSet implementation there are some subroutines, e.g. sub my_sub, that return filtered subsets of data.

In a FormFu YAML file, the following will fetch all the records from MyTable:

elements:
  - type: Select
    model_config:
      resultset: MyTable

This is equivalent to fetching, in a Controller, $schema->resultset('MyTable'). This executes correctly on both the old server and the new server.

On the old server, I can use dot notation to call the subroutine to fetch the subset of records it returns like so:

elements:
  - type: Select
    model_config:
      resultset: MyTable.my_sub

This is equivalent to fetching in a Controller, $schema->resultset('MyTable')->my_sub. This executes correctly on the old server. On the new server, in FormFu, this throws the error:

Can't find source for MyTable.my_sub at /[...]/HTML/FormFu/Model/DBIC.pm

I've added debugging to the FormFu DBIC.pm module to see if it's doing anything special. The code it calls is $schema->resultset($rs_name); where rs_name is the name given in the resultset parameter, "MyTable.my_sub", and $schema is of type Moose::Meta::Class::__ANON__::SERIAL, which I assume is some kind of wrapper. Within a Catalyst controller, a schema is of type myapp::Schema.

What am I missing? Is there some configuration option I need to set? Some module I need to install? I can't find any documentation or examples that show a FormFu resultset with dot notation, yet on the old server it works.

Upvotes: 1

Views: 53

Answers (1)

Mike Bennett
Mike Bennett

Reputation: 386

When I attempted to add logging to the working DBIC.pm file, I discovered that the developer from whom I inherited this application symlinked the module's DBIC.pm file to a custom DBIC.pm file in his own home folder with the extended functionality.

Upvotes: 2

Related Questions