-
Notifications
You must be signed in to change notification settings - Fork 48
AggregateModel: Cannot add hasOne reference #984
Copy link
Copy link
Labels
Description
The recent implementation of AggregateModel does not allow to add a hasOne reference (or inherit it from the source model).
Steps to replicate:
$aggregateModel = new \Atk4\Data\Model\AggregateModel($sourcemodel);
$aggregateModel->hasOne('tax_rule_id', ['model' => [TaxRule::class]]);
$aggregateModel->setGroupBy(['tax_rule_id', 'tax_rate'], [
'total_gross' => ['expr' => 'sum([total_gross])'],
'total_net' => ['expr' => 'sum([total_net])'],
'total_tax' => ['expr' => 'sum([total_tax])'],
]);
Expected result:
$targetmodel->ref('tax_rule_id') returns hasOne-linked model.
Result:
Error in vendor/atk4/data/src/Reference.php:224saying TypeError: preg_quote(): Argument #1 ($str) must be of type string, null given
Reactions are currently unavailable