(test): add e2e test for $sequence query type validation per adapter

This commit is contained in:
Jake Barnby
2026-03-20 18:03:17 +13:00
parent 91e252382b
commit c9d023991d
@@ -3518,6 +3518,62 @@ trait DatabasesBase
$this->assertEquals(200, $response['headers']['status-code']);
}
public function testQueryBySequenceType(): void
{
$data = $this->setupDocuments();
$databaseId = $data['databaseId'];
$documents = $this->client->call(Client::METHOD_GET, $this->getRecordUrl($databaseId, $data['moviesId']), array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => [
Query::equal('$id', $data['documentIds'])->toString(),
],
]);
$this->assertEquals(200, $documents['headers']['status-code']);
$this->assertGreaterThan(0, count($documents['body'][$this->getRecordResource()]));
$sequence = $documents['body'][$this->getRecordResource()][0]['$sequence'];
$this->assertIsString($sequence);
// Query with string $sequence value (supported by all adapters)
$response = $this->client->call(Client::METHOD_GET, $this->getRecordUrl($databaseId, $data['moviesId']), array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => [
Query::equal('$sequence', [$sequence])->toString(),
],
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertCount(1, $response['body'][$this->getRecordResource()]);
$this->assertIsString($response['body'][$this->getRecordResource()][0]['$sequence']);
$this->assertSame($sequence, $response['body'][$this->getRecordResource()][0]['$sequence']);
// Query with int $sequence value (supported by SQL adapters, rejected by MongoDB)
$intSequence = (int)$sequence;
$response = $this->client->call(Client::METHOD_GET, $this->getRecordUrl($databaseId, $data['moviesId']), array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => [
Query::equal('$sequence', [$intSequence])->toString(),
],
]);
$adapter = getenv('_APP_DB_ADAPTER');
if ($adapter === 'mongodb') {
$this->assertEquals(400, $response['headers']['status-code']);
} else {
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertCount(1, $response['body'][$this->getRecordResource()]);
$this->assertIsString($response['body'][$this->getRecordResource()][0]['$sequence']);
}
}
public function testListDocumentsAfterPagination(): void
{
$data = $this->setupDocuments();