nextras / orm

Orm with clean object design, smart relationship loading and powerful collections.
https://nextras.org/orm
MIT License
309 stars 59 forks source link

Embeddables doesn´t support relationships #427

Closed Ivorius closed 4 years ago

Ivorius commented 4 years ago

It can not be used relationship in embeddables because throw exception Nextras\Orm\NullValueException

Property ...\Order::$country is not nullable

/**
 * @property-read string|NULL $street
 * @property-read string|NULL $city
 * @property-read string|NULL $postCode
 * @property Country $country {default CZ} {m:1 Country, oneSided=true}
 */
class Address extends \Nextras\Orm\Entity\Embeddable\Embeddable
{
    public function __construct(string $street, string $city, string $postCode, Country $country)
    {
        parent::__construct([
            'street' => $street,
            'city' => $city,
            'postCode' => $postCode,
            'country' => $country,
        ]);
    }
}

Mapping

        $conventions->setMapping('address->street', 'street');
        $conventions->setMapping('address->city', 'town');
        $conventions->setMapping('address->postCode', 'postcode');
        $conventions->setMapping('address->country', 'country_code');

Versions::

hrach commented 4 years ago

In the end, this is not really not supported. Please see for future enhancements and implementation: https://github.com/nextras/orm/issues/430