cycle/orm

๐Ÿ› load null relation with Embeddable

gam6itko opened this issue ยท 0 comments

No duplicates ๐Ÿฅฒ.

  • I have searched for a similar issue in our bug tracker and didn't find any solutions.

What happened?

If i load null relation entity with Embeddable the error occurs.

[TypeError]
Cycle\ORM\Parser\MultiKeyCollection::getLastItemKeys(): Return value must be of type array, null returned in vendor/cycle/orm/src/Parser/MultiKeyCollection.php:65

Example classes

class User
{
    #[Cycle\Relation\HasOne(target: Billing::class, outerKey: 'user_id', nullable: true)]
    private ?Billing $billing = null;
}
class Billing
{
    #[Cycle\Relation\Embedded(target: SomeEmbedded::class)]
    private SomeEmbedded $someEmbedded;
}
#[Cycle\Embeddable(columnPrefix: 'foo_')]
class SomeEmbedded
{
    #[Cycle\Column(type: 'decimal(12,2)', default: 0)]
    public float $propertyDecimal = 0;

    #[Cycle\Column(type: 'integer', default: 0)]
    public int $propertyInt = 0;
}

// reproduce bug

$this->gerRepository(User::class)
    ->select()
    ->load('billing')
    ->where('id', $someId)
    ->fetchData();

Version

ORM 2.3.2
PHP 8.1