Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 21, 2021
2 parents 57d148d + 006873d commit c05390b
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 27 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG-6.x.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
# Release Notes for 6.x

## [Unreleased](https://github.com/laravel/framework/compare/v6.20.10...6.x)
## [Unreleased](https://github.com/laravel/framework/compare/v6.20.13...6.x)


## [v6.20.13 (2021-01-19)](https://github.com/laravel/framework/compare/v6.20.12...v6.20.13)

### Fixed
- Fixed empty html mail ([#35941](https://github.com/laravel/framework/pull/35941))


## [v6.20.12 (2021-01-13)](https://github.com/laravel/framework/compare/v6.20.11...v6.20.12)


## [v6.20.11 (2021-01-13)](https://github.com/laravel/framework/compare/v6.20.10...v6.20.11)

### Fixed
- Limit expected bindings ([#35865](https://github.com/laravel/framework/pull/35865))


## [v6.20.10 (2021-01-12)](https://github.com/laravel/framework/compare/v6.20.9...v6.20.10)
Expand Down
31 changes: 21 additions & 10 deletions src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
);

if (! $value instanceof Expression) {
$this->addBinding(is_array($value) ? head($value) : $value, 'where');
$this->addBinding($this->flattenValue($value), 'where');
}

return $this;
Expand Down Expand Up @@ -1078,7 +1078,7 @@ public function whereBetween($column, array $values, $boolean = 'and', $not = fa

$this->wheres[] = compact('type', 'column', 'values', 'boolean', 'not');

$this->addBinding(array_slice($this->cleanBindings($values), 0, 2), 'where');
$this->addBinding(array_slice($this->cleanBindings(Arr::flatten($values)), 0, 2), 'where');

return $this;
}
Expand Down Expand Up @@ -1201,7 +1201,7 @@ public function whereDate($column, $operator, $value = null, $boolean = 'and')
$value, $operator, func_num_args() === 2
);

$value = is_array($value) ? head($value) : $value;
$value = $this->flattenValue($value);

if ($value instanceof DateTimeInterface) {
$value = $value->format('Y-m-d');
Expand Down Expand Up @@ -1242,7 +1242,7 @@ public function whereTime($column, $operator, $value = null, $boolean = 'and')
$value, $operator, func_num_args() === 2
);

$value = is_array($value) ? head($value) : $value;
$value = $this->flattenValue($value);

if ($value instanceof DateTimeInterface) {
$value = $value->format('H:i:s');
Expand Down Expand Up @@ -1283,7 +1283,7 @@ public function whereDay($column, $operator, $value = null, $boolean = 'and')
$value, $operator, func_num_args() === 2
);

$value = is_array($value) ? head($value) : $value;
$value = $this->flattenValue($value);

if ($value instanceof DateTimeInterface) {
$value = $value->format('d');
Expand Down Expand Up @@ -1328,7 +1328,7 @@ public function whereMonth($column, $operator, $value = null, $boolean = 'and')
$value, $operator, func_num_args() === 2
);

$value = is_array($value) ? head($value) : $value;
$value = $this->flattenValue($value);

if ($value instanceof DateTimeInterface) {
$value = $value->format('m');
Expand Down Expand Up @@ -1373,7 +1373,7 @@ public function whereYear($column, $operator, $value = null, $boolean = 'and')
$value, $operator, func_num_args() === 2
);

$value = is_array($value) ? head($value) : $value;
$value = $this->flattenValue($value);

if ($value instanceof DateTimeInterface) {
$value = $value->format('Y');
Expand Down Expand Up @@ -1683,7 +1683,7 @@ public function whereJsonLength($column, $operator, $value = null, $boolean = 'a
$this->wheres[] = compact('type', 'column', 'operator', 'value', 'boolean');

if (! $value instanceof Expression) {
$this->addBinding((int) $value);
$this->addBinding((int) $this->flattenValue($value));
}

return $this;
Expand Down Expand Up @@ -1832,7 +1832,7 @@ public function having($column, $operator = null, $value = null, $boolean = 'and
$this->havings[] = compact('type', 'column', 'operator', 'value', 'boolean');

if (! $value instanceof Expression) {
$this->addBinding(is_array($value) ? head($value) : $value, 'having');
$this->addBinding($this->flattenValue($value), 'having');
}

return $this;
Expand Down Expand Up @@ -1870,7 +1870,7 @@ public function havingBetween($column, array $values, $boolean = 'and', $not = f

$this->havings[] = compact('type', 'column', 'values', 'boolean', 'not');

$this->addBinding($this->cleanBindings($values), 'having');
$this->addBinding(array_slice($this->cleanBindings(Arr::flatten($values)), 0, 2), 'having');

return $this;
}
Expand Down Expand Up @@ -3092,6 +3092,17 @@ protected function cleanBindings(array $bindings)
}));
}

/**
* Get a scalar type value from an unknown type of input.
*
* @param mixed $value
* @return mixed
*/
protected function flattenValue($value)
{
return is_array($value) ? head(Arr::flatten($value)) : $value;
}

/**
* Get the default key name of the table.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Http/Concerns/InteractsWithContentTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static function matchesType($actual, $type)
*/
public function isJson()
{
return Str::contains($this->header('CONTENT_TYPE'), ['/json', '+json']);
return Str::contains($this->header('CONTENT_TYPE') ?? '', ['/json', '+json']);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ protected function parseView($view)
protected function addContent($message, $view, $plain, $raw, $data)
{
if (isset($view)) {
$message->setBody($this->renderView($view, $data), 'text/html');
$message->setBody($this->renderView($view, $data) ?: ' ', 'text/html');
}

if (isset($plain)) {
Expand Down
52 changes: 38 additions & 14 deletions tests/Database/DatabaseQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,20 +305,25 @@ public function testWheresWithArrayValue()
$this->assertSame('select * from "users" where "id" = ?', $builder->toSql());
$this->assertEquals([0 => 12], $builder->getBindings());

// $builder = $this->getBuilder();
// $builder->select('*')->from('users')->where('id', '=', [12, 30]);
// $this->assertSame('select * from "users" where "id" = ?', $builder->toSql());
// $this->assertEquals([0 => 12, 1 => 30], $builder->getBindings());
$builder = $this->getBuilder();
$builder->select('*')->from('users')->where('id', '=', [12, 30]);
$this->assertSame('select * from "users" where "id" = ?', $builder->toSql());
$this->assertEquals([0 => 12], $builder->getBindings());

// $builder = $this->getBuilder();
// $builder->select('*')->from('users')->where('id', '!=', [12, 30]);
// $this->assertSame('select * from "users" where "id" != ?', $builder->toSql());
// $this->assertEquals([0 => 12, 1 => 30], $builder->getBindings());
$builder = $this->getBuilder();
$builder->select('*')->from('users')->where('id', '!=', [12, 30]);
$this->assertSame('select * from "users" where "id" != ?', $builder->toSql());
$this->assertEquals([0 => 12], $builder->getBindings());

// $builder = $this->getBuilder();
// $builder->select('*')->from('users')->where('id', '<>', [12, 30]);
// $this->assertSame('select * from "users" where "id" <> ?', $builder->toSql());
// $this->assertEquals([0 => 12, 1 => 30], $builder->getBindings());
$builder = $this->getBuilder();
$builder->select('*')->from('users')->where('id', '<>', [12, 30]);
$this->assertSame('select * from "users" where "id" <> ?', $builder->toSql());
$this->assertEquals([0 => 12], $builder->getBindings());

$builder = $this->getBuilder();
$builder->select('*')->from('users')->where('id', '=', [[12, 30]]);
$this->assertSame('select * from "users" where "id" = ?', $builder->toSql());
$this->assertEquals([0 => 12], $builder->getBindings());
}

public function testMySqlWrappingProtectsQuotationMarks()
Expand Down Expand Up @@ -649,6 +654,16 @@ public function testWhereBetweens()
$this->assertSame('select * from "users" where "id" between ? and ?', $builder->toSql());
$this->assertEquals([0 => 1, 1 => 2], $builder->getBindings());

$builder = $this->getBuilder();
$builder->select('*')->from('users')->whereBetween('id', [[1, 2, 3]]);
$this->assertSame('select * from "users" where "id" between ? and ?', $builder->toSql());
$this->assertEquals([0 => 1, 1 => 2], $builder->getBindings());

$builder = $this->getBuilder();
$builder->select('*')->from('users')->whereBetween('id', [[1], [2, 3]]);
$this->assertSame('select * from "users" where "id" between ? and ?', $builder->toSql());
$this->assertEquals([0 => 1, 1 => 2], $builder->getBindings());

$builder = $this->getBuilder();
$builder->select('*')->from('users')->whereNotBetween('id', [1, 2]);
$this->assertSame('select * from "users" where "id" not between ? and ?', $builder->toSql());
Expand Down Expand Up @@ -1244,10 +1259,19 @@ public function testHavings()
$builder = $this->getBuilder();
$builder->select(['category', new Raw('count(*) as "total"')])->from('item')->where('department', '=', 'popular')->groupBy('category')->having('total', '>', 3);
$this->assertSame('select "category", count(*) as "total" from "item" where "department" = ? group by "category" having "total" > ?', $builder->toSql());
}

public function testHavingBetweens()
{
$builder = $this->getBuilder();
$builder->select('*')->from('users')->havingBetween('id', [1, 2, 3]);
$this->assertSame('select * from "users" having "id" between ? and ?', $builder->toSql());
$this->assertEquals([0 => 1, 1 => 2], $builder->getBindings());

$builder = $this->getBuilder();
$builder->select('*')->from('users')->havingBetween('last_login_date', ['2018-11-16', '2018-12-16']);
$this->assertSame('select * from "users" having "last_login_date" between ? and ?', $builder->toSql());
$builder->select('*')->from('users')->havingBetween('id', [[1, 2], [3, 4]]);
$this->assertSame('select * from "users" having "id" between ? and ?', $builder->toSql());
$this->assertEquals([0 => 1, 1 => 2], $builder->getBindings());
}

public function testHavingShortcut()
Expand Down

0 comments on commit c05390b

Please sign in to comment.