Mjoin and "missing" join field

Mjoin and "missing" join field

zajczajc Posts: 67Questions: 10Answers: 2

Oracle identifiers are not allowed to exceed 30 characters in length. Therefore I use alias for Editor table in Editor 1.5.5. It works fine until I use Mjoin. I get the following error Join was performed on the field 'cpri_id' which was not included in the Editor field list. Here is a simple example:

$data = Editor::inst($db, 'cert_pri as c', 'cpri_id')
    ->fields(
        Field::inst('c.cpri_id'),
        Field::inst('c.cpri_st_prijave')
            ->validator('Validate::notEmpty'),
        Field::inst('c.cpri_leto_prijave')
            ->validator('Validate::notEmpty'),
        Field::inst('c.cpri_csnas_id')
            ->validator('Validate::notEmpty'),
    )
    ->leftJoin('cert_sif_nas_view csnv', 'csnv.csnas_id', '=', 'c.cpri_csnas_id')
    ->join(
        Mjoin::inst('cert_sif_pri')
            ->aliasParentTable( 'c' )
            ->link('c.cpri_id', 'cert_pri_pri.cppri_cpri_id')
            ->link('cert_sif_pri.cspri_id', 'cert_pri_pri.cppri_cspri_id')
            ->fields(
                Field::inst('cspri_id')
                    ->validator('Validate::required')
                    ->options('cert_sif_pri', 'cspri_id', 'cspri_naziv'),
                Field::inst('cspri_naziv')
            )
    )

If I remove leftJoin it works, but when leftJoin is included I got the above error. Can you help, please?

Answers

  • zajczajc Posts: 67Questions: 10Answers: 2

    I found a bug in Join.php.

    The line

    $pkeyIsJoin = $pkey === $joinField || $pkey === $dteTable.'.'.$joinField;
    

    should be

    $pkeyIsJoin = $pkey === $joinField || $pkey === $dteTable.'.'.$joinField || $pkey === $dteTableLocal.'.'.$joinField;
    

    You should include this in the next version ;)

This discussion has been closed.