Commit a5c4a0eb by Alexander Makarov

Adjusted BaseActiveRecord code for better noSQL compatibility

parent ed041f7a
......@@ -1297,8 +1297,6 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
public function unlinkAll($name, $delete = false)
{
$relation = $this->getRelation($name);
/** @var Command $command */
$command = static::getDb()->createCommand();
$columns = [];
$condition = [];
if (empty($relation->via)) {
......@@ -1308,18 +1306,22 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
foreach ($relation->link as $a => $b) {
$condition[$a] = $this->$b;
}
$command->delete($viaClass::tableName(), $condition)->execute();
$viaClass::deleteAll($condition);
} else {
foreach ($relation->link as $a => $b) {
$columns[$a] = null;
$condition[$a] = $this->$b;
}
$command->update($viaClass::tableName(), $columns, $condition)->execute();
$viaClass::updateAll($columns, $condition);
}
} else {
$viaTable = $viaTable = reset($relation->via->from);
$viaTable = reset($relation->via->from);
/** @var ActiveQuery $viaRelation */
$viaRelation = $relation->via;
/** @var Command $command */
$command = static::getDb()->createCommand();
if ($delete) {
foreach ($viaRelation->link as $a => $b) {
$condition[$a] = $this->$b;
......
......@@ -45,6 +45,10 @@ trait ActiveRecordTestTrait
*/
abstract public function getItemClass();
abstract public function getOrderWithNullFKClass();
abstract public function getOrderItemWithNullFKmClass();
/**
* can be overridden to do things after save()
*/
......@@ -724,7 +728,7 @@ trait ActiveRecordTestTrait
public function testUnlinkAll()
{
/** @var \yii\db\ActiveRecordInterface $customerClass */
/** @var \yii\db\ActiveRecordInterface $customewdfsdfdfsfd
$customerClass = $this->getCustomerClass();
/** @var \yii\db\ActiveRecordInterface $orderClass */
$orderClass = $this->getOrderClass();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment