Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.6] orWhereDate should accept only two arguments #24043

Merged
merged 1 commit into from Apr 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1078,10 +1078,10 @@ public function whereDate($column, $operator, $value = null, $boolean = 'and')
*
* @param string $column
* @param string $operator
* @param string $value
* @param mixed $value
* @return \Illuminate\Database\Query\Builder|static
*/
public function orWhereDate($column, $operator, $value)
public function orWhereDate($column, $operator, $value = null)
{
list($value, $operator) = $this->prepareValueAndOperator(
$value, $operator, func_num_args() == 2
Expand Down
19 changes: 19 additions & 0 deletions tests/Database/DatabaseQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,25 @@ public function testDateBasedWheresAcceptsTwoArguments()
$this->assertEquals('select * from `users` where year(`created_at`) = ?', $builder->toSql());
}

public function testDateBasedOrWheresAcceptsTwoArguments()
{
$builder = $this->getMySqlBuilder();
$builder->select('*')->from('users')->where('id', 1)->orWhereDate('created_at', 1);
$this->assertEquals('select * from `users` where `id` = ? or date(`created_at`) = ?', $builder->toSql());

$builder = $this->getMySqlBuilder();
$builder->select('*')->from('users')->where('id', 1)->orWhereDay('created_at', 1);
$this->assertEquals('select * from `users` where `id` = ? or day(`created_at`) = ?', $builder->toSql());

$builder = $this->getMySqlBuilder();
$builder->select('*')->from('users')->where('id', 1)->orWhereMonth('created_at', 1);
$this->assertEquals('select * from `users` where `id` = ? or month(`created_at`) = ?', $builder->toSql());

$builder = $this->getMySqlBuilder();
$builder->select('*')->from('users')->where('id', 1)->orWhereyear('created_at', 1);
$this->assertEquals('select * from `users` where `id` = ? or year(`created_at`) = ?', $builder->toSql());
}

public function testDateBasedWheresExpressionIsNotBound()
{
$builder = $this->getBuilder();
Expand Down