[Dbix-class] Fwd: might_have for dbix versions

lim weityug weityug at gmail.com
Tue May 28 02:01:42 GMT 2013


Hi,



Our company is maintaining 2 versions of dbix class, which is  version
0.08115 and 0.08195. We have an issue on defining the condition in
might_have relationship. Before we have the new server (which is running
dbix version 0.08195), our result file is like the following:



__PACKAGE__->might_have(

     'sample',

     'Schema::Result::Sample',

     {

         'foreign.pid' =3D> 'self.pid and sample.wstart =3D 0',

     },

);



This works well for version 0.08115, but it fail for version 0.08195 with
the following error:



Couldn't instantiate component "Model::DB", "Couldn't load class (Schema)
because: DBIx::Class::Schema::throw_exception():
DBIx::Class::Row::throw_exception():
DBIx::Class::Relationship::HasOne::might_have(): Defining rel on
Schema::Result::Product that includes pid and sample.wstart =3D 0 but no su=
ch
column defined here yet at Schema/Result/Product.pm line 1621\n



We understand that the condition should be in hash form, so it is right for
version 0.08195 to complain about 'foreign.pid' =3D> 'self.pid and
sample.wstart =3D 0'. We=92ve tried to change this to the following, but it
cannot produce the result we want:



__PACKAGE__->might_have(

    'sample',

    'Schema::Result::Sample',

    {

        'foreign.pid' =3D> 'self.pid',

    },

    { where =3D> {'sample.wstart' =3D> 0}},

);



I have also tried the following,  but it throws exception on the key must
be =91foreign=92 instead of =91self=92:



__PACKAGE__->might_have(

    'sample',

    'Schema::Result::Sample',

    {

        'foreign.pid' =3D> 'self.pid',

        =91self.wstart=92 =3D> 0,

    },

);


We can=92t just upgrade our dbix class to latest version as this require
intensive regression test on our application which is very huge effort and
high risk. We=92re trying to see if there is any way for having the codes to
be run in both dbix versions. Would it be possible to have the self.column
in the might_have condition? Could you advice the possible way to solve
this?



Thank you.



Regards,

Wei Tyug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20130528/f1a=
596ea/attachment.htm


More information about the DBIx-Class mailing list