From f18af04eaeb18d0071e369d012468686b67f7d73 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 20 May 2026 09:58:35 +0530 Subject: [PATCH] Fix tenant database adapter reuse --- src/Appwrite/Database/DatabaseFactory.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Database/DatabaseFactory.php b/src/Appwrite/Database/DatabaseFactory.php index afe512ce65..14ce0839ff 100644 --- a/src/Appwrite/Database/DatabaseFactory.php +++ b/src/Appwrite/Database/DatabaseFactory.php @@ -110,12 +110,15 @@ class DatabaseFactory $projectDsn = $this->dsn($project->getAttribute('database')); $databaseType = $databaseDocument->getAttribute('type', ''); - $database = $this->newDatabase($this->adapter($databaseDsn->getHost())); + $database = $this->newDatabase(new DatabasePool($this->pools->get($databaseDsn->getHost()))); $database ->setDatabase($this->database) ->setAuthorization($this->authorization); + // This flag is adapter-level mutable state. Tenant databases can share the same + // pool name while requiring different attribute support (for example TablesDB + // versus DocumentsDB), so this adapter must not be reused from the factory cache. $database->getAdapter()->setSupportForAttributes($databaseType !== DOCUMENTSDB); if ($preserveDates) {