[Dbix-class] What would cause has_many relation accessor to query and return objects using the wrong table/class ?

Jess Robinson castaway at desert-island.me.uk
Mon Jul 28 16:10:26 BST 2008


On Mon, 28 Jul 2008, Aaron Trevena wrote:

> Hi All,
>
> I have a peculiar problem.
>
> I've defined a bunch of has_many relations, but when I call them an
> object they use the it's own table and class...
>
> i.e.
> ---
> package CustomField;
>
> ...
>
> __PACKAGE__->has_many(custom_field_values => 'CustomFieldValue', {
> 'foreign.custom_field_id' => 'self.custom_field_id' });
> ----
>
> yet when I call custom_field_values on a CustomField object I get
> CustomField objects back, and it queries the custom_field rather than
> custom_field_value table.
>
> No warnings, just the wrong query and wrong object.
>
> I've checked the definitiions of the related classes, they are all
> fine and correct, how on earth can has_many get as confused as this ?
>
> Any idea what could be causing this ?
>

Care to dump the entire contents of both classes involves? Cos at the mo 
I'm guessing "You typed the wrong table name in one of them".. Failing 
that, also the code you called, and a test tarball ;)

Jess




More information about the DBIx-Class mailing list