Skip to content

Commit

Permalink
Merge pull request #6462 from cakephp/orm-query-update
Browse files Browse the repository at this point in the history
Adding a test to show it is possible to pass an expression in Query::update
  • Loading branch information
markstory committed May 1, 2015
2 parents 12caa77 + 5790c3b commit bc2d222
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/TestCase/ORM/QueryTest.php
Expand Up @@ -1537,6 +1537,27 @@ public function testUpdate()
$this->assertTrue($result->rowCount() > 0);
}

/**
* Test update method.
*
* @return void
*/
public function testUpdateWithTableExpression()
{
$this->skipIf(!$this->connection->driver() instanceof \Cake\Database\Driver\Mysql);
$table = TableRegistry::get('articles');

$query = $table->query();
$result = $query->update($query->newExpr('articles, authors'))
->set(['title' => 'First'])
->where(['articles.author_id = authors.id'])
->andWhere(['authors.name' => 'mariano'])
->execute();

$this->assertInstanceOf('Cake\Database\StatementInterface', $result);
$this->assertTrue($result->rowCount() > 0);
}

/**
* Test insert method.
*
Expand Down

0 comments on commit bc2d222

Please sign in to comment.