Skip to content

Commit 59d9d34

Browse files
authored
Merge pull request #48 from utopia-php/fix-create-collection-no-unique-index
Fix: remove unique index from collection name
2 parents f6e4458 + 6b1e96c commit 59d9d34

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/Database/Database.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,7 @@ public function create(): bool
230230
['indexesInQueue', self::VAR_STRING, 1000000, false],
231231
]);
232232

233-
/** @var Document[] $indexes*/
234-
$indexes = [
235-
new Document([
236-
'$id' => '_key_1',
237-
'type' => self::INDEX_UNIQUE,
238-
'attributes' => ['name'],
239-
])
240-
];
241-
242-
$this->createCollection(self::COLLECTIONS, $attributes, $indexes);
233+
$this->createCollection(self::COLLECTIONS, $attributes);
243234

244235
return true;
245236
}

tests/Database/Base.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ public function testCreateListDeleteCollection()
6464

6565
$this->assertCount(1, static::getDatabase()->listCollections());
6666

67+
// Collection names should not be unique
68+
$this->assertInstanceOf('Utopia\Database\Document', static::getDatabase()->createCollection('actors2'));
69+
$this->assertCount(2, static::getDatabase()->listCollections());
70+
$collection = static::getDatabase()->getCollection('actors2');
71+
$collection->setAttribute('name', 'actors'); // change name to one that exists
72+
$this->assertInstanceOf('Utopia\Database\Document', static::getDatabase()->updateDocument($collection->getCollection(), $collection->getId(), $collection));
73+
$this->assertEquals(true, static::getDatabase()->deleteCollection('actors2')); // Delete collection when finished
74+
$this->assertCount(1, static::getDatabase()->listCollections());
75+
6776
$this->assertEquals(false, static::getDatabase()->getCollection('actors')->isEmpty());
6877
$this->assertEquals(true, static::getDatabase()->deleteCollection('actors'));
6978
$this->assertEquals(true, static::getDatabase()->getCollection('actors')->isEmpty());

0 commit comments

Comments
 (0)