Skip to content

Commit

Permalink
Fix timeouts not thrown
Browse files Browse the repository at this point in the history
  • Loading branch information
abnegate committed Aug 19, 2024
1 parent 0ba61b1 commit ab549c1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/Database/Adapter/MariaDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,7 @@ public function createAttribute(string $collection, string $id, string $type, in
->prepare($sql)
->execute();
} catch (PDOException $e) {
$this->processException($e);
return false;
throw $this->processException($e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Database/Adapter/Mongo.php
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ public function find(string $collection, array $queries = [], ?int $limit = 25,
try {
$results = $this->client->find($name, $filters, $options)->cursor->firstBatch ?? [];
} catch (MongoException $e) {
$this->processException($e);
throw $this->processException($e);
}

if (empty($results)) {
Expand Down
6 changes: 3 additions & 3 deletions src/Database/Adapter/Postgres.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,7 @@ public function createAttribute(string $collection, string $id, string $type, in
->prepare($sql)
->execute();
} catch (PDOException $e) {
$this->processException($e);
return false;
throw $this->processException($e);
}
}

Expand Down Expand Up @@ -1661,6 +1660,7 @@ public function deleteDocument(string $collection, string $id): bool
* @return array<Document>
* @throws DatabaseException
* @throws TimeoutException
* @throws Exception
*/
public function find(string $collection, array $queries = [], ?int $limit = 25, ?int $offset = null, array $orderAttributes = [], array $orderTypes = [], array $cursor = [], string $cursorDirection = Database::CURSOR_AFTER): array
{
Expand Down Expand Up @@ -1804,7 +1804,7 @@ public function find(string $collection, array $queries = [], ?int $limit = 25,
try {
$stmt->execute();
} catch (PDOException $e) {
$this->processException($e);
throw $this->processException($e);
}

$results = $stmt->fetchAll();
Expand Down
15 changes: 13 additions & 2 deletions tests/e2e/Adapter/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -989,10 +989,21 @@ public function testQueryTimeout(): void
if (!$this->getDatabase()->getAdapter()->getSupportForTimeouts()) {
$this->expectNotToPerformAssertions();
}

static::getDatabase()->createCollection('global-timeouts');
$this->assertEquals(true, static::getDatabase()->createAttribute('global-timeouts', 'longtext', Database::VAR_STRING, 100000000, true));

for ($i = 0 ; $i <= 200 ; $i++) {
$this->assertEquals(
true,
static::getDatabase()->createAttribute(
collection: 'global-timeouts',
id: 'longtext',
type: Database::VAR_STRING,
size: 100000000,
required: true
)
);

for ($i = 0 ; $i <= 20 ; $i++) {
static::getDatabase()->createDocument('global-timeouts', new Document([
'longtext' => file_get_contents(__DIR__ . '/../../resources/longtext.txt'),
'$permissions' => [
Expand Down

0 comments on commit ab549c1

Please sign in to comment.