Commit b8c9d515 by Klimov Paul

Merge branch 'master' of github.com:yiisoft/yii2

parents 3f001aee 2a75cd19
......@@ -35,6 +35,11 @@ class Customer extends ActiveRecord
return $this->hasMany(Order::className(), ['customer_id' => 'id'])->orderBy('created_at');
}
public function getOrdersWithNullFK()
{
return $this->hasMany(OrderWithNullFK::className(), ['customer_id' => 'id'])->orderBy('created_at');
}
public function afterSave($insert)
{
ActiveRecordTest::$afterSaveInsert = $insert;
......
......@@ -28,6 +28,14 @@ class Customer extends ActiveRecord
}
/**
* @return \yii\redis\ActiveQuery
*/
public function getOrdersWithNullFK()
{
return $this->hasMany(OrderWithNullFK::className(), ['customer_id' => 'id']);
}
/**
* @inheritdoc
*/
public function afterSave($insert)
......
<?php
namespace yiiunit\data\ar\redis;
/**
* Class OrderItem
*
* @property integer $order_id
* @property integer $item_id
* @property integer $quantity
* @property string $subtotal
*/
class OrderItemWithNullFK extends ActiveRecord
{
public static function primaryKey()
{
return ['order_id', 'item_id'];
}
public function attributes()
{
return ['order_id', 'item_id', 'quantity', 'subtotal'];
}
}
<?php
namespace yiiunit\data\ar\redis;
/**
* Class Order
*
* @property integer $id
* @property integer $customer_id
* @property integer $created_at
* @property string $total
*/
class OrderWithNullFK extends ActiveRecord
{
public static function primaryKey()
{
return ['id'];
}
public function attributes()
{
return ['id', 'customer_id', 'created_at', 'total'];
}
}
......@@ -72,7 +72,7 @@ CREATE TABLE "order_item_with_null_fk" (
order_id INTEGER,
item_id INTEGER,
quantity INTEGER NOT NULL,
subtotal decimal(10,0) NOT NULL,
subtotal decimal(10,0) NOT NULL
);
CREATE TABLE "composite_fk" (
......
......@@ -8,6 +8,8 @@ use yiiunit\data\ar\redis\Customer;
use yiiunit\data\ar\redis\OrderItem;
use yiiunit\data\ar\redis\Order;
use yiiunit\data\ar\redis\Item;
use yiiunit\data\ar\redis\OrderItemWithNullFK;
use yiiunit\data\ar\redis\OrderWithNullFK;
use yiiunit\framework\ar\ActiveRecordTestTrait;
/**
......@@ -37,6 +39,16 @@ class ActiveRecordTest extends RedisTestCase
return OrderItem::className();
}
public function getOrderWithNullFKClass()
{
return OrderWithNullFK::className();
}
public function getOrderItemWithNullFKmClass()
{
return OrderItemWithNullFK::className();
}
public function setUp()
{
parent::setUp();
......
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