-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Credit to @tschallacka Upgraded symfony/yaml to ^5.1 Updated requirement to php 7.4 Changed Exception to Throwable to make the methods compatible with parent class Transport manager was changed in Mail Manager in laravel 7. Removed backports of compileUpsert in SQL grammars Added unit test for dispatcher on changed events that are accepted on the listen() method. Modified Dispatcher so it accepts closures and QueuedClosures and passes handling off to the parent class Added priority sorting for all accepted event types Added serializable protections for emitter and extendable added Serialisation helper for wrapping closures Added constants to get rid of the magic strings in the traits. Co-authored-by: Luke Towers <github@luketowers.ca> Co-authored-by: Michael Dibbets <michael@exit-reizen.nl>
- Loading branch information
1 parent
d0cb705
commit 04230d5
Showing
24 changed files
with
542 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,9 @@ | ||
<?php namespace Winter\Storm\Database\Query\Grammars; | ||
|
||
use Winter\Storm\Database\QueryBuilder; | ||
use Illuminate\Database\Query\Grammars\MySqlGrammar as BaseMysqlGrammer; | ||
use Winter\Storm\Database\Query\Grammars\Concerns\SelectConcatenations; | ||
|
||
class MySqlGrammar extends BaseMysqlGrammer | ||
{ | ||
use SelectConcatenations; | ||
|
||
/** | ||
* Compile an "upsert" statement into SQL. | ||
* | ||
* @param \Winter\Storm\Database\QueryBuilder $query | ||
* @param array $values | ||
* @param array $uniqueBy | ||
* @param array $update | ||
* @return string | ||
*/ | ||
public function compileUpsert(QueryBuilder $query, array $values, array $uniqueBy, array $update) | ||
{ | ||
$sql = $this->compileInsert($query, $values) . ' on duplicate key update '; | ||
|
||
$columns = collect($update)->map(function ($value, $key) { | ||
return is_numeric($key) | ||
? $this->wrap($value) . ' = values(' . $this->wrap($value) . ')' | ||
: $this->wrap($key) . ' = ' . $this->parameter($value); | ||
})->implode(', '); | ||
|
||
return $sql . $columns; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,9 @@ | ||
<?php namespace Winter\Storm\Database\Query\Grammars; | ||
|
||
use Winter\Storm\Database\QueryBuilder; | ||
use Illuminate\Database\Query\Grammars\PostgresGrammar as BasePostgresGrammer; | ||
use Winter\Storm\Database\Query\Grammars\Concerns\SelectConcatenations; | ||
|
||
class PostgresGrammar extends BasePostgresGrammer | ||
{ | ||
use SelectConcatenations; | ||
|
||
/** | ||
* Compile an "upsert" statement into SQL. | ||
* | ||
* @param \Winter\Storm\Database\QueryBuilder $query | ||
* @param array $values | ||
* @param array $uniqueBy | ||
* @param array $update | ||
* @return string | ||
*/ | ||
public function compileUpsert(QueryBuilder $query, array $values, array $uniqueBy, array $update) | ||
{ | ||
$sql = $this->compileInsert($query, $values); | ||
|
||
$sql .= ' on conflict (' . $this->columnize($uniqueBy) . ') do update set '; | ||
|
||
$columns = collect($update)->map(function ($value, $key) { | ||
return is_numeric($key) | ||
? $this->wrap($value) . ' = ' . $this->wrapValue('excluded') . '.' . $this->wrap($value) | ||
: $this->wrap($key) . ' = ' . $this->parameter($value); | ||
})->implode(', '); | ||
|
||
return $sql . $columns; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,9 @@ | ||
<?php namespace Winter\Storm\Database\Query\Grammars; | ||
|
||
use Winter\Storm\Database\QueryBuilder; | ||
use Illuminate\Database\Query\Grammars\SqlServerGrammar as BaseSqlServerGrammar; | ||
use Winter\Storm\Database\Query\Grammars\Concerns\SelectConcatenations; | ||
|
||
class SqlServerGrammar extends BaseSqlServerGrammar | ||
{ | ||
use SelectConcatenations; | ||
|
||
/** | ||
* Compile an "upsert" statement into SQL. | ||
* | ||
* @param \Winter\Storm\Database\QueryBuilder $query | ||
* @param array $values | ||
* @param array $uniqueBy | ||
* @param array $update | ||
* @return string | ||
*/ | ||
public function compileUpsert(QueryBuilder $query, array $values, array $uniqueBy, array $update) | ||
{ | ||
$columns = $this->columnize(array_keys(reset($values))); | ||
|
||
$sql = 'merge ' . $this->wrapTable($query->from) . ' '; | ||
|
||
$parameters = collect($values)->map(function ($record) { | ||
return '(' . $this->parameterize($record) . ')'; | ||
})->implode(', '); | ||
|
||
$sql .= 'using (values ' . $parameters . ') ' . $this->wrapTable('laravel_source') . ' (' . $columns . ') '; | ||
|
||
$on = collect($uniqueBy)->map(function ($column) use ($query) { | ||
return $this->wrap('laravel_source.' . $column) . ' = ' . $this->wrap($query->from . '.' . $column); | ||
})->implode(' and '); | ||
|
||
$sql .= 'on ' . $on . ' '; | ||
|
||
if ($update) { | ||
$update = collect($update)->map(function ($value, $key) { | ||
return is_numeric($key) | ||
? $this->wrap($value) . ' = ' . $this->wrap('laravel_source.' . $value) | ||
: $this->wrap($key) . ' = ' . $this->parameter($value); | ||
})->implode(', '); | ||
|
||
$sql .= 'when matched then update set ' . $update . ' '; | ||
} | ||
|
||
$sql .= 'when not matched then insert (' . $columns . ') values (' . $columns . ')'; | ||
|
||
return $sql; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.