Skip to content

Commit ef96440

Browse files
authored
Document that from subquery may be built using eloquent builders (#44705)
1 parent cea7ba0 commit ef96440

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Illuminate/Database/Query/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ public function distinct()
439439
/**
440440
* Set the table which the query is targeting.
441441
*
442-
* @param \Closure|\Illuminate\Database\Query\Builder|string $table
442+
* @param \Closure|\Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder|string $table
443443
* @param string|null $as
444444
* @return $this
445445
*/

tests/Database/DatabaseQueryBuilderTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5231,6 +5231,18 @@ public function testWhereJsonLengthSqlServer()
52315231
$this->assertEquals([1], $builder->getBindings());
52325232
}
52335233

5234+
public function testFrom()
5235+
{
5236+
$builder = $this->getBuilder();
5237+
$builder->from($this->getBuilder()->from('users'), 'u');
5238+
$this->assertSame('select * from (select * from "users") as "u"', $builder->toSql());
5239+
5240+
$builder = $this->getBuilder();
5241+
$eloquentBuilder = new EloquentBuilder($this->getBuilder());
5242+
$builder->from($eloquentBuilder->from('users'), 'u');
5243+
$this->assertSame('select * from (select * from "users") as "u"', $builder->toSql());
5244+
}
5245+
52345246
public function testFromSub()
52355247
{
52365248
$builder = $this->getBuilder();

0 commit comments

Comments
 (0)