Skip to content

Commit abc9fb6

Browse files
Merge branch 'main' into fix/test-split
2 parents 2f90bb4 + cd55117 commit abc9fb6

9 files changed

Lines changed: 332 additions & 147 deletions

File tree

composer.lock

Lines changed: 52 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Database/Adapter.php

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
abstract class Adapter
1212
{
1313
protected string $database = '';
14+
protected string $hostname = '';
1415

1516
protected string $namespace = '';
1617

@@ -79,15 +80,15 @@ public function resetDebug(): static
7980
*
8081
* @param string $namespace
8182
*
82-
* @return bool
83+
* @return $this
8384
* @throws DatabaseException
8485
*
8586
*/
86-
public function setNamespace(string $namespace): bool
87+
public function setNamespace(string $namespace): static
8788
{
8889
$this->namespace = $this->filter($namespace);
8990

90-
return true;
91+
return $this;
9192
}
9293

9394
/**
@@ -103,6 +104,29 @@ public function getNamespace(): string
103104
return $this->namespace;
104105
}
105106

107+
/**
108+
* Set Hostname.
109+
*
110+
* @param string $hostname
111+
* @return $this
112+
*/
113+
public function setHostname(string $hostname): static
114+
{
115+
$this->hostname = $hostname;
116+
117+
return $this;
118+
}
119+
120+
/**
121+
* Get Hostname.
122+
*
123+
* @return string
124+
*/
125+
public function getHostname(): string
126+
{
127+
return $this->hostname;
128+
}
129+
106130
/**
107131
* Set Database.
108132
*
@@ -950,8 +974,20 @@ abstract public function getSupportForUpserts(): bool;
950974
*/
951975
abstract public function getSupportForCacheSkipOnFailure(): bool;
952976

977+
/**
978+
* Is reconnection supported?
979+
*
980+
* @return bool
981+
*/
953982
abstract public function getSupportForReconnection(): bool;
954983

984+
/**
985+
* Is hostname supported?
986+
*
987+
* @return bool
988+
*/
989+
abstract public function getSupportForHostname(): bool;
990+
955991
/**
956992
* Get current attribute count from collection document
957993
*

src/Database/Adapter/MariaDB.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,13 @@ public function deleteCollection(string $id): bool
331331

332332
$sql = $this->trigger(Database::EVENT_COLLECTION_DELETE, $sql);
333333

334-
return $this->getPDO()
335-
->prepare($sql)
336-
->execute();
334+
try {
335+
return $this->getPDO()
336+
->prepare($sql)
337+
->execute();
338+
} catch (PDOException $e) {
339+
throw $this->processException($e);
340+
}
337341
}
338342

339343
/**
@@ -2284,6 +2288,13 @@ protected function processException(PDOException $e): \Exception
22842288
return new NotFoundException('Collection not found', $e->getCode(), $e);
22852289
}
22862290

2291+
// Unknown collection
2292+
// We have two of same, because docs point to 1051.
2293+
// Keeping previous 1049 (above) just in case it's for older versions
2294+
if ($e->getCode() === '42S02' && isset($e->errorInfo[1]) && $e->errorInfo[1] === 1051) {
2295+
return new NotFoundException('Collection not found', $e->getCode(), $e);
2296+
}
2297+
22872298
return $e;
22882299
}
22892300

0 commit comments

Comments
 (0)