Skip to content

Commit 8397a91

Browse files
refactor: Make DeleteItemsRequest and QueryItemsRequest constructor parameters optional with null defaults, simplifying test calls.
1 parent 807c01c commit 8397a91

3 files changed

Lines changed: 8 additions & 21 deletions

File tree

src/Requests/DeleteItemsRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ class DeleteItemsRequest
1313
* @param array<string, string> $whereDocument Optional query condition to filter items to delete based on document content.
1414
*/
1515
public function __construct(
16-
public readonly ?array $ids,
17-
public readonly ?array $where,
18-
public readonly ?array $whereDocument,
16+
public readonly ?array $ids = null,
17+
public readonly ?array $where = null,
18+
public readonly ?array $whereDocument = null,
1919
) {}
2020

2121
public static function fromArray(array $data): self

src/Requests/QueryItemsRequest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ class QueryItemsRequest
1515
* @param string[] $include Optional list of items to include in the response.
1616
*/
1717
public function __construct(
18-
public readonly ?array $where,
19-
public readonly ?array $whereDocument,
20-
public readonly ?array $queryEmbeddings,
21-
public readonly ?int $nResults,
22-
public readonly ?array $include,
18+
public readonly ?array $where = null,
19+
public readonly ?array $whereDocument = null,
20+
public readonly ?array $queryEmbeddings = null,
21+
public readonly ?int $nResults = null,
22+
public readonly ?array $include = null,
2323
) {}
2424

2525
public static function fromArray(array $data): self

tests/Feature/ApiTest.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Codewithkyrian\ChromaDB\Tests\Feature;
66

77
use Codewithkyrian\ChromaDB\ChromaDB;
8-
use Codewithkyrian\ChromaDB\Exceptions\ChromaException;
98
use Codewithkyrian\ChromaDB\Exceptions\InvalidArgumentException;
109
use Codewithkyrian\ChromaDB\Exceptions\NotFoundException;
1110
use Codewithkyrian\ChromaDB\Exceptions\UniqueConstraintException;
@@ -18,7 +17,6 @@
1817
use Codewithkyrian\ChromaDB\Requests\QueryItemsRequest;
1918
use Codewithkyrian\ChromaDB\Requests\UpdateCollectionRequest;
2019
use Codewithkyrian\ChromaDB\Requests\UpdateItemsRequest;
21-
use Codewithkyrian\ChromaDB\Requests\UpdateTenantRequest;
2220

2321
beforeEach(function () {
2422
$this->api = ChromaDB::factory()
@@ -264,12 +262,6 @@
264262

265263
$items = $this->api->getCollectionItems($collection->id, 'default_database', 'default_tenant', new GetEmbeddingRequest(
266264
ids: ['id1'],
267-
where: null,
268-
whereDocument: null,
269-
sort: null,
270-
limit: null,
271-
offset: null,
272-
include: []
273265
));
274266
expect($items->ids)->toContain('id1')
275267
->and($items->ids)->not->toContain('id2');
@@ -289,9 +281,6 @@
289281
$query = $this->api->queryCollectionItems($collection->id, 'default_database', 'default_tenant', new QueryItemsRequest(
290282
queryEmbeddings: [[1.1, 2.2]],
291283
nResults: 1,
292-
where: null,
293-
whereDocument: null,
294-
include: []
295284
));
296285
expect($query->ids[0])->toContain('id1');
297286
});
@@ -351,8 +340,6 @@
351340

352341
$this->api->deleteCollectionItems($collection->id, 'default_database', 'default_tenant', new DeleteItemsRequest(
353342
ids: ['id1'],
354-
where: null,
355-
whereDocument: null
356343
));
357344
$count = $this->api->countCollectionItems($collection->id, 'default_database', 'default_tenant');
358345
expect($count)->toBe(1);

0 commit comments

Comments
 (0)