Skip to content

Commit 4cf2e4f

Browse files
Merge branch '5.7'
2 parents ca13d0e + adb72b4 commit 4cf2e4f

File tree

11 files changed

+140
-7
lines changed

11 files changed

+140
-7
lines changed

CHANGELOG-5.7.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Release Notes for 5.7.x
22

3+
## Unreleased
4+
5+
### Added
6+
- Added `Database\Query\Builder::insertUsing` method ([#26732](https://github.com/laravel/framework/pull/26732), [8216b46](https://github.com/laravel/framework/commit/8216b4607152f9b01f26efba6b045add5382c625))
7+
- Added `Database\Query\Builder::havingBetween` method ([#26758](https://github.com/laravel/framework/pull/26758))
8+
- Added `Packets out of order. Expected` string to `DetectsLostConnections` trait ([#26760](https://github.com/laravel/framework/pull/26760))
9+
10+
### TODO
11+
- https://github.com/laravel/framework/pull/26775
12+
- https://github.com/laravel/framework/commit/0f9886d0cb17c9d756068e09743f871003cf1b45
13+
14+
315
## [v5.7.16 (2018-12-05)](https://github.com/laravel/framework/compare/v5.7.15...v5.7.16)
416

517
### Added

src/Illuminate/Console/Command.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,14 @@ protected function parseVerbosity($level = null)
543543
return $level;
544544
}
545545

546+
/**
547+
* {@inheritdoc}
548+
*/
549+
public function isHidden()
550+
{
551+
return $this->hidden;
552+
}
553+
546554
/**
547555
* Get the console command arguments.
548556
*

src/Illuminate/Database/Query/Builder.php

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,6 +1717,26 @@ public function orHaving($column, $operator = null, $value = null)
17171717
return $this->having($column, $operator, $value, 'or');
17181718
}
17191719

1720+
/**
1721+
* Add a "having between " clause to the query.
1722+
*
1723+
* @param string $column
1724+
* @param array $values
1725+
* @param string $boolean
1726+
* @param bool $not
1727+
* @return \Illuminate\Database\Query\Builder|static
1728+
*/
1729+
public function havingBetween($column, array $values, $boolean = 'and', $not = false)
1730+
{
1731+
$type = 'between';
1732+
1733+
$this->havings[] = compact('type', 'column', 'values', 'boolean', 'not');
1734+
1735+
$this->addBinding($this->cleanBindings($values), 'having');
1736+
1737+
return $this;
1738+
}
1739+
17201740
/**
17211741
* Add a raw having clause to the query.
17221742
*
@@ -2575,7 +2595,7 @@ public function insert(array $values)
25752595
/**
25762596
* Insert a new record and get the value of the primary key.
25772597
*
2578-
* @param array $values
2598+
* @param array $values
25792599
* @param string|null $sequence
25802600
* @return int
25812601
*/
@@ -2588,6 +2608,23 @@ public function insertGetId(array $values, $sequence = null)
25882608
return $this->processor->processInsertGetId($this, $sql, $values, $sequence);
25892609
}
25902610

2611+
/**
2612+
* Insert new records into the table using a subquery.
2613+
*
2614+
* @param array $columns
2615+
* @param \Closure|\Illuminate\Database\Query\Builder|string $query
2616+
* @return bool
2617+
*/
2618+
public function insertUsing(array $columns, $query)
2619+
{
2620+
[$sql, $bindings] = $this->createSub($query);
2621+
2622+
return $this->connection->insert(
2623+
$this->grammar->compileInsertUsing($this, $columns, $sql),
2624+
$this->cleanBindings($bindings)
2625+
);
2626+
}
2627+
25912628
/**
25922629
* Update a record in the database.
25932630
*
@@ -2624,7 +2661,7 @@ public function updateOrInsert(array $attributes, array $values = [])
26242661
*
26252662
* @param string $column
26262663
* @param float|int $amount
2627-
* @param array $extra
2664+
* @param array $extra
26282665
* @return int
26292666
*/
26302667
public function increment($column, $amount = 1, array $extra = [])
@@ -2645,7 +2682,7 @@ public function increment($column, $amount = 1, array $extra = [])
26452682
*
26462683
* @param string $column
26472684
* @param float|int $amount
2648-
* @param array $extra
2685+
* @param array $extra
26492686
* @return int
26502687
*/
26512688
public function decrement($column, $amount = 1, array $extra = [])

src/Illuminate/Database/Query/Grammars/Grammar.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,8 @@ protected function compileHaving(array $having)
648648
// clause into SQL based on the components that make it up from builder.
649649
if ($having['type'] === 'Raw') {
650650
return $having['boolean'].' '.$having['sql'];
651+
} elseif ($having['type'] === 'between') {
652+
return $this->compileHavingBetween($having);
651653
}
652654

653655
return $this->compileBasicHaving($having);
@@ -668,6 +670,25 @@ protected function compileBasicHaving($having)
668670
return $having['boolean'].' '.$column.' '.$having['operator'].' '.$parameter;
669671
}
670672

673+
/**
674+
* Compile a "between" having clause.
675+
*
676+
* @param array $having
677+
* @return string
678+
*/
679+
protected function compileHavingBetween($having)
680+
{
681+
$between = $having['not'] ? 'not between' : 'between';
682+
683+
$column = $this->wrap($having['column']);
684+
685+
$min = $this->parameter(head($having['values']));
686+
687+
$max = $this->parameter(last($having['values']));
688+
689+
return $having['boolean'].' '.$column.' '.$between.' '.$min.' and '.$max;
690+
}
691+
671692
/**
672693
* Compile the "order by" portions of the query.
673694
*
@@ -848,6 +869,19 @@ public function compileInsertGetId(Builder $query, $values, $sequence)
848869
return $this->compileInsert($query, $values);
849870
}
850871

872+
/**
873+
* Compile an insert statement using a subquery into SQL.
874+
*
875+
* @param \Illuminate\Database\Query\Builder $query
876+
* @param array $columns
877+
* @param string $sql
878+
* @return string
879+
*/
880+
public function compileInsertUsing(Builder $query, array $columns, string $sql)
881+
{
882+
return "insert into {$this->wrapTable($query->from)} ({$this->columnize($columns)}) $sql";
883+
}
884+
851885
/**
852886
* Compile an update statement into SQL.
853887
*

src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ public function compileForeign(Blueprint $blueprint, Fluent $command)
166166
$sql .= $command->initiallyImmediate ? ' initially immediate' : ' initially deferred';
167167
}
168168

169+
if (! is_null($command->notValid)) {
170+
$sql .= ' not valid';
171+
}
172+
169173
return $sql;
170174
}
171175

src/Illuminate/Foundation/Console/ModelMakeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected function createFactory()
7171

7272
$this->call('make:factory', [
7373
'name' => "{$factory}Factory",
74-
'--model' => $this->argument('name'),
74+
'--model' => $this->qualifyClass($this->getNameInput()),
7575
]);
7676
}
7777

src/Illuminate/Mail/Mailable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ public function replyTo($address, $name = null)
553553
}
554554

555555
/**
556-
* Determine if the given recipient is set on the mailable.
556+
* Determine if the given replyTo is set on the mailable.
557557
*
558558
* @param object|array|string $address
559559
* @param string|null $name

src/Illuminate/Support/helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ function data_fill(&$target, $key, $value)
443443
* Get an item from an array or object using "dot" notation.
444444
*
445445
* @param mixed $target
446-
* @param string|array $key
446+
* @param string|array|int $key
447447
* @param mixed $default
448448
* @return mixed
449449
*/

tests/Database/DatabaseEloquentCastsDatabaseStringTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ protected function connection()
104104
/**
105105
* Get a schema builder instance.
106106
*
107-
* @return Schema\Builder
107+
* @return \Illuminate\Database\Schema\Builder
108108
*/
109109
protected function schema()
110110
{

tests/Database/DatabasePostgresSchemaGrammarTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,13 @@ public function testCompileForeign()
729729

730730
$this->assertCount(1, $statements);
731731
$this->assertEquals('alter table "users" add constraint "users_parent_id_foreign" foreign key ("parent_id") references "parents" ("id") on delete cascade deferrable initially deferred', $statements[0]);
732+
733+
$blueprint = new Blueprint('users');
734+
$blueprint->foreign('parent_id')->references('id')->on('parents')->onDelete('cascade')->deferrable()->notValid();
735+
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
736+
737+
$this->assertCount(1, $statements);
738+
$this->assertEquals('alter table "users" add constraint "users_parent_id_foreign" foreign key ("parent_id") references "parents" ("id") on delete cascade deferrable not valid', $statements[0]);
732739
}
733740

734741
public function testAddingGeometry()

0 commit comments

Comments
 (0)