From b082ae263314e625efb2a5f582049c7f90713e23 Mon Sep 17 00:00:00 2001 From: prateek banga Date: Thu, 3 Aug 2023 12:57:56 +0530 Subject: [PATCH] Fallback to when validating select queries Metadata tables for indexes and attributes does not have key property so select queries cannot be validated. We need to fallback on when key property is not present in such cases. This commit fixes that --- src/Database/Database.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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']; } }