Commit da000165 by Klimov Paul

Method 'oneWithUpdate' renamed to 'oneWithModify' at `yii\mongodb\Query`

parent b819a678
...@@ -169,9 +169,9 @@ class ActiveQuery extends Query implements ActiveQueryInterface ...@@ -169,9 +169,9 @@ class ActiveQuery extends Query implements ActiveQueryInterface
* Depending on the setting of [[asArray]], the query result may be either an array or an ActiveRecord object. * Depending on the setting of [[asArray]], the query result may be either an array or an ActiveRecord object.
* Null will be returned if the query results in nothing. * Null will be returned if the query results in nothing.
*/ */
public function oneWithUpdate($update, $options = [], $db = null) public function oneWithModify($update, $options = [], $db = null)
{ {
$row = parent::oneWithUpdate($update, $options, $db); $row = parent::oneWithModify($update, $options, $db);
if ($row !== null) { if ($row !== null) {
$models = $this->populate([$row]); $models = $this->populate([$row]);
return reset($models) ?: null; return reset($models) ?: null;
......
...@@ -205,7 +205,7 @@ class Query extends Component implements QueryInterface ...@@ -205,7 +205,7 @@ class Query extends Component implements QueryInterface
* @param Connection $db the Mongo connection used to execute the query. * @param Connection $db the Mongo connection used to execute the query.
* @return array|null the original document, or the modified document when $options['new'] is set. * @return array|null the original document, or the modified document when $options['new'] is set.
*/ */
public function oneWithUpdate($update, $options = [], $db = null) public function oneWithModify($update, $options = [], $db = null)
{ {
$collection = $this->getCollection($db); $collection = $this->getCollection($db);
if (!empty($this->orderBy)) { if (!empty($this->orderBy)) {
......
...@@ -264,14 +264,14 @@ class ActiveRecordTest extends MongoDbTestCase ...@@ -264,14 +264,14 @@ class ActiveRecordTest extends MongoDbTestCase
$this->assertEquals(7, $rowRefreshed->status); $this->assertEquals(7, $rowRefreshed->status);
} }
public function testFindOneWithUpdate() public function testFindOneWithModify()
{ {
$searchName = 'name7'; $searchName = 'name7';
$newName = 'new name'; $newName = 'new name';
$customer = Customer::find() $customer = Customer::find()
->where(['name' => $searchName]) ->where(['name' => $searchName])
->oneWithUpdate(['$set' => ['name' => $newName]], ['new' => true]); ->oneWithModify(['$set' => ['name' => $newName]], ['new' => true]);
$this->assertTrue($customer instanceof Customer); $this->assertTrue($customer instanceof Customer);
$this->assertEquals($newName, $customer->name); $this->assertEquals($newName, $customer->name);
} }
......
...@@ -211,7 +211,7 @@ class QueryRunTest extends MongoDbTestCase ...@@ -211,7 +211,7 @@ class QueryRunTest extends MongoDbTestCase
$this->assertEquals($rows, $rowsUppercase); $this->assertEquals($rows, $rowsUppercase);
} }
public function testOneWithUpdate() public function testOneWithModify()
{ {
$connection = $this->getConnection(); $connection = $this->getConnection();
...@@ -221,14 +221,14 @@ class QueryRunTest extends MongoDbTestCase ...@@ -221,14 +221,14 @@ class QueryRunTest extends MongoDbTestCase
$newName = 'new name'; $newName = 'new name';
$row = $query->from('customer') $row = $query->from('customer')
->where(['name' => $searchName]) ->where(['name' => $searchName])
->oneWithUpdate(['$set' => ['name' => $newName]], ['new' => false], $connection); ->oneWithModify(['$set' => ['name' => $newName]], ['new' => false], $connection);
$this->assertEquals($searchName, $row['name']); $this->assertEquals($searchName, $row['name']);
$searchName = 'name7'; $searchName = 'name7';
$newName = 'new name'; $newName = 'new name';
$row = $query->from('customer') $row = $query->from('customer')
->where(['name' => $searchName]) ->where(['name' => $searchName])
->oneWithUpdate(['$set' => ['name' => $newName]], ['new' => true], $connection); ->oneWithModify(['$set' => ['name' => $newName]], ['new' => true], $connection);
$this->assertEquals($newName, $row['name']); $this->assertEquals($newName, $row['name']);
} }
......
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