0

I have the following code in a Table definition.

$paginationQuery = $this->find()
    ->select([
        'Members__id','Members__member_type','Members__first_name',
        'Members__middle_name','Members__last_name','Members__suffix'
    ])
    ->contain([
        'SocialMembers' => [
            'foreignKey' => false,
            'queryBuilder' => function (Query $q) {
                return $q->where([
                    'Members.Members__id' => 'SocialMembers.full_member_id'
                ]);
            }
        ]
    ])
    ->from([
        $this->getAlias() => $query
    ])
    ->order([
        'Members__last_name' => 'ASC',
        'Members__first_name' => 'ASC'
    ]);

return $paginationQuery;

This is to paginate the results of a union of two sets of extracted data.

The problem comes from the queryBuilder function. The left join that is generated looks like this:

LEFT JOIN members SocialMembers ON (
    SocialMembers.member_type = 2 
    AND Members.Members__id = 'SocialMembers.full_member_id'
)

There is an unneeded pair of single quotes around SocialMembers.full_member_id. queryBuilder appears to correctly handle the Members.Members__id, but not the value field of the array. Is there any way to get this to generate correctly?

ndm
  • 59,784
  • 9
  • 71
  • 110
jhogarth
  • 19
  • 6

1 Answers1

0

Was able to resolve this by moving the contains clause to the preceding finder methods.

jhogarth
  • 19
  • 6