[Dbix-class] weird result_source_instance problem

Tobias Kremer list at funkreich.de
Fri May 25 12:48:24 GMT 2007


> Am 24.05.2007 um 18:28 schrieb Matt S Trout:
> > On Thu, May 24, 2007 at 03:18:46PM +0200, Tobias Kremer wrote:
> >>> The problem is that even calls on MyApp::Schema::User ResultSets to
> >>> standard relationships defined via has_many trigger the execution
> >>> of the
> >>> manually added ResultSource above - which of course fails with a
> >>> "called with x bind variables when y are needed" error message.
> >>
> >> Correction: Calls to standard relationships DO work fine but I
> >> have custom
> >> methods in MyApp::Schema::User that use these relationships and
> >> they stop
> >> working:
> >
> > Can you show the calling code, please?

Ok, I tried to strip down my schema so that you can have a look at it:

http://www.funkreich.de/files/dbic_wreck.tar.gz

runme.pl fails on my system - The call to custom_method() tries to use the
ResultSource that is created in Wreck::Schema::User although it should just use
the "normal" relationship called relation_a (notice the "I AM NOT SUPPOSED TO BE
CALLED" string in the output). The "prefetch" parameter in custom_method seems
to somehow have to do with this.

What I find most interesting is the fact that the name given to
->register_source in Wreck::Schema::User has an influence on the whole case.
Try changing it from "MyResultSource" to "UserMutual" and suddenly everything
works as intended.

What kind of magic is going on there under the hood? :)

--Tobias



More information about the Dbix-class mailing list