mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
joinWith implementation cleanup
This commit is contained in:
@ -641,7 +641,6 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
||||
if (!empty($child->join)) {
|
||||
foreach ($child->join as $join) {
|
||||
$this->join[] = $join;
|
||||
$this->populateAliases((array) $join[1]);
|
||||
}
|
||||
}
|
||||
if (!empty($child->union)) {
|
||||
|
@ -851,7 +851,7 @@ class Query extends Component implements QueryInterface
|
||||
*/
|
||||
public static function create($from)
|
||||
{
|
||||
$query = new self([
|
||||
return new self([
|
||||
'where' => $from->where,
|
||||
'limit' => $from->limit,
|
||||
'offset' => $from->offset,
|
||||
@ -867,7 +867,5 @@ class Query extends Component implements QueryInterface
|
||||
'union' => $from->union,
|
||||
'params' => $from->params,
|
||||
]);
|
||||
$query->_aliases = $from->_aliases;
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
@ -115,12 +115,12 @@ class Order extends ActiveRecord
|
||||
->viaTable('order_item', ['order_id' => 'id']);
|
||||
}
|
||||
|
||||
public function getBooksQuerysyntax()
|
||||
{
|
||||
return $this->hasMany(Item::className(), ['id' => 'item_id'])
|
||||
->onCondition(['{{@item}}.category_id' => 1])
|
||||
->viaTable('order_item', ['order_id' => 'id']);
|
||||
}
|
||||
// public function getBooksQuerysyntax()
|
||||
// {
|
||||
// return $this->hasMany(Item::className(), ['id' => 'item_id'])
|
||||
// ->onCondition(['{{@item}}.category_id' => 1])
|
||||
// ->viaTable('order_item', ['order_id' => 'id']);
|
||||
// }
|
||||
|
||||
public function getBooksExplicitA()
|
||||
{
|
||||
@ -129,12 +129,12 @@ class Order extends ActiveRecord
|
||||
->viaTable('order_item', ['order_id' => 'id']);
|
||||
}
|
||||
|
||||
public function getBooksQuerysyntaxA()
|
||||
{
|
||||
return $this->hasMany(Item::className(), ['id' => 'item_id'])->alias('bo')
|
||||
->onCondition(['{{@item}}.category_id' => 1])
|
||||
->viaTable('order_item', ['order_id' => 'id']);
|
||||
}
|
||||
// public function getBooksQuerysyntaxA()
|
||||
// {
|
||||
// return $this->hasMany(Item::className(), ['id' => 'item_id'])->alias('bo')
|
||||
// ->onCondition(['{{@item}}.category_id' => 1])
|
||||
// ->viaTable('order_item', ['order_id' => 'id']);
|
||||
// }
|
||||
|
||||
public function getBookItems()
|
||||
{
|
||||
|
@ -555,7 +555,7 @@ class ActiveRecordTest extends DatabaseTestCase
|
||||
{
|
||||
return [
|
||||
['explicit'], // c
|
||||
['querysyntax'], // {{@customer}}
|
||||
// ['querysyntax'], // {{@customer}}
|
||||
// ['applyAlias'], // $query->applyAlias('customer', 'id') // _aliases are currently not being populated
|
||||
// later getRelationAlias() could be added
|
||||
];
|
||||
@ -761,7 +761,7 @@ class ActiveRecordTest extends DatabaseTestCase
|
||||
// alias is defined in the relation definition
|
||||
// without eager loading
|
||||
$query = Order::find()
|
||||
->joinWith('bookItems', false)// TODO true
|
||||
->joinWith('bookItems', false)
|
||||
->joinWith('movieItems', false)
|
||||
->where(['movies.name' => 'Toy Story']);
|
||||
$orders = $query->all();
|
||||
|
Reference in New Issue
Block a user