mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
(fix): reject empty project database DSN
This commit is contained in:
1 parent
3ac5cb0c94
commit
f1cefdcd44
2 files changed
+14
-1
No files matched your search
@@ -33,7 +33,11 @@ final class Pool
|
||||
$sharedTables = \array_filter(\explode(',', System::getEnv('_APP_DATABASE_VECTORSDB_SHARED_TABLES', '')));
|
||||
break;
|
||||
default:
|
||||
return $projectDsn ?? '';
|
||||
if (empty($projectDsn)) {
|
||||
throw new Exception(Exception::GENERAL_SERVER_ERROR, "Project database DSN is required for {$type} databases");
|
||||
}
|
||||
|
||||
return $projectDsn;
|
||||
}
|
||||
|
||||
$projectUsesSharedTables = false;
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Platform\Modules\Databases;
|
||||
|
||||
use Appwrite\Extend\Exception;
|
||||
use Appwrite\Platform\Modules\Databases\Pool;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Utopia\Config\Config;
|
||||
@@ -55,6 +56,14 @@ final class PoolTest extends TestCase
|
||||
$this->assertSame($dsn, Pool::dsn('tablesdb', 'default', $dsn));
|
||||
}
|
||||
|
||||
public function testRejectsEmptyProjectDatabaseForTablesDB(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionMessage('Project database DSN is required for tablesdb databases');
|
||||
|
||||
Pool::dsn('tablesdb', 'default', null);
|
||||
}
|
||||
|
||||
public function testSelectsDocumentsDatabasePool(): void
|
||||
{
|
||||
Config::setParam('pools-documentsdb', ['documents']);
|
||||
|
||||
Reference in new issue
Block a user