Skip to content

Commit

Permalink
Fixes database offset tests (laravel#37163)
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro authored Apr 28, 2021
1 parent 647d5aa commit 48af1c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,7 @@ public function offset($value)
{
$property = $this->unions ? 'unionOffset' : 'offset';

$this->$property = max(0, $value);
$this->$property = max(0, (int) $value);

return $this;
}
Expand Down
6 changes: 5 additions & 1 deletion tests/Database/DatabaseQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2913,7 +2913,11 @@ public function testSqlServerLimitsAndOffsets()

$builder = $this->getSqlServerBuilder();
$builder->select('*')->from('users')->take('foo')->offset('bar');
$this->assertSame('select * from (select *, row_number() over (order by (select 0)) as row_num from [users]) as temp_table where row_num between 1 and 0 order by row_num', $builder->toSql());
$this->assertSame('select * from [users]', $builder->toSql());

$builder = $this->getSqlServerBuilder();
$builder->select('*')->from('users')->offset('bar');
$this->assertSame('select * from [users]', $builder->toSql());
}

public function testMySqlSoundsLikeOperator()
Expand Down

0 comments on commit 48af1c9

Please sign in to comment.