diff --git a/src/Database/Database.php b/src/Database/Database.php index b4fed64c9..8f66d0475 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -4515,7 +4515,8 @@ private function validateSelections(Document $collection, array $queries): array $keys = []; foreach ($collection->getAttribute('attributes', []) as $attribute) { if ($attribute['type'] !== self::VAR_RELATIONSHIP) { - $keys[] = $attribute['key']; + // Fallback to $id when key property is not present in metadata table for some tables such as Indexes or Attributes + $keys[] = $attribute['key'] ?? $attribute['$id']; } }