mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 17:08:45 +00:00
Merge pull request #10596 from appwrite/feat-update-relationships
Update database
This commit is contained in:
commit
3190d0437e
8 changed files with 52 additions and 44 deletions
|
|
@ -52,7 +52,7 @@
|
|||
"utopia-php/cache": "0.13.*",
|
||||
"utopia-php/cli": "0.15.*",
|
||||
"utopia-php/config": "0.2.*",
|
||||
"utopia-php/database": "1.*",
|
||||
"utopia-php/database": "2.*",
|
||||
"utopia-php/detector": "0.1.*",
|
||||
"utopia-php/domains": "0.8.*",
|
||||
"utopia-php/dns": "0.3.*",
|
||||
|
|
|
|||
68
composer.lock
generated
68
composer.lock
generated
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "7553e976312b0423cc31544abb91caec",
|
||||
"content-hash": "773efb29b9b584b1249790e0016c823a",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
|
|
@ -1927,16 +1927,16 @@
|
|||
},
|
||||
{
|
||||
"name": "phpseclib/phpseclib",
|
||||
"version": "3.0.46",
|
||||
"version": "3.0.47",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpseclib/phpseclib.git",
|
||||
"reference": "56483a7de62a6c2a6635e42e93b8a9e25d4f0ec6"
|
||||
"reference": "9d6ca36a6c2dd434765b1071b2644a1c683b385d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/56483a7de62a6c2a6635e42e93b8a9e25d4f0ec6",
|
||||
"reference": "56483a7de62a6c2a6635e42e93b8a9e25d4f0ec6",
|
||||
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/9d6ca36a6c2dd434765b1071b2644a1c683b385d",
|
||||
"reference": "9d6ca36a6c2dd434765b1071b2644a1c683b385d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -2017,7 +2017,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/phpseclib/phpseclib/issues",
|
||||
"source": "https://github.com/phpseclib/phpseclib/tree/3.0.46"
|
||||
"source": "https://github.com/phpseclib/phpseclib/tree/3.0.47"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -2033,7 +2033,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2025-06-26T16:29:55+00:00"
|
||||
"time": "2025-10-06T01:07:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/container",
|
||||
|
|
@ -3293,16 +3293,16 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/abuse",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/abuse.git",
|
||||
"reference": "c5e2232033b507a07f72180dc56d37e1872ee7be"
|
||||
"reference": "cd591568791556d246d901d6aaf9935ab02c3f9a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/c5e2232033b507a07f72180dc56d37e1872ee7be",
|
||||
"reference": "c5e2232033b507a07f72180dc56d37e1872ee7be",
|
||||
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/cd591568791556d246d901d6aaf9935ab02c3f9a",
|
||||
"reference": "cd591568791556d246d901d6aaf9935ab02c3f9a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -3310,7 +3310,7 @@
|
|||
"ext-pdo": "*",
|
||||
"ext-redis": "*",
|
||||
"php": ">=8.0",
|
||||
"utopia-php/database": "1.*"
|
||||
"utopia-php/database": "2.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"laravel/pint": "1.*",
|
||||
|
|
@ -3338,9 +3338,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/abuse/issues",
|
||||
"source": "https://github.com/utopia-php/abuse/tree/1.0.0"
|
||||
"source": "https://github.com/utopia-php/abuse/tree/1.0.1"
|
||||
},
|
||||
"time": "2025-08-13T09:12:54+00:00"
|
||||
"time": "2025-09-04T12:46:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/analytics",
|
||||
|
|
@ -3390,21 +3390,21 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/audit",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/audit.git",
|
||||
"reference": "c0ed75f4d068f1f6c2e7149a909490d4214e72bb"
|
||||
"reference": "5ef26d6a2ab2db7bb86288a1a6ef970307b46f22"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/audit/zipball/c0ed75f4d068f1f6c2e7149a909490d4214e72bb",
|
||||
"reference": "c0ed75f4d068f1f6c2e7149a909490d4214e72bb",
|
||||
"url": "https://api.github.com/repos/utopia-php/audit/zipball/5ef26d6a2ab2db7bb86288a1a6ef970307b46f22",
|
||||
"reference": "5ef26d6a2ab2db7bb86288a1a6ef970307b46f22",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.0",
|
||||
"utopia-php/database": "1.*"
|
||||
"utopia-php/database": "2.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"laravel/pint": "1.*",
|
||||
|
|
@ -3431,9 +3431,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/audit/issues",
|
||||
"source": "https://github.com/utopia-php/audit/tree/1.0.0"
|
||||
"source": "https://github.com/utopia-php/audit/tree/1.0.1"
|
||||
},
|
||||
"time": "2025-08-13T09:09:00+00:00"
|
||||
"time": "2025-09-04T12:46:43+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/cache",
|
||||
|
|
@ -3635,16 +3635,16 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/database",
|
||||
"version": "1.5.1",
|
||||
"version": "2.3.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database.git",
|
||||
"reference": "56efe4daaf23abb753553acffccdcc04cd6178c9"
|
||||
"reference": "a91e04080d7f13c35c4885dea0ffebc33cd33e1f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/56efe4daaf23abb753553acffccdcc04cd6178c9",
|
||||
"reference": "56efe4daaf23abb753553acffccdcc04cd6178c9",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/a91e04080d7f13c35c4885dea0ffebc33cd33e1f",
|
||||
"reference": "a91e04080d7f13c35c4885dea0ffebc33cd33e1f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -3685,9 +3685,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/database/issues",
|
||||
"source": "https://github.com/utopia-php/database/tree/1.5.1"
|
||||
"source": "https://github.com/utopia-php/database/tree/2.3.1"
|
||||
},
|
||||
"time": "2025-10-01T04:44:14+00:00"
|
||||
"time": "2025-10-06T04:29:14+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/detector",
|
||||
|
|
@ -4187,16 +4187,16 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/migration",
|
||||
"version": "1.2.0",
|
||||
"version": "1.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/migration.git",
|
||||
"reference": "42ff497c5231f5a727d1e229419ff1d2195d8093"
|
||||
"reference": "6fb6f8f032cd34c3c65728a55d494adeac2ff038"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/migration/zipball/42ff497c5231f5a727d1e229419ff1d2195d8093",
|
||||
"reference": "42ff497c5231f5a727d1e229419ff1d2195d8093",
|
||||
"url": "https://api.github.com/repos/utopia-php/migration/zipball/6fb6f8f032cd34c3c65728a55d494adeac2ff038",
|
||||
"reference": "6fb6f8f032cd34c3c65728a55d494adeac2ff038",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -4204,7 +4204,7 @@
|
|||
"ext-curl": "*",
|
||||
"ext-openssl": "*",
|
||||
"php": ">=8.1",
|
||||
"utopia-php/database": "1.*",
|
||||
"utopia-php/database": "2.*",
|
||||
"utopia-php/dsn": "0.2.*",
|
||||
"utopia-php/framework": "0.33.*",
|
||||
"utopia-php/storage": "0.18.*"
|
||||
|
|
@ -4237,9 +4237,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/migration/issues",
|
||||
"source": "https://github.com/utopia-php/migration/tree/1.2.0"
|
||||
"source": "https://github.com/utopia-php/migration/tree/1.1.0"
|
||||
},
|
||||
"time": "2025-09-24T10:32:24+00:00"
|
||||
"time": "2025-09-10T05:45:30+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/orchestration",
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class Upsert extends Action
|
|||
|
||||
try {
|
||||
$modified = $dbForProject->withPreserveDates(function () use ($dbForProject, $database, $collection, $documents, $plan, &$upserted) {
|
||||
return $dbForProject->createOrUpdateDocuments(
|
||||
return $dbForProject->upsertDocuments(
|
||||
'database_' . $database->getSequence() . '_collection_' . $collection->getSequence(),
|
||||
$documents,
|
||||
onNext: function (Document $document) use ($plan, &$upserted) {
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ class Upsert extends Action
|
|||
$upserted = [];
|
||||
try {
|
||||
$dbForProject->withPreserveDates(function () use (&$upserted, $dbForProject, $database, $collection, $newDocument) {
|
||||
return $dbForProject->createOrUpdateDocuments(
|
||||
return $dbForProject->upsertDocuments(
|
||||
'database_' . $database->getSequence() . '_collection_' . $collection->getSequence(),
|
||||
[$newDocument],
|
||||
onNext: function (Document $document) use (&$upserted) {
|
||||
|
|
|
|||
|
|
@ -462,7 +462,7 @@ class StatsResources extends Action
|
|||
});
|
||||
|
||||
try {
|
||||
$dbForLogs->createOrUpdateDocuments(
|
||||
$dbForLogs->upsertDocuments(
|
||||
'stats',
|
||||
$this->documents,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -452,7 +452,7 @@ class StatsUsage extends Action
|
|||
return strcmp($a['time'], $b['time']);
|
||||
});
|
||||
|
||||
$dbForProject->createOrUpdateDocumentsWithIncrease('stats', 'value', $projectStats['stats']);
|
||||
$dbForProject->upsertDocumentsWithIncrease('stats', 'value', $projectStats['stats']);
|
||||
Console::success('Batch successfully written to DB');
|
||||
} catch (Throwable $e) {
|
||||
Console::error('Error processing stats: ' . $e->getMessage());
|
||||
|
|
@ -532,7 +532,7 @@ class StatsUsage extends Action
|
|||
return strcmp($a['time'], $b['time']);
|
||||
});
|
||||
|
||||
$dbForLogs->createOrUpdateDocumentsWithIncrease(
|
||||
$dbForLogs->upsertDocumentsWithIncrease(
|
||||
'stats',
|
||||
'value',
|
||||
$this->statDocuments
|
||||
|
|
|
|||
|
|
@ -4711,12 +4711,16 @@ trait DatabasesBase
|
|||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['library.*'])->toString(),
|
||||
Query::equal('library.libraryName', ['Library 1'])->toString(),
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertEquals(400, $documents['headers']['status-code']);
|
||||
$this->assertEquals('Invalid query: Cannot query nested attribute on: library', $documents['body']['message']);
|
||||
$this->assertEquals(200, $documents['headers']['status-code']);
|
||||
$this->assertEquals(1, $documents['body']['total']);
|
||||
$this->assertCount(1, $documents['body']['documents']);
|
||||
$this->assertEquals('Library 1', $documents['body']['documents'][0]['library']['libraryName']);
|
||||
$this->assertEquals($person1['body']['$id'], $documents['body']['documents'][0]['$id']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/collections/' . $person['body']['$id'] . '/attributes/library', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
|
|
|
|||
|
|
@ -4638,12 +4638,16 @@ trait DatabasesBase
|
|||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['library.*'])->toString(),
|
||||
Query::equal('library.libraryName', ['Library 1'])->toString(),
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertEquals(400, $rows['headers']['status-code']);
|
||||
$this->assertEquals('Invalid query: Cannot query nested attribute on: library', $rows['body']['message']);
|
||||
$this->assertEquals(200, $rows['headers']['status-code']);
|
||||
$this->assertEquals(1, $rows['body']['total']);
|
||||
$this->assertCount(1, $rows['body']['rows']);
|
||||
$this->assertEquals('Library 1', $rows['body']['rows'][0]['library']['libraryName']);
|
||||
$this->assertEquals($person1['body']['$id'], $rows['body']['rows'][0]['$id']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_DELETE, '/tablesdb/' . $databaseId . '/tables/' . $person['body']['$id'] . '/columns/library', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
|
|
|
|||
Loading…
Reference in a new issue