mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
(fix): strip database prefix from internal collection name before mapping lookup
The decorator receives full internal keys like 'database_2_collection_15' but the mapping uses relative keys like 'collection_15'. Strip the database prefix before looking up the mapping. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
1c19cf5323
commit
7dca267727
1 file changed
+14
-2
@@ -80,11 +80,23 @@ class Metadata implements Decorator
|
||||
return $this->collectionIdMap[$internalName];
|
||||
}
|
||||
|
||||
// Strip database prefix if present (e.g., 'database_2_collection_15' → 'collection_15')
|
||||
$databasePrefix = 'database_' . $this->database->getSequence() . '_';
|
||||
$relativeName = \str_starts_with($internalName, $databasePrefix)
|
||||
? \substr($internalName, \strlen($databasePrefix))
|
||||
: $internalName;
|
||||
|
||||
if (isset($this->collectionIdMap[$relativeName])) {
|
||||
$this->collectionIdMap[$internalName] = $this->collectionIdMap[$relativeName];
|
||||
return $this->collectionIdMap[$relativeName];
|
||||
}
|
||||
|
||||
if (!$this->mapLoaded && $this->dbForProject !== null && $this->authorization !== null) {
|
||||
$this->mapLoaded = true;
|
||||
$this->loadCollectionMap();
|
||||
if (isset($this->collectionIdMap[$internalName])) {
|
||||
return $this->collectionIdMap[$internalName];
|
||||
if (isset($this->collectionIdMap[$relativeName])) {
|
||||
$this->collectionIdMap[$internalName] = $this->collectionIdMap[$relativeName];
|
||||
return $this->collectionIdMap[$relativeName];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user