orm
orm copied to clipboard
Ошибка в join()
Пример запроса:
$userRepository
->select()
->buildQuery()
->join('LEFT', 'user_profile', 'profile', 'user.id = profile.user_id')
->fetchAll()
В запросе получается вот такой JOIN:
LEFT JOIN "user_profile" AS "profile"
ON "profile" = "user"."id" = "profile"."user_id"
Проблема в том, что в методе JoinTrait:join(), передается параметр $alias в аргументы метода JoinTrait::on(...$args).
Поэтому получается ошибка в запросе JOIN, лишний параметр "profile" =
Рекомендую использовать отдельный метод ->on():
$userRepository
->select()
->buildQuery()
->join('LEFT', 'user_profile as profile')
->on(['user.id' => 'profile.user_id'])
// так тоже работает:
// ->on('user.id', 'profile.user_id')
->fetchAll()