Skip to content

Commit

Permalink
u
Browse files Browse the repository at this point in the history
  • Loading branch information
bohanyang committed Sep 24, 2023
1 parent 3cd1c21 commit 95e4ff4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
21 changes: 19 additions & 2 deletions packages/mango/Doctrine/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -866,9 +866,17 @@ public function gte(string|array $x, $y): string
return $this->comparison($x, '>=', $y);
}

public function executeStatement(?int $rowsAffected = null): int
public function executeStatement(?int $rowsAffected = null, ?callable $preprocess = null): int
{
$actual = $this->builder->executeStatement();
$sql = $this->getSQL();
$params = $this->getParameters();
$types = $this->getParameterTypes();

if ($preprocess) {
$preprocess($sql, $params, $types);
}

$actual = $this->connection->executeStatement($sql, $params, $types);

if ($actual !== ($rowsAffected ?? $actual)) {
throw UnexpectedRowsAffected::create($rowsAffected, $actual);
Expand Down Expand Up @@ -919,4 +927,13 @@ public function where(mixed ...$expressions): self

return $this;
}

public function onConflictDoNothing(string|array $conflict, ?int $rowsAffected = null): int
{
$conflict = array_map(static fn ($n) => $this->quoteColumn($n), (array) $conflict);

return $this->executeStatement($rowsAffected, static function (&$sql) use ($conflict) {
$sql .= ' ON CONFLICT (' . implode(', ', $conflict) . ') DO NOTHING';
});
}
}
4 changes: 1 addition & 3 deletions packages/mango/Jose/CachedJWKSLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\ItemInterface;

use function spl_object_hash;

class CachedJWKSLoader implements JWKSLoader
{
public function __construct(
Expand All @@ -27,7 +25,7 @@ public function __construct(

public function __invoke(): JWKSet
{
return $this->cache->get(spl_object_hash($this), function (ItemInterface $item) {
return $this->cache->get($this->url, function (ItemInterface $item) {
$item->expiresAfter($this->expiresAfter);

return $this->jkuFactory->loadFromUrl($this->url, $this->header);
Expand Down

0 comments on commit 95e4ff4

Please sign in to comment.