From 079acfe003b067c4c4465bc84603cbd1c4dc12d8 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Thu, 5 Aug 2021 09:12:19 -0400 Subject: [PATCH 1/2] Remove unique index from collection name --- src/Database/Database.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index 4029f46b01..10e094a253 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -230,16 +230,7 @@ public function create(): bool ['indexesInQueue', self::VAR_STRING, 1000000, false], ]); - /** @var Document[] $indexes*/ - $indexes = [ - new Document([ - '$id' => '_key_1', - 'type' => self::INDEX_UNIQUE, - 'attributes' => ['name'], - ]) - ]; - - $this->createCollection(self::COLLECTIONS, $attributes, $indexes); + $this->createCollection(self::COLLECTIONS, $attributes); return true; } From 6b1e96cbbbea22422df345ca65456b9f0b2e230e Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Thu, 5 Aug 2021 10:07:07 -0400 Subject: [PATCH 2/2] Test for non-unique collection names --- tests/Database/Base.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/Database/Base.php b/tests/Database/Base.php index d517186f82..f64715ed05 100644 --- a/tests/Database/Base.php +++ b/tests/Database/Base.php @@ -64,6 +64,15 @@ public function testCreateListDeleteCollection() $this->assertCount(1, static::getDatabase()->listCollections()); + // Collection names should not be unique + $this->assertInstanceOf('Utopia\Database\Document', static::getDatabase()->createCollection('actors2')); + $this->assertCount(2, static::getDatabase()->listCollections()); + $collection = static::getDatabase()->getCollection('actors2'); + $collection->setAttribute('name', 'actors'); // change name to one that exists + $this->assertInstanceOf('Utopia\Database\Document', static::getDatabase()->updateDocument($collection->getCollection(), $collection->getId(), $collection)); + $this->assertEquals(true, static::getDatabase()->deleteCollection('actors2')); // Delete collection when finished + $this->assertCount(1, static::getDatabase()->listCollections()); + $this->assertEquals(false, static::getDatabase()->getCollection('actors')->isEmpty()); $this->assertEquals(true, static::getDatabase()->deleteCollection('actors')); $this->assertEquals(true, static::getDatabase()->getCollection('actors')->isEmpty());