mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
attempt: fixes, changes.
This commit is contained in:
@@ -3309,7 +3309,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents')
|
||||
$checkPermissions($collection, $document, Database::PERMISSION_CREATE);
|
||||
|
||||
try {
|
||||
$document = $dbForProject->createDocument('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $document);
|
||||
$document = $dbForProject->ignoreNestedQueries(fn () => $dbForProject->createDocument('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $document));
|
||||
} catch (StructureException $e) {
|
||||
throw new Exception(Exception::DOCUMENT_INVALID_STRUCTURE, $e->getMessage());
|
||||
} catch (DuplicateException $e) {
|
||||
@@ -3601,7 +3601,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen
|
||||
|
||||
try {
|
||||
$queries = Query::parseQueries($queries);
|
||||
$document = $dbForProject->getDocument('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $documentId, $queries);
|
||||
$document = $dbForProject->ignoreNestedQueries(fn () => $dbForProject->getDocument('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $documentId, $queries));
|
||||
} catch (AuthorizationException) {
|
||||
throw new Exception(Exception::USER_UNAUTHORIZED);
|
||||
} catch (QueryException $e) {
|
||||
@@ -3967,11 +3967,15 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
|
||||
try {
|
||||
$document = $dbForProject->withRequestTimestamp(
|
||||
$requestTimestamp,
|
||||
fn () => $dbForProject->updateDocument(
|
||||
'database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(),
|
||||
$document->getId(),
|
||||
$newDocument
|
||||
)
|
||||
fn () =>
|
||||
// TODO: itznotabug, jake - how much diff is this even making here?
|
||||
// I don't think we can remove the related docs when returning back the response?
|
||||
$dbForProject->ignoreNestedQueries(fn () =>
|
||||
$dbForProject->updateDocument(
|
||||
'database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(),
|
||||
$document->getId(),
|
||||
$newDocument
|
||||
))
|
||||
);
|
||||
} catch (AuthorizationException) {
|
||||
throw new Exception(Exception::USER_UNAUTHORIZED);
|
||||
|
||||
Generated
+14
-14
@@ -3502,7 +3502,7 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database",
|
||||
"reference": "88be37de468c1263dff7ee0e8921c5548ce96680"
|
||||
"reference": "5f4dc3c2a9fbd727381aea6b228f9eff5c649963"
|
||||
},
|
||||
"require": {
|
||||
"ext-mbstring": "*",
|
||||
@@ -3571,7 +3571,7 @@
|
||||
"upf",
|
||||
"utopia"
|
||||
],
|
||||
"time": "2025-04-19T10:51:50+00:00"
|
||||
"time": "2025-04-28T09:05:48+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/detector",
|
||||
@@ -3727,16 +3727,16 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/fetch",
|
||||
"version": "0.4.1",
|
||||
"version": "0.4.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/fetch.git",
|
||||
"reference": "65095dac14037db0c822fb5e209e5bd3187a0303"
|
||||
"reference": "83986d1be75a2fae4e684107fe70dd78a8e19b77"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/fetch/zipball/65095dac14037db0c822fb5e209e5bd3187a0303",
|
||||
"reference": "65095dac14037db0c822fb5e209e5bd3187a0303",
|
||||
"url": "https://api.github.com/repos/utopia-php/fetch/zipball/83986d1be75a2fae4e684107fe70dd78a8e19b77",
|
||||
"reference": "83986d1be75a2fae4e684107fe70dd78a8e19b77",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3760,9 +3760,9 @@
|
||||
"description": "A simple library that provides an interface for making HTTP Requests.",
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/fetch/issues",
|
||||
"source": "https://github.com/utopia-php/fetch/tree/0.4.1"
|
||||
"source": "https://github.com/utopia-php/fetch/tree/0.4.2"
|
||||
},
|
||||
"time": "2025-04-14T07:34:27+00:00"
|
||||
"time": "2025-04-25T13:48:02+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/framework",
|
||||
@@ -4833,16 +4833,16 @@
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "appwrite/sdk-generator",
|
||||
"version": "0.40.12",
|
||||
"version": "0.40.15",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/appwrite/sdk-generator.git",
|
||||
"reference": "182ec17848f81b78c336379bac94ff92b7a73365"
|
||||
"reference": "65c708b931b29b3e01c5cc7504a734ce2cc3dc95"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/182ec17848f81b78c336379bac94ff92b7a73365",
|
||||
"reference": "182ec17848f81b78c336379bac94ff92b7a73365",
|
||||
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/65c708b931b29b3e01c5cc7504a734ce2cc3dc95",
|
||||
"reference": "65c708b931b29b3e01c5cc7504a734ce2cc3dc95",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -4878,9 +4878,9 @@
|
||||
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
|
||||
"support": {
|
||||
"issues": "https://github.com/appwrite/sdk-generator/issues",
|
||||
"source": "https://github.com/appwrite/sdk-generator/tree/0.40.12"
|
||||
"source": "https://github.com/appwrite/sdk-generator/tree/0.40.15"
|
||||
},
|
||||
"time": "2025-04-02T23:36:11+00:00"
|
||||
"time": "2025-04-25T08:50:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/annotations",
|
||||
|
||||
@@ -4128,7 +4128,12 @@ trait DatabasesBase
|
||||
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $personCollection . '/documents/' . $person2['body']['$id'], array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
// explicitly select the nested document
|
||||
Query::select(['libraries.*'])->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertArrayNotHasKey('$collection', $response['body']);
|
||||
@@ -4138,7 +4143,12 @@ trait DatabasesBase
|
||||
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $libraryCollection . '/documents/library11', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
// explicitly select the nested document
|
||||
Query::select(['person_one_to_many.$id'])->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertArrayHasKey('person_one_to_many', $response['body']);
|
||||
@@ -4288,19 +4298,37 @@ trait DatabasesBase
|
||||
$album = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $albums['body']['$id'] . '/documents/album1', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select([
|
||||
'$id',
|
||||
'name',
|
||||
'$permissions',
|
||||
// explicitly select the nested document
|
||||
'artist.$id',
|
||||
'artist.name',
|
||||
'artist.$permissions'
|
||||
])->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $album['headers']['status-code']);
|
||||
$this->assertEquals('album1', $album['body']['$id']);
|
||||
$this->assertEquals('Album 1', $album['body']['name']);
|
||||
$this->assertEquals('Artist 1', $album['body']['artist']['name']);
|
||||
$this->assertEquals($permissions, $album['body']['$permissions']);
|
||||
$this->assertEquals('Artist 1', $album['body']['artist']['name']);
|
||||
$this->assertEquals($permissions, $album['body']['artist']['$permissions']);
|
||||
|
||||
$artist = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $artists['body']['$id'] . '/documents/' . $album['body']['artist']['$id'], array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
// explicitly select the nested document
|
||||
// Query::select(['albums'])->toString()
|
||||
// TODO: using query on this side doesn't return the related doc as its not found
|
||||
]
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $artist['headers']['status-code']);
|
||||
$this->assertEquals('Artist 1', $artist['body']['name']);
|
||||
@@ -4482,6 +4510,7 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['libraries.*'])->toString(),
|
||||
Query::isNotNull('$id')->toString(),
|
||||
Query::startsWith('fullName', 'Stevie')->toString(),
|
||||
Query::endsWith('fullName', 'Wonder')->toString(),
|
||||
|
||||
Reference in New Issue
Block a user