Commit 12f9180b by Paul Klimov

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

parent 33c16380
......@@ -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.
* Null will be returned if the query results in nothing.
*/
public function oneWithModify($update, $options = [], $db = null)
public function modify($update, $options = [], $db = null)
{
$row = parent::oneWithModify($update, $options, $db);
$row = parent::modify($update, $options, $db);
if ($row !== null) {
$models = $this->populate([$row]);
return reset($models) ?: null;
......
......@@ -205,7 +205,7 @@ class Query extends Component implements QueryInterface
* @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.
*/
public function oneWithModify($update, $options = [], $db = null)
public function modify($update, $options = [], $db = null)
{
$collection = $this->getCollection($db);
if (!empty($this->orderBy)) {
......
......@@ -264,14 +264,14 @@ class ActiveRecordTest extends MongoDbTestCase
$this->assertEquals(7, $rowRefreshed->status);
}
public function testFindOneWithModify()
public function testModify()
{
$searchName = 'name7';
$newName = 'new name';
$customer = Customer::find()
->where(['name' => $searchName])
->oneWithModify(['$set' => ['name' => $newName]], ['new' => true]);
->modify(['$set' => ['name' => $newName]], ['new' => true]);
$this->assertTrue($customer instanceof Customer);
$this->assertEquals($newName, $customer->name);
}
......
......@@ -211,7 +211,7 @@ class QueryRunTest extends MongoDbTestCase
$this->assertEquals($rows, $rowsUppercase);
}
public function testOneWithModify()
public function testModify()
{
$connection = $this->getConnection();
......@@ -221,14 +221,14 @@ class QueryRunTest extends MongoDbTestCase
$newName = 'new name';
$row = $query->from('customer')
->where(['name' => $searchName])
->oneWithModify(['$set' => ['name' => $newName]], ['new' => false], $connection);
->modify(['$set' => ['name' => $newName]], ['new' => false], $connection);
$this->assertEquals($searchName, $row['name']);
$searchName = 'name7';
$newName = 'new name';
$row = $query->from('customer')
->where(['name' => $searchName])
->oneWithModify(['$set' => ['name' => $newName]], ['new' => true], $connection);
->modify(['$set' => ['name' => $newName]], ['new' => true], $connection);
$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