[Dbix-class] What would cause has_many relation accessor to query
and return objects using the wrong table/class ?
Matt S Trout
dbix-class at trout.me.uk
Mon Jul 28 22:44:28 BST 2008
On Mon, Jul 28, 2008 at 03:49:16PM +0100, 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' });
> ----
First, make sure you use full class names in rel names (hard to tell if
you did due to the contrivedness of your example)
> 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.
I think you've somehow registered an extra result source for one of the
two and/or messed up ->source_name.
Can you possibly produce at the very least redacted versions of the
CustomField -and- CustomFieldValue classes, and dump
My::Schema->source_registrations
plus
$schema->source_registrations
and see if you can spot a problem - and if you can't, also post recated
versions of those.
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
More information about the DBIx-Class
mailing list