|
2 | 2 |
|
3 | 3 | namespace Tests\E2E\Adapter\Scopes; |
4 | 4 |
|
| 5 | +use Exception; |
5 | 6 | use Utopia\Database\Database; |
6 | 7 | use Utopia\Database\Document; |
7 | 8 | use Utopia\Database\Exception\Index as IndexException; |
| 9 | +use Utopia\Database\Exception\Query as QueryException; |
8 | 10 | use Utopia\Database\Exception\Structure as StructureException; |
9 | 11 | use Utopia\Database\Helpers\ID; |
10 | 12 | use Utopia\Database\Helpers\Permission; |
@@ -152,21 +154,31 @@ public function testObjectAttribute(): void |
152 | 154 |
|
153 | 155 | // Test 11d: notEqual on scalar inside object should exclude doc1 |
154 | 156 | $results = $database->find($collectionId, [ |
155 | | - Query::notEqual('meta', [['age' => 26]]) |
| 157 | + Query::notEqual('meta', ['age' => 26]) |
156 | 158 | ]); |
157 | 159 | // Should return doc2 only |
158 | 160 | $this->assertCount(1, $results); |
159 | 161 | $this->assertEquals('doc2', $results[0]->getId()); |
160 | 162 |
|
| 163 | + try { |
| 164 | + // test -> not equal allows one value only |
| 165 | + $results = $database->find($collectionId, [ |
| 166 | + Query::notEqual('meta', [['age' => 26],['age' => 27]]) |
| 167 | + ]); |
| 168 | + $this->fail('No query thrown'); |
| 169 | + } catch (Exception $e) { |
| 170 | + $this->assertInstanceOf(QueryException::class, $e); |
| 171 | + } |
| 172 | + |
161 | 173 | // Test 11e: notEqual on nested object should exclude doc1 |
162 | 174 | $results = $database->find($collectionId, [ |
163 | | - Query::notEqual('meta', [[ |
| 175 | + Query::notEqual('meta', [ |
164 | 176 | 'user' => [ |
165 | 177 | 'info' => [ |
166 | 178 | 'country' => 'CA' |
167 | 179 | ] |
168 | 180 | ] |
169 | | - ]]) |
| 181 | + ]) |
170 | 182 | ]); |
171 | 183 | // Should return doc2 only |
172 | 184 | $this->assertCount(1, $results); |
@@ -588,9 +600,10 @@ public function testObjectAttributeGinIndex(): void |
588 | 600 |
|
589 | 601 | // Test 3: Query with equal on indexed JSONB column |
590 | 602 | $results = $database->find($collectionId, [ |
591 | | - Query::equal('data', [['env' => 'production']]) |
| 603 | + Query::equal('data', [['config' => ['env' => 'production']]]) |
592 | 604 | ]); |
593 | | - $this->assertCount(0, $results); // Note: Object index doesn't make equal queries work differently |
| 605 | + $this->assertCount(1, $results); |
| 606 | + $this->assertEquals('gin1', $results[0]->getId()); |
594 | 607 |
|
595 | 608 | // Test 4: Query with contains on indexed JSONB column |
596 | 609 | $results = $database->find($collectionId, [ |
|
0 commit comments