WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Cannot use joins with composite expressions #7213

@emodric

Description

@emodric
Q A
Version 4.3.4/3.10.1

Summary

Doctrine\DBAL\Query\Join class does not support CompositeExpression.

Current behavior

When having code similar to:

$query->innerJoin(
    'r',
    'rule',
    'rt',
    $query->expr()->and(
        $query->expr()->eq('r.id', 'rt.rule_id'),
        $query->expr()->eq('r.status', 'rt.status'),
    ),
)

I'm getting the error Doctrine\DBAL\Query\QueryBuilder::innerJoin(): Argument #4 ($condition) must be of type ?string, Doctrine\DBAL\Query\Expression\CompositeExpression given

It seems that join/innerJoin/leftJoin/rightJoin methods do not support CompositeExpression class. Is there are reason for that behaviour?

Expected behavior

I expect this snippet to work fine. It works in 3.10.x because there are no typehints, but PHPStan emits an error nevertheless due to PHPDoc types.

How to reproduce

Just use a join with a condition expression that returns a CompositeExpression like and().

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions