Merge pull request #10296 from appwrite/cursor/add-new-database-query-type-tests-5161

Add new database query type tests
This commit is contained in:
Jake Barnby 2025-08-12 18:30:16 +12:00 committed by GitHub
commit 02b83d59b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 1325 additions and 28 deletions

View file

@ -55,7 +55,8 @@ return [
'$id' => ID::custom('type'),
'type' => Database::VAR_STRING,
'size' => 128,
'required' => true,
'required' => false,
'default' => 'grids',
'signed' => true,
'array' => false,
'filters' => [],

14
composer.lock generated
View file

@ -3545,16 +3545,16 @@
},
{
"name": "utopia-php/database",
"version": "0.77.0",
"version": "0.77.4",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/database.git",
"reference": "a8ab3a7b25a5a1edf7e7afc83eda9f7aec5ba57d"
"reference": "eaa4e275cefdeeb90bcece2f056e05b59f5b1473"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/database/zipball/a8ab3a7b25a5a1edf7e7afc83eda9f7aec5ba57d",
"reference": "a8ab3a7b25a5a1edf7e7afc83eda9f7aec5ba57d",
"url": "https://api.github.com/repos/utopia-php/database/zipball/eaa4e275cefdeeb90bcece2f056e05b59f5b1473",
"reference": "eaa4e275cefdeeb90bcece2f056e05b59f5b1473",
"shasum": ""
},
"require": {
@ -3595,9 +3595,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/database/issues",
"source": "https://github.com/utopia-php/database/tree/0.77.0"
"source": "https://github.com/utopia-php/database/tree/0.77.4"
},
"time": "2025-08-07T09:30:32+00:00"
"time": "2025-08-11T13:56:31+00:00"
},
{
"name": "utopia-php/detector",
@ -4118,7 +4118,7 @@
"ext-curl": "*",
"ext-openssl": "*",
"php": ">=8.1",
"utopia-php/database": "0.71.*",
"utopia-php/database": "0.*.*",
"utopia-php/dsn": "0.2.*",
"utopia-php/framework": "0.33.*",
"utopia-php/storage": "0.18.*"

View file

@ -43,8 +43,8 @@ class Database extends Model
->addRule('type', [
'type' => self::TYPE_STRING,
'description' => 'Database type.',
'default' => 'grids',
'example' => 'grids',
'default' => 'legacy',
'example' => 'legacy',
])
;
}

File diff suppressed because it is too large Load diff

View file

@ -1382,8 +1382,7 @@ trait DatabasesBase
'attributes' => ['actors'],
]);
// Indexes on array attributes are disabled due to MySQL bug
$this->assertEquals(400, $actorsArray['headers']['status-code']);
$this->assertEquals(202, $actorsArray['headers']['status-code']);
$twoLevelsArray = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/indexes', array_merge([
'content-type' => 'application/json',
@ -1396,8 +1395,7 @@ trait DatabasesBase
'orders' => ['DESC', 'DESC'],
]);
// Indexes on array attributes are disabled due to MySQL bug
$this->assertEquals(400, $twoLevelsArray['headers']['status-code']);
$this->assertEquals(202, $twoLevelsArray['headers']['status-code']);
$unknown = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/indexes', array_merge([
'content-type' => 'application/json',
@ -1423,8 +1421,7 @@ trait DatabasesBase
'orders' => ['DESC'], // Check order is removed in API
]);
// Indexes on array attributes are disabled due to MySQL bug
$this->assertEquals(400, $index1['headers']['status-code']);
$this->assertEquals(202, $index1['headers']['status-code']);
$index2 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/indexes', array_merge([
'content-type' => 'application/json',
@ -1436,8 +1433,7 @@ trait DatabasesBase
'attributes' => ['integers'], // array attribute
]);
// Indexes on array attributes are disabled due to MySQL bug
$this->assertEquals(400, $index2['headers']['status-code']);
$this->assertEquals(202, $index2['headers']['status-code']);
/**
* Create Indexes by worker
@ -1451,7 +1447,7 @@ trait DatabasesBase
]), []);
$this->assertIsArray($movies['body']['indexes']);
$this->assertCount(4, $movies['body']['indexes']);
$this->assertCount(8, $movies['body']['indexes']);
$this->assertEquals($titleIndex['body']['key'], $movies['body']['indexes'][0]['key']);
$this->assertEquals($releaseYearIndex['body']['key'], $movies['body']['indexes'][1]['key']);
$this->assertEquals($releaseWithDate1['body']['key'], $movies['body']['indexes'][2]['key']);