Skip to content

Commit

Permalink
Changed subquery() to static function and use connection from Table
Browse files Browse the repository at this point in the history
  • Loading branch information
othercorey committed Jul 17, 2020
1 parent 2dd79ba commit 1e8a996
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/ORM/Query.php
Expand Up @@ -1306,9 +1306,9 @@ public function insert(array $columns, array $types = [])
* @param \Cake\ORM\Table $table The table this query is starting on
* @return static
*/
public function subquery(Table $table)
public static function subquery(Table $table)
{
$query = new static($this->getConnection(), $table);
$query = new static($table->getConnection(), $table);
$query->aliasingEnabled = false;

return $query;
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/ORM/QueryTest.php
Expand Up @@ -4009,8 +4009,8 @@ public function testWith(): void
*/
public function testSubqueryConnection()
{
$subquery = (new Query($this->connection, $this->table))->subquery($this->table);
$this->assertEquals($this->connection, $subquery->getConnection());
$subquery = Query::subquery($this->table);
$this->assertEquals($this->table->getConnection(), $subquery->getConnection());
}

/**
Expand All @@ -4021,7 +4021,7 @@ public function testSubqueryConnection()
public function testSubqueryAliasing()
{
$articles = $this->getTableLocator()->get('Articles');
$subquery = (new Query($this->connection, $this->table))->subquery($articles);
$subquery = Query::subquery($articles);

$subquery->select('Articles.field1');
$this->assertRegExpSql(
Expand Down

0 comments on commit 1e8a996

Please sign in to comment.